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
This commit is contained in:
dougt%netscape.com 2001-04-14 00:34:06 +00:00
parent c9e29953a6
commit 6e8d19ed26
2 changed files with 43 additions and 18 deletions

View File

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

View File

@ -152,30 +152,56 @@ nsProxyEventObject::GetNewOrUsedProxy(nsIEventQueue *destQueue,
nsISupports *aObj,
REFNSIID aIID)
{
nsCOMPtr<nsProxyEventObject> proxy;
nsCOMPtr<nsProxyEventObject> root;
nsProxyEventObject* peo;
if (!aObj)
return nsnull;
nsISupports* rawObject = aObj;
// Get a class for this IID.
nsCOMPtr<nsProxyEventClass> clazz = getter_AddRefs( nsProxyEventClass::GetNewOrUsedClass(aIID) );
if(!clazz) return nsnull;
// make sure that the object pass in is not a proxy.
nsCOMPtr<nsProxyEventObject> 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<nsProxyEventClass> clazz = getter_AddRefs( nsProxyEventClass::GetNewOrUsedClass(aIID) );
if(!clazz)
return nsnull;
nsCOMPtr<nsProxyEventObject> proxy;
nsCOMPtr<nsProxyEventObject> 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<nsISupports> 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<nsISupports> 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<nsISupports> 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,