Fix for 89672 -- crash on exit with xpcom plugin, r=peterl, sr=waterson, a=marek

git-svn-id: svn://10.0.0.236/branches/MOZILLA_0_9_2_BRANCH@101280 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
av%netscape.com
2001-08-17 07:47:11 +00:00
parent 352048d687
commit f41f82c821
3 changed files with 27 additions and 31 deletions

View File

@@ -510,6 +510,11 @@ nsObjectFrame::Destroy(nsIPresContext* aPresContext)
inst->SetWindow(nsnull);
inst->Stop();
}
nsCOMPtr<nsIPluginHost> pluginHost = do_GetService(kCPluginManagerCID);
if(pluginHost)
pluginHost->StopPluginInstance(inst);
NS_RELEASE(inst);
}
}
@@ -1618,13 +1623,7 @@ nsPluginInstanceOwner::~nsPluginInstanceOwner()
CancelTimer();
}
if (nsnull != mInstance)
{
if (mPluginHost)
mPluginHost->StopPluginInstance(mInstance);
NS_IF_RELEASE(mInstance);
}
NS_IF_RELEASE(mInstance);
NS_IF_RELEASE(mPluginHost);
mOwner = nsnull;

View File

@@ -55,7 +55,7 @@ nsPluginInstancePeerImpl::nsPluginInstancePeerImpl()
nsPluginInstancePeerImpl::~nsPluginInstancePeerImpl()
{
mInstance = nsnull;
mOwner = nsnull;
NS_IF_RELEASE(mOwner);
if (nsnull != mMIMEType)
{
@@ -895,11 +895,10 @@ NS_IMETHODIMP nsPluginInstancePeerImpl::GetJSContext(JSContext* *outContext)
nsresult nsPluginInstancePeerImpl::Initialize(nsIPluginInstanceOwner *aOwner,
const nsMIMEType aMIMEType)
{
//don't add a ref to prevent circular references... MMP
mOwner = aOwner;
NS_IF_ADDREF(mOwner);
aOwner->GetInstance(mInstance);
//release this one too... MMP
NS_IF_RELEASE(mInstance);
if (nsnull != aMIMEType)
@@ -918,8 +917,12 @@ nsresult nsPluginInstancePeerImpl::Initialize(nsIPluginInstanceOwner *aOwner,
nsresult nsPluginInstancePeerImpl::SetOwner(nsIPluginInstanceOwner *aOwner)
{
// do not add refs to these objects to prevent circular references
// get rid of the previous owner
NS_IF_RELEASE(mOwner);
mOwner = aOwner;
NS_IF_ADDREF(mOwner);
aOwner->GetInstance(mInstance);
NS_IF_RELEASE(mInstance);
return NS_OK;

View File

@@ -274,6 +274,19 @@ PluginViewerImpl::~PluginViewerImpl()
if (mOwner) mOwner->CancelTimer();
#endif
if(mOwner) {
nsIPluginInstance * inst;
mOwner->GetInstance(inst);
if(inst) {
nsCOMPtr<nsIPluginHost> host = do_GetService(kCPluginManagerCID);
if(host)
host->StopPluginInstance(inst);
NS_RELEASE(inst);
}
}
NS_IF_RELEASE(mOwner);
if (nsnull != mWindow) {
mWindow->Destroy();
@@ -925,26 +938,7 @@ pluginInstanceOwner :: ~pluginInstanceOwner()
CancelTimer();
}
if (nsnull != mInstance)
{
PRBool doCache = PR_TRUE;
// determine if the plugin wants to be cached
mInstance->GetValue(nsPluginInstanceVariable_DoCacheBool,
(void *) &doCache);
mInstance->Stop();
if (!doCache) {
// if not, destroy the instance
mInstance->Destroy();
}
else {
nsCOMPtr<nsIPluginHost> host;
host = do_GetService(kCPluginManagerCID);
if(host)
host->StopPluginInstance(mInstance);
}
NS_IF_RELEASE(mInstance);
}
NS_IF_RELEASE(mInstance);
mWindow = nsnull;
mViewer = nsnull;