From: Cheng Zhao Date: Fri, 11 Apr 2014 04:47:22 +0000 (+0800) Subject: mac: Avoid managing NSWindow by hand. X-Git-Tag: v0.11.9~2 X-Git-Url: http://git.khamidou.com/?a=commitdiff_plain;h=84d458687a88eea837c8040d1793ad917a9a866d;p=electron.git mac: Avoid managing NSWindow by hand. --- diff --git a/atom/browser/native_window_mac.h b/atom/browser/native_window_mac.h index 0e62762d..1a8efc9f 100644 --- a/atom/browser/native_window_mac.h +++ b/atom/browser/native_window_mac.h @@ -7,6 +7,7 @@ #import +#include "base/mac/scoped_nsobject.h" #include "base/memory/scoped_ptr.h" #include "atom/browser/native_window.h" @@ -86,7 +87,7 @@ class NativeWindowMac : public NativeWindow { void UpdateDraggableRegionsForCustomDrag( const std::vector& regions); - NSWindow* window_; + base::scoped_nsobject window_; bool is_kiosk_; diff --git a/atom/browser/native_window_mac.mm b/atom/browser/native_window_mac.mm index 1715aed4..d0ea3efb 100644 --- a/atom/browser/native_window_mac.mm +++ b/atom/browser/native_window_mac.mm @@ -7,7 +7,6 @@ #include #include "base/mac/mac_util.h" -#include "base/mac/scoped_nsobject.h" #include "base/strings/sys_string_conversions.h" #include "base/values.h" #import "atom/browser/ui/cocoa/event_processing_window.h" @@ -170,7 +169,7 @@ NativeWindowMac::NativeWindowMac(content::WebContents* web_contents, defer:YES]; [atomWindow setShell:this]; - window_ = atomWindow; + window_.reset(atomWindow); AtomNSWindowDelegate* delegate = [[AtomNSWindowDelegate alloc] initWithShell:this]; @@ -203,9 +202,6 @@ NativeWindowMac::~NativeWindowMac() { // Force InspectableWebContents to be destroyed before we destroy window, // because it may still be observing the window at this time. inspectable_web_contents_.reset(); - - if (window_) - [window_ release]; } void NativeWindowMac::Close() { @@ -332,10 +328,10 @@ gfx::Size NativeWindowMac::GetMaximumSize() { void NativeWindowMac::SetResizable(bool resizable) { if (resizable) { [[window_ standardWindowButton:NSWindowZoomButton] setEnabled:YES]; - [window_ setStyleMask:window_.styleMask | NSResizableWindowMask]; + [window_ setStyleMask:[window_ styleMask] | NSResizableWindowMask]; } else { [[window_ standardWindowButton:NSWindowZoomButton] setEnabled:NO]; - [window_ setStyleMask:window_.styleMask ^ NSResizableWindowMask]; + [window_ setStyleMask:[window_ styleMask] ^ NSResizableWindowMask]; } }