bug 559180 - add local autorelease pools to avoid cocoa object leaks during shutdown. r=josh
authorJonathan Kew <jfkthame@gmail.com>
Wed, 14 Apr 2010 16:11:12 +0100
changeset 40761 a8fd7c7e46ac3123ebcdd018de317deea5d7861d
parent 40760 90861e26db38d3719232169e7159525f1e6a98c5
child 40762 1b4a2702d2dd22c0ad25f0730eb8721e08f0769b
push id12802
push userjkew@mozilla.com
push dateWed, 14 Apr 2010 15:22:37 +0000
treeherdermozilla-central@a8fd7c7e46ac [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjosh
bugs559180
milestone1.9.3a5pre
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
bug 559180 - add local autorelease pools to avoid cocoa object leaks during shutdown. r=josh
widget/src/cocoa/nsCocoaWindow.mm
widget/src/cocoa/nsMenuBarX.mm
widget/src/cocoa/nsMenuX.mm
widget/src/cocoa/nsNativeThemeCocoa.mm
--- a/widget/src/cocoa/nsCocoaWindow.mm
+++ b/widget/src/cocoa/nsCocoaWindow.mm
@@ -148,16 +148,20 @@ nsCocoaWindow::nsCocoaWindow()
 {
 
 }
 
 void nsCocoaWindow::DestroyNativeWindow()
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
+  // During shutdown, this is called outside the event loop;
+  // provide an autorelease pool to prevent cocoa object leakage.
+  nsAutoreleasePool localPool;
+
   CleanUpWindowFilter();
   // We want to unhook the delegate here because we don't want events
   // sent to it after this object has been destroyed.
   [mWindow setDelegate:nil];
   [mWindow close];
   [mDelegate autorelease];
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
--- a/widget/src/cocoa/nsMenuBarX.mm
+++ b/widget/src/cocoa/nsMenuBarX.mm
@@ -96,16 +96,20 @@ nsMenuBarX::nsMenuBarX()
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
 nsMenuBarX::~nsMenuBarX()
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
+  // During shutdown, this is called outside the event loop;
+  // provide an autorelease pool to prevent cocoa object leakage.
+  nsAutoreleasePool localPool;
+
   if (nsMenuBarX::sLastGeckoMenuBarPainted == this)
     nsMenuBarX::sLastGeckoMenuBarPainted = nsnull;
 
   // the quit/pref items of a random window might have been used if there was no
   // hidden window, thus we need to invalidate the weak references.
   if (sAboutItemContent == mAboutItemContent)
     sAboutItemContent = nsnull;
   if (sQuitItemContent == mQuitItemContent)
--- a/widget/src/cocoa/nsMenuX.mm
+++ b/widget/src/cocoa/nsMenuX.mm
@@ -157,16 +157,20 @@ nsMenuX::nsMenuX()
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
 nsMenuX::~nsMenuX()
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
+  // During shutdown, this is called outside the event loop;
+  // provide an autorelease pool to prevent cocoa object leakage.
+  nsAutoreleasePool localPool;
+
   // Prevent the icon object from outliving us.
   if (mIcon)
     mIcon->Destroy();
 
   RemoveAll();
 
   [mNativeMenu setDelegate:nil];
   [mNativeMenu release];
--- a/widget/src/cocoa/nsNativeThemeCocoa.mm
+++ b/widget/src/cocoa/nsNativeThemeCocoa.mm
@@ -227,16 +227,20 @@ nsNativeThemeCocoa::nsNativeThemeCocoa()
 
   NS_OBJC_END_TRY_ABORT_BLOCK;
 }
 
 nsNativeThemeCocoa::~nsNativeThemeCocoa()
 {
   NS_OBJC_BEGIN_TRY_ABORT_BLOCK;
 
+  // During shutdown, this is called outside the event loop;
+  // provide an autorelease pool to prevent cocoa object leakage.
+  nsAutoreleasePool localPool;
+
   [mPushButtonCell release];
   [mRadioButtonCell release];
   [mCheckboxCell release];
   [mSearchFieldCell release];
   [mDropdownCell release];
   [mComboBoxCell release];
   [mCellDrawView release];