From 6e8d19ed26f316c3bc1c83c94de483dfe748144e Mon Sep 17 00:00:00 2001 From: "dougt%netscape.com" Date: Sat, 14 Apr 2001 00:34:06 +0000 Subject: [PATCH] Attempting to fix 74057, although not likely. See bug for details. If you are asserting after this patch is applied, please contact dougt@netscape.com. r=gagan@netscape.com sr=waterson@netscape.com git-svn-id: svn://10.0.0.236/trunk@92258 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/xpcom/proxy/src/nsProxyEventClass.cpp | 2 +- .../xpcom/proxy/src/nsProxyEventObject.cpp | 59 +++++++++++++------ 2 files changed, 43 insertions(+), 18 deletions(-) diff --git a/mozilla/xpcom/proxy/src/nsProxyEventClass.cpp b/mozilla/xpcom/proxy/src/nsProxyEventClass.cpp index 2336cd614d4..8e5d3b19e17 100644 --- a/mozilla/xpcom/proxy/src/nsProxyEventClass.cpp +++ b/mozilla/xpcom/proxy/src/nsProxyEventClass.cpp @@ -307,7 +307,7 @@ nsProxyEventClass::DelegatedQueryInterface(nsProxyEventObject* self, if(aIID.Equals(NS_GET_IID(ProxyEventClassIdentity))) { - *aInstancePtr = (void**)self; //todo this should be a static cast + *aInstancePtr = NS_STATIC_CAST(void*, self); NS_ADDREF(self); return NS_OK; } diff --git a/mozilla/xpcom/proxy/src/nsProxyEventObject.cpp b/mozilla/xpcom/proxy/src/nsProxyEventObject.cpp index f2f45339122..479d1a1ca3e 100644 --- a/mozilla/xpcom/proxy/src/nsProxyEventObject.cpp +++ b/mozilla/xpcom/proxy/src/nsProxyEventObject.cpp @@ -152,30 +152,56 @@ nsProxyEventObject::GetNewOrUsedProxy(nsIEventQueue *destQueue, nsISupports *aObj, REFNSIID aIID) { - - nsCOMPtr proxy; - nsCOMPtr root; - nsProxyEventObject* peo; + if (!aObj) + return nsnull; + + nsISupports* rawObject = aObj; - // Get a class for this IID. - nsCOMPtr clazz = getter_AddRefs( nsProxyEventClass::GetNewOrUsedClass(aIID) ); - if(!clazz) return nsnull; - // make sure that the object pass in is not a proxy. nsCOMPtr aIdentificationObject; - if (NS_SUCCEEDED(aObj->QueryInterface(kProxyObject_Identity_Class_IID, getter_AddRefs(aIdentificationObject)))) - { + nsresult rv = rawObject->QueryInterface(kProxyObject_Identity_Class_IID, getter_AddRefs(aIdentificationObject)); + + if (NS_SUCCEEDED(rv)) + { + // ATTENTION!!!! + // + // If you are hitting any of the assertions in this block of code, + // please contact dougt@netscape.com. + // + + // if you hit this assertion, you might want to check out how + // you are using proxies. You shouldn't need to be creating + // a proxy from a proxy. -- dougt@netscape.com + NS_ASSERTION(0, "Someone is building a proxy from a proxy"); + + NS_ASSERTION(aIdentificationObject, "where did my identification object go!"); + + if (!aIdentificationObject) + return nsnull; + // someone is asking us to create a proxy for a proxy. Lets get // the real object and build aproxy for that! - aObj = aIdentificationObject->GetRealObject(); - aIdentificationObject = 0; - if (aObj == nsnull) return nsnull; + rawObject = aIdentificationObject->GetRealObject(); + + NS_ASSERTION(rawObject, "where did my real object go!"); + + if (!rawObject) + return nsnull; } + // Get a class for this IID. + nsCOMPtr clazz = getter_AddRefs( nsProxyEventClass::GetNewOrUsedClass(aIID) ); + if(!clazz) + return nsnull; + + nsCOMPtr proxy; + nsCOMPtr root; + nsProxyEventObject* peo; + // always find the native root if the |real| object. // this must not be a nsCOMPtr since we need to make sure that we do a QI. nsCOMPtr rootObject; - if(NS_FAILED(aObj->QueryInterface(NS_GET_IID(nsISupports), getter_AddRefs(rootObject)))) + if(NS_FAILED(rawObject->QueryInterface(NS_GET_IID(nsISupports), getter_AddRefs(rootObject)))) return nsnull; /* get our hash table */ @@ -189,14 +215,13 @@ nsProxyEventObject::GetNewOrUsedProxy(nsIEventQueue *destQueue, // this must not be a nsCOMPtr since we need to make sure that we do a QI. nsCOMPtr requestedInterface; - if(NS_FAILED(aObj->QueryInterface(aIID, getter_AddRefs(requestedInterface)))) + if(NS_FAILED(rawObject->QueryInterface(aIID, getter_AddRefs(requestedInterface)))) return nsnull; // this will be our key in the hash table. // this must not be a nsCOMPtr since we need to make sure that we do a QI. nsCOMPtr destQRoot; - nsresult rv; destQRoot = do_QueryInterface(destQueue, &rv); if (NS_FAILED(rv)) return nsnull; @@ -219,7 +244,7 @@ nsProxyEventObject::GetNewOrUsedProxy(nsIEventQueue *destQueue, else { // build the root proxy - if (aObj == rootObject.get()) + if (rawObject == rootObject.get()) { // the root will do double duty as the interface wrapper peo = new nsProxyEventObject(destQueue,