Fix for bug 26420. r=scc@netscape.com
git-svn-id: svn://10.0.0.236/trunk@59805 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -43,6 +43,12 @@ static uint32 zero_methods_descriptor;
|
||||
|
||||
static NS_DEFINE_IID(kProxyEventClassIID, NS_PROXYEVENT_CLASS_IID);
|
||||
|
||||
/* ssc@netscape.com wishes he could get rid of this instance of
|
||||
* |NS_DEFINE_IID|, but |ProxyEventClassIdentity| is not visible from
|
||||
* here.
|
||||
*/
|
||||
static NS_DEFINE_IID(kProxyObject_Identity_Class_IID, NS_PROXYEVENT_IDENTITY_CLASS_IID);
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
// nsProxyEventClass
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
@@ -205,9 +211,11 @@ nsProxyEventClass::~nsProxyEventClass()
|
||||
nsresult
|
||||
nsProxyEventClass::CallQueryInterfaceOnProxy(nsProxyEventObject* self, REFNSIID aIID, nsProxyEventObject** aInstancePtr)
|
||||
{
|
||||
nsresult rv;
|
||||
NS_PRECONDITION(aInstancePtr, "Requires non-null result");
|
||||
|
||||
*aInstancePtr = (nsProxyEventObject*)0xDEADBEEF; // in case of error.
|
||||
nsresult rv;
|
||||
|
||||
*aInstancePtr = nsnull; // in case of error.
|
||||
|
||||
|
||||
// The functions we will call: QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
@@ -217,20 +225,43 @@ nsProxyEventClass::CallQueryInterfaceOnProxy(nsProxyEventObject* self, REFNSIID
|
||||
var[0].val.p = (void*)&aIID;
|
||||
var[1].val.p = (void*)aInstancePtr;
|
||||
|
||||
nsCOMPtr<nsIInterfaceInfoManager> iim = getter_AddRefs(XPTI_GetInterfaceInfoManager());
|
||||
|
||||
|
||||
if (iim == nsnull)
|
||||
return NS_NOINTERFACE;
|
||||
|
||||
nsIInterfaceInfo *nsISupportsInfo;
|
||||
nsIInterfaceInfo *interfaceInfo;
|
||||
const nsXPTMethodInfo *mi;
|
||||
|
||||
iim->GetInfoForName("nsISupports", &nsISupportsInfo);
|
||||
nsISupportsInfo->GetMethodInfo(0, &mi); // 0 is QueryInterface
|
||||
nsCOMPtr<nsIInterfaceInfoManager> iim = getter_AddRefs(XPTI_GetInterfaceInfoManager());
|
||||
|
||||
if (!iim) return NS_NOINTERFACE;
|
||||
iim->GetInfoForName("nsISupports", &interfaceInfo);
|
||||
interfaceInfo->GetMethodInfo(0, &mi); // 0 is QueryInterface
|
||||
|
||||
rv = self->CallMethod(0, mi, var);
|
||||
|
||||
if (NS_SUCCEEDED(rv))
|
||||
{
|
||||
nsISupports *aIdentificationObject;
|
||||
|
||||
rv = (*aInstancePtr)->QueryInterface(kProxyObject_Identity_Class_IID, (void**)&aIdentificationObject);
|
||||
|
||||
if (NS_FAILED(rv))
|
||||
{
|
||||
// okay, aInstancePtr was not a proxy. Lets create one.
|
||||
nsProxyObjectManager *manager = nsProxyObjectManager::GetInstance();
|
||||
if (manager == nsnull)
|
||||
{
|
||||
NS_IF_RELEASE((*aInstancePtr));
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
rv = manager->GetProxyObject(self->GetQueue(),
|
||||
aIID,
|
||||
self->GetRealObject(),
|
||||
self->GetProxyType(),
|
||||
(void**)&aIdentificationObject);
|
||||
}
|
||||
|
||||
NS_IF_RELEASE((*aInstancePtr));
|
||||
(*aInstancePtr) = NS_STATIC_CAST(nsProxyEventObject*, aIdentificationObject);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
|
||||
@@ -118,8 +118,8 @@ nsProxyEventObject::GetNewOrUsedProxy(nsIEventQueue *destQueue,
|
||||
REFNSIID aIID)
|
||||
{
|
||||
|
||||
nsCOMPtr<nsProxyEventObject> proxy = 0;
|
||||
nsCOMPtr<nsProxyEventObject> root = 0;
|
||||
nsCOMPtr<nsProxyEventObject> proxy;
|
||||
nsCOMPtr<nsProxyEventObject> root;
|
||||
nsProxyEventObject* peo;
|
||||
|
||||
// Get a class for this IID.
|
||||
@@ -137,11 +137,12 @@ nsProxyEventObject::GetNewOrUsedProxy(nsIEventQueue *destQueue,
|
||||
if (aObj == nsnull) return nsnull;
|
||||
}
|
||||
|
||||
// always find the native root if the |real| object.
|
||||
// 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))))
|
||||
return nsnull;
|
||||
|
||||
if(NS_FAILED(aObj->QueryInterface(NS_GET_IID(nsISupports), getter_AddRefs(rootObject))))
|
||||
return nsnull;
|
||||
|
||||
/* get our hash table */
|
||||
nsProxyObjectManager *manager = nsProxyObjectManager::GetInstance();
|
||||
if (manager == nsnull) return nsnull;
|
||||
@@ -150,17 +151,20 @@ nsProxyEventObject::GetNewOrUsedProxy(nsIEventQueue *destQueue,
|
||||
if (realToProxyMap == nsnull) return nsnull;
|
||||
|
||||
// we need to do make sure that we addref the passed in object as well as ensure
|
||||
// that it is of the requested IID;
|
||||
// that it is of the requested IID;
|
||||
// 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))))
|
||||
return nsnull;
|
||||
if(NS_FAILED(aObj->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;
|
||||
if(NS_FAILED(destQueue->QueryInterface(NS_GET_IID(nsISupports), (void**)&destQueue)))
|
||||
return nsnull;
|
||||
if(NS_FAILED(destQueue->QueryInterface(NS_GET_IID(nsISupports), (void**)&destQueue)))
|
||||
return nsnull;
|
||||
|
||||
|
||||
char* rootKeyString = PR_sprintf_append(nsnull, "%p.%p.%d", (PRUint32)rootObject.get(), (PRUint32)destQRoot.get(), proxyType);
|
||||
nsStringKey rootkey(rootKeyString);
|
||||
@@ -351,13 +355,18 @@ nsProxyEventObject::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
nsProxyEventObject*
|
||||
nsProxyEventObject::Find(REFNSIID aIID)
|
||||
{
|
||||
nsProxyEventObject* cur = (mRoot ? mRoot : this);
|
||||
if(aIID.Equals(GetClass()->GetProxiedIID()))
|
||||
{
|
||||
return this;
|
||||
}
|
||||
|
||||
if(aIID.Equals(NS_GET_IID(nsISupports)))
|
||||
{
|
||||
return cur;
|
||||
return this;
|
||||
}
|
||||
|
||||
nsProxyEventObject* cur = (mRoot ? mRoot : this);
|
||||
|
||||
do
|
||||
{
|
||||
if(aIID.Equals(GetClass()->GetProxiedIID()))
|
||||
|
||||
Reference in New Issue
Block a user