Bug 810618. Make sure we don't allow layout statics to go away while we're still trying to use them. r=khuey
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 13 Nov 2012 00:26:55 -0800
changeset 121717 92cb4a2c1ed4d51eb37d9ccf467fa7abacdd5772
parent 121716 2378c3dd095d6a27e5ae93a2f8bfbdabb8098045
child 121718 470acc9eaa36c312a0ac712243801d74ef7411e8
push id273
push userlsblakk@mozilla.com
push dateThu, 14 Feb 2013 23:19:38 +0000
treeherdermozilla-release@c5e807a3f8b8 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskhuey
bugs810618
milestone19.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 810618. Make sure we don't allow layout statics to go away while we're still trying to use them. r=khuey
dom/bindings/CallbackFunction.h
--- a/dom/bindings/CallbackFunction.h
+++ b/dom/bindings/CallbackFunction.h
@@ -22,16 +22,17 @@
 #include "jsapi.h"
 #include "jswrapper.h"
 #include "mozilla/Assertions.h"
 #include "mozilla/Util.h"
 #include "nsContentUtils.h"
 #include "nsWrapperCache.h"
 #include "nsJSEnvironment.h"
 #include "xpcpublic.h"
+#include "nsLayoutStatics.h"
 
 namespace mozilla {
 namespace dom {
 
 class CallbackFunction : public nsISupports
 {
 public:
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
@@ -58,16 +59,18 @@ public:
         *aInited = false;
         return;
       }
     }
 
     // Set mCallable before we hold, on the off chance that a GC could somehow
     // happen in there... (which would be pretty odd, granted).
     mCallable = aCallable;
+    // Make sure we'll be able to drop as needed
+    nsLayoutStatics::AddRef();
     NS_HOLD_JS_OBJECTS(this, CallbackFunction);
     *aInited = true;
   }
 
   virtual ~CallbackFunction()
   {
     DropCallback();
   }
@@ -85,16 +88,17 @@ public:
   }
 
 protected:
   void DropCallback()
   {
     if (mCallable) {
       NS_DROP_JS_OBJECTS(this, CallbackFunction);
       mCallable = nullptr;
+      nsLayoutStatics::Release();
     }
   }
 
   JSObject* mCallable;
 
   class NS_STACK_CLASS CallSetup
   {
     /**