зеркало из https://github.com/mozilla/gecko-dev.git
Make sure everything is still init'd in FinalizeStub
This commit is contained in:
Родитель
cc13964851
Коммит
b73f91d038
|
@ -481,10 +481,19 @@ XPCOMPRIVATE_NATIVE(FinalizeStub) (JNIEnv *env, jclass that,
|
|||
env->ReleaseStringUTFChars(name, javaObjectName);
|
||||
#endif
|
||||
|
||||
void* obj = gBindings->GetXPCOMObject(env, aJavaObject);
|
||||
NS_ASSERTION(!IsXPTCStub(obj),
|
||||
"Expecting JavaXPCOMInstance, got nsJavaXPTCStub");
|
||||
gBindings->RemoveBinding(env, aJavaObject, nsnull);
|
||||
delete (JavaXPCOMInstance*) obj;
|
||||
// Due to Java's garbage collection, this finalize statement may get called
|
||||
// after FreeJavaGlobals(). So check to make sure that everything is still
|
||||
// initialized.
|
||||
if (gJavaXPCOMInitialized) {
|
||||
void* obj = gBindings->GetXPCOMObject(env, aJavaObject);
|
||||
NS_ASSERTION(obj != nsnull, "No matching XPCOM obj in FinalizeStub");
|
||||
|
||||
if (obj) {
|
||||
NS_ASSERTION(!IsXPTCStub(obj),
|
||||
"Expecting JavaXPCOMInstance, got nsJavaXPTCStub");
|
||||
gBindings->RemoveBinding(env, aJavaObject, nsnull);
|
||||
delete (JavaXPCOMInstance*) obj;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -66,6 +66,7 @@ jmethodID getNameMID = nsnull;
|
|||
#endif
|
||||
|
||||
nsJavaXPCOMBindings* gBindings = nsnull;
|
||||
PRBool gJavaXPCOMInitialized = PR_FALSE;
|
||||
|
||||
|
||||
/**************************************
|
||||
|
@ -344,12 +345,10 @@ nsJavaXPCOMBindings::GetJavaObject(JNIEnv* env, void* aXPCOMObject,
|
|||
/******************************
|
||||
* InitializeJavaGlobals
|
||||
******************************/
|
||||
PRBool gInitialized = PR_FALSE;
|
||||
|
||||
PRBool
|
||||
InitializeJavaGlobals(JNIEnv *env)
|
||||
{
|
||||
if (gInitialized)
|
||||
if (gJavaXPCOMInitialized)
|
||||
return PR_TRUE;
|
||||
|
||||
jclass clazz;
|
||||
|
@ -438,7 +437,7 @@ InitializeJavaGlobals(JNIEnv *env)
|
|||
goto init_error;
|
||||
}
|
||||
|
||||
gInitialized = PR_TRUE;
|
||||
gJavaXPCOMInitialized = PR_TRUE;
|
||||
return PR_TRUE;
|
||||
|
||||
init_error:
|
||||
|
@ -472,7 +471,7 @@ FreeJavaGlobals(JNIEnv* env)
|
|||
gBindings = nsnull;
|
||||
}
|
||||
|
||||
gInitialized = PR_FALSE;
|
||||
gJavaXPCOMInitialized = PR_FALSE;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -81,6 +81,7 @@ extern jmethodID getNameMID;
|
|||
class nsJavaXPCOMBindings;
|
||||
extern nsJavaXPCOMBindings* gBindings;
|
||||
|
||||
extern PRBool gJavaXPCOMInitialized;
|
||||
PRBool InitializeJavaGlobals(JNIEnv *env);
|
||||
void FreeJavaGlobals(JNIEnv* env);
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче