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

This commit is contained in:
av%netscape.com 2001-08-17 00:45:25 +00:00
Родитель 930a195ea0
Коммит 62d0a74217
4 изменённых файлов: 33 добавлений и 38 удалений

Просмотреть файл

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

Просмотреть файл

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

Просмотреть файл

@ -56,7 +56,7 @@ nsPluginInstancePeerImpl::nsPluginInstancePeerImpl()
nsPluginInstancePeerImpl::~nsPluginInstancePeerImpl() nsPluginInstancePeerImpl::~nsPluginInstancePeerImpl()
{ {
mInstance = nsnull; mInstance = nsnull;
mOwner = nsnull; NS_IF_RELEASE(mOwner);
if (nsnull != mMIMEType) if (nsnull != mMIMEType)
{ {
@ -896,11 +896,10 @@ NS_IMETHODIMP nsPluginInstancePeerImpl::GetJSContext(JSContext* *outContext)
nsresult nsPluginInstancePeerImpl::Initialize(nsIPluginInstanceOwner *aOwner, nsresult nsPluginInstancePeerImpl::Initialize(nsIPluginInstanceOwner *aOwner,
const nsMIMEType aMIMEType) const nsMIMEType aMIMEType)
{ {
//don't add a ref to prevent circular references... MMP
mOwner = aOwner; mOwner = aOwner;
NS_IF_ADDREF(mOwner);
aOwner->GetInstance(mInstance); aOwner->GetInstance(mInstance);
//release this one too... MMP
NS_IF_RELEASE(mInstance); NS_IF_RELEASE(mInstance);
if (nsnull != aMIMEType) if (nsnull != aMIMEType)
@ -919,8 +918,12 @@ nsresult nsPluginInstancePeerImpl::Initialize(nsIPluginInstanceOwner *aOwner,
nsresult nsPluginInstancePeerImpl::SetOwner(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; mOwner = aOwner;
NS_IF_ADDREF(mOwner);
aOwner->GetInstance(mInstance); aOwner->GetInstance(mInstance);
NS_IF_RELEASE(mInstance); NS_IF_RELEASE(mInstance);
return NS_OK; return NS_OK;

Просмотреть файл

@ -254,6 +254,19 @@ PluginViewerImpl::~PluginViewerImpl()
if (mOwner) mOwner->CancelTimer(); if (mOwner) mOwner->CancelTimer();
#endif #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); NS_IF_RELEASE(mOwner);
if (nsnull != mWindow) { if (nsnull != mWindow) {
mWindow->Destroy(); mWindow->Destroy();
@ -913,26 +926,7 @@ pluginInstanceOwner :: ~pluginInstanceOwner()
CancelTimer(); CancelTimer();
} }
if (nsnull != mInstance) NS_IF_RELEASE(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);
}
mWindow = nsnull; mWindow = nsnull;
mViewer = nsnull; mViewer = nsnull;