Make sure everything is still init'd in FinalizeStub

Original committer: pedemont%us.ibm.com
Original revision: 1.22
Original date: 2005/01/21 22:21:47
This commit is contained in:
pedemont%us.ibm.com 2006-09-27 15:17:53 +00:00
Родитель aba8e4805b
Коммит 41f98793c7
1 изменённых файлов: 14 добавлений и 5 удалений

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

@ -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;
}
}
}