Bug 965920, part 2 - Smart pointerize gSharedScriptableHelperForJSIID. r=bholley

This commit is contained in:
Andrew McCreight 2014-02-04 19:29:58 -08:00
Родитель d7e0183e9e
Коммит b99f98d662
1 изменённых файлов: 5 добавлений и 5 удалений

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

@ -10,6 +10,7 @@
#include "mozilla/dom/BindingUtils.h"
#include "mozilla/Attributes.h"
#include "JavaScriptParent.h"
#include "mozilla/StaticPtr.h"
using namespace mozilla::dom;
using namespace JS;
@ -223,14 +224,13 @@ NS_IMPL_RELEASE(SharedScriptableHelperForJSIID)
nsIXPCScriptable::ALLOW_PROP_MODS_DURING_RESOLVE
#include "xpc_map_end.h" /* This will #undef the above */
static nsIXPCScriptable* gSharedScriptableHelperForJSIID;
static StaticRefPtr<nsIXPCScriptable> gSharedScriptableHelperForJSIID;
static bool gClassObjectsWereInited = false;
static void EnsureClassObjectsInitialized()
{
if (!gClassObjectsWereInited) {
gSharedScriptableHelperForJSIID = new SharedScriptableHelperForJSIID();
NS_ADDREF(gSharedScriptableHelperForJSIID);
gClassObjectsWereInited = true;
}
@ -241,8 +241,8 @@ NS_METHOD GetSharedScriptableHelperForJSIID(uint32_t language,
{
EnsureClassObjectsInitialized();
if (language == nsIProgrammingLanguage::JAVASCRIPT) {
NS_IF_ADDREF(gSharedScriptableHelperForJSIID);
*helper = gSharedScriptableHelperForJSIID;
nsCOMPtr<nsIXPCScriptable> temp = gSharedScriptableHelperForJSIID.get();
temp.forget(helper);
} else
*helper = nullptr;
return NS_OK;
@ -268,7 +268,7 @@ void xpc_DestroyJSxIDClassObjects()
if (gClassObjectsWereInited) {
NS_IF_RELEASE(NS_CLASSINFO_NAME(nsJSIID));
NS_IF_RELEASE(NS_CLASSINFO_NAME(nsJSCID));
NS_IF_RELEASE(gSharedScriptableHelperForJSIID);
gSharedScriptableHelperForJSIID = nullptr;
gClassObjectsWereInited = false;
}