]> khamidou — GitHub mirrors - electron.git/commitdiff
mac: Destroy the app delegate before running destruction callbacks
authorCheng Zhao <zcbenz@gmail.com>
Wed, 4 Nov 2015 09:23:27 +0000 (17:23 +0800)
committerCheng Zhao <zcbenz@gmail.com>
Wed, 4 Nov 2015 09:23:27 +0000 (17:23 +0800)
Otherwise users might be able to access wrapper functions after they are
destroyed.

atom/browser/atom_browser_main_parts.cc
atom/browser/atom_browser_main_parts.h
atom/browser/atom_browser_main_parts_mac.mm

index 5fae5bfdbedd3ca54b6370eb3bacb1d9e4372c12..f6d1070e875df5d98d6f8becd814180c12af6d6b 100644 (file)
@@ -128,6 +128,10 @@ void AtomBrowserMainParts::PostMainMessageLoopStart() {
 void AtomBrowserMainParts::PostMainMessageLoopRun() {
   brightray::BrowserMainParts::PostMainMessageLoopRun();
 
+#if defined(OS_MACOSX)
+  FreeAppDelegate();
+#endif
+
   // Make sure destruction callbacks are called before message loop is
   // destroyed, otherwise some objects that need to be deleted on IO thread
   // won't be freed.
index 65b142157dc1333dcd989fe897401befae0efc99..360b1cba1169f293d3d522dee521cafd8340030c 100644 (file)
@@ -46,7 +46,6 @@ class AtomBrowserMainParts : public brightray::BrowserMainParts {
   void PostMainMessageLoopRun() override;
 #if defined(OS_MACOSX)
   void PreMainMessageLoopStart() override;
-  void PostDestroyThreads() override;
 #endif
 
  private:
@@ -56,6 +55,10 @@ class AtomBrowserMainParts : public brightray::BrowserMainParts {
   void HandleShutdownSignals();
 #endif
 
+#if defined(OS_MACOSX)
+  void FreeAppDelegate();
+#endif
+
   // A fake BrowserProcess object that used to feed the source code from chrome.
   scoped_ptr<BrowserProcess> fake_browser_process_;
 
index 1de07dfc0e4409902e792b486afbca9a00c85e10..42e3100f490efbd5ee05416c26fe0289dc0fd850 100644 (file)
@@ -34,7 +34,7 @@ void AtomBrowserMainParts::PreMainMessageLoopStart() {
       setObject:@"NO" forKey:@"NSTreatUnknownArgumentsAsOpen"];
 }
 
-void AtomBrowserMainParts::PostDestroyThreads() {
+void AtomBrowserMainParts::FreeAppDelegate() {
   [[NSApp delegate] release];
   [NSApp setDelegate:nil];
 }