removing an extra release (16832)

Now doing a QI when getting a proxy so that the IID matches the |in| real
object.

r=jud
This commit is contained in:
dougt%netscape.com 1999-10-20 20:04:20 +00:00
parent 56f9652bab
commit eed901ef67
2 changed files with 36 additions and 10 deletions

View File

@ -73,6 +73,11 @@ nsProxyObjectCallInfo::SetCompleted()
}
#ifdef debug_DOUGT
static PRUint32 totalProxyObjects = 0;
static PRUint32 outstandingProxyObjects = 0;
#endif
NS_IMPL_ISUPPORTS0(nsProxyObject)
nsProxyObject::nsProxyObject()
@ -81,6 +86,11 @@ nsProxyObject::nsProxyObject()
}
nsProxyObject::nsProxyObject(nsIEventQueue *destQueue, PRInt32 proxyType, nsISupports *realObject)
{
#ifdef debug_DOUGT
totalProxyObjects++;
outstandingProxyObjects++;
#endif
NS_INIT_REFCNT();
NS_ADDREF_THIS();
@ -92,6 +102,11 @@ nsProxyObject::nsProxyObject(nsIEventQueue *destQueue, PRInt32 proxyType, nsISup
nsProxyObject::nsProxyObject(nsIEventQueue *destQueue, PRInt32 proxyType, const nsCID &aClass, nsISupports *aDelegate, const nsIID &aIID)
{
#ifdef debug_DOUGT
totalProxyObjects++;
outstandingProxyObjects++;
#endif
NS_INIT_REFCNT();
NS_ADDREF_THIS();
@ -106,8 +121,10 @@ nsProxyObject::nsProxyObject(nsIEventQueue *destQueue, PRInt32 proxyType, const
nsProxyObject::~nsProxyObject()
{
if(mRealObject)
NS_RELEASE(mRealObject);
#ifdef debug_DOUGT
outstandingProxyObjects--;
printf("[proxyobjects] %d total used in system, %d outstading\n", totalProxyObjects, outstandingProxyObjects);
#endif
}

View File

@ -137,6 +137,8 @@ nsProxyObjectManager::Create(nsISupports* outer, const nsIID& aIID, void* *aInst
NS_IMETHODIMP
nsProxyObjectManager::GetProxyObject(nsIEventQueue *destQueue, REFNSIID aIID, nsISupports* aObj, PRInt32 proxyType, void** aProxyObject)
{
nsresult rv;
nsCOMPtr<nsIEventQueue> postQ(do_QueryInterface(destQueue));
*aProxyObject = nsnull;
@ -144,7 +146,6 @@ nsProxyObjectManager::GetProxyObject(nsIEventQueue *destQueue, REFNSIID aIID, ns
// post to primordial thread event queue if no queue specified
if (postQ == nsnull)
{
nsresult rv;
nsCOMPtr<nsIThread> mainIThread;
PRThread *mainThread;
@ -180,18 +181,26 @@ nsProxyObjectManager::GetProxyObject(nsIEventQueue *destQueue, REFNSIID aIID, ns
}
}
NS_ADDREF(aObj);
nsISupports *realObject;
// we need to do make sure that we addref the passed in object as well as ensure
// that it is of the requested IID;
rv = aObj->QueryInterface(aIID, (void**)&realObject);
if ( NS_FAILED( rv ) )
return rv;
// check to see if proxy is there or not.
*aProxyObject = nsProxyEventObject::GetNewOrUsedProxy(postQ, proxyType, aObj, aIID);
if (*aProxyObject != nsnull)
*aProxyObject = nsProxyEventObject::GetNewOrUsedProxy(postQ, proxyType, realObject, aIID);
if (*aProxyObject == nsnull)
{
return NS_OK;
NS_RELEASE(aObj);
return NS_ERROR_NO_INTERFACE; //fix error code?
}
NS_RELEASE(aObj);
return NS_ERROR_NO_INTERFACE; //fix error code?
return NS_OK;
}