Bug 810618. Make sure we don't allow layout statics to go away while we're still trying to use them. r=khuey

This commit is contained in:
Boris Zbarsky 2012-11-13 00:26:55 -08:00
Родитель 2f3202994d
Коммит 45edccd252
1 изменённых файлов: 4 добавлений и 0 удалений

Просмотреть файл

@ -27,6 +27,7 @@
#include "nsWrapperCache.h" #include "nsWrapperCache.h"
#include "nsJSEnvironment.h" #include "nsJSEnvironment.h"
#include "xpcpublic.h" #include "xpcpublic.h"
#include "nsLayoutStatics.h"
namespace mozilla { namespace mozilla {
namespace dom { namespace dom {
@ -63,6 +64,8 @@ public:
// Set mCallable before we hold, on the off chance that a GC could somehow // Set mCallable before we hold, on the off chance that a GC could somehow
// happen in there... (which would be pretty odd, granted). // happen in there... (which would be pretty odd, granted).
mCallable = aCallable; mCallable = aCallable;
// Make sure we'll be able to drop as needed
nsLayoutStatics::AddRef();
NS_HOLD_JS_OBJECTS(this, CallbackFunction); NS_HOLD_JS_OBJECTS(this, CallbackFunction);
*aInited = true; *aInited = true;
} }
@ -90,6 +93,7 @@ protected:
if (mCallable) { if (mCallable) {
NS_DROP_JS_OBJECTS(this, CallbackFunction); NS_DROP_JS_OBJECTS(this, CallbackFunction);
mCallable = nullptr; mCallable = nullptr;
nsLayoutStatics::Release();
} }
} }