Bug 337675 - improper automatic nsISupportsWeakReference handling for java-based xpcom objects. XULRunner only. r=bsmedberg

git-svn-id: svn://10.0.0.236/trunk@199596 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
pedemont%us.ibm.com
2006-06-09 13:30:24 +00:00
parent 40e75ddca1
commit 5dbfbd0435
5 changed files with 19 additions and 63 deletions

View File

@@ -721,40 +721,23 @@ SetupParams(JNIEnv *env, const jobject aParam, PRUint8 aType, PRBool aIsOut,
iid = aIID;
}
PRBool isXPTCStub;
rv = GetNewOrUsedXPCOMObject(env, java_obj, iid, &xpcom_obj,
&isXPTCStub);
rv = GetNewOrUsedXPCOMObject(env, java_obj, iid, &xpcom_obj);
if (NS_FAILED(rv))
break;
// If the function expects a weak reference, then we need to
// create it here.
if (isWeakRef) {
if (isXPTCStub) {
nsJavaXPTCStub* stub = NS_STATIC_CAST(nsJavaXPTCStub*,
NS_STATIC_CAST(nsXPTCStubBase*,
xpcom_obj));
nsJavaXPTCStubWeakRef* weakref;
weakref = new nsJavaXPTCStubWeakRef(java_obj, stub);
if (!weakref) {
rv = NS_ERROR_OUT_OF_MEMORY;
break;
}
nsCOMPtr<nsISupportsWeakReference> supportsweak =
do_QueryInterface(xpcom_obj);
if (supportsweak) {
nsWeakPtr weakref;
supportsweak->GetWeakReference(getter_AddRefs(weakref));
NS_RELEASE(xpcom_obj);
xpcom_obj = weakref;
NS_ADDREF(xpcom_obj);
} else { // if is native XPCOM object
nsCOMPtr<nsISupportsWeakReference> supportsweak =
do_QueryInterface(xpcom_obj);
if (supportsweak) {
nsWeakPtr weakref;
supportsweak->GetWeakReference(getter_AddRefs(weakref));
NS_RELEASE(xpcom_obj);
xpcom_obj = weakref;
NS_ADDREF(xpcom_obj);
} else {
xpcom_obj = nsnull;
}
} else {
xpcom_obj = nsnull;
}
}
} else {