]> khamidou — GitHub mirrors - electron.git/commitdiff
mac: Avoid managing NSWindow by hand.
authorCheng Zhao <zcbenz@gmail.com>
Fri, 11 Apr 2014 04:47:22 +0000 (12:47 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Fri, 11 Apr 2014 04:47:22 +0000 (12:47 +0800)
atom/browser/native_window_mac.h
atom/browser/native_window_mac.mm

index 0e62762d5b332f797d8d8df73a7f49cd569b009a..1a8efc9f2ed74500e3fe3e2f49ec4f2836b8372b 100644 (file)
@@ -7,6 +7,7 @@
 
 #import <Cocoa/Cocoa.h>
 
+#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<DraggableRegion>& regions);
 
-  NSWindow* window_;
+  base::scoped_nsobject<NSWindow> window_;
 
   bool is_kiosk_;
 
index 1715aed4dbee55484510113b5cef20642f85e6f8..d0ea3efb88e5c6b480c0bd01992df5dce7a2dbfb 100644 (file)
@@ -7,7 +7,6 @@
 #include <string>
 
 #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];
   }
 }