diff --git a/modules/plugin/base/src/nsNPAPIPluginInstance.cpp b/modules/plugin/base/src/nsNPAPIPluginInstance.cpp index ab20a9ddbf6..0222b1f1c26 100644 --- a/modules/plugin/base/src/nsNPAPIPluginInstance.cpp +++ b/modules/plugin/base/src/nsNPAPIPluginInstance.cpp @@ -841,6 +841,8 @@ NS_IMETHODIMP nsNPAPIPluginInstance::Stop(void) } if (!mStarted) { + // Break our cycle with the peer that owns us. + mPeer = nsnull; return NS_OK; } @@ -859,6 +861,8 @@ NS_IMETHODIMP nsNPAPIPluginInstance::Stop(void) OnPluginDestroy(&fNPP); if (fCallbacks->destroy == NULL) { + // Break our cycle with the peer that owns us. + mPeer = nsnull; return NS_ERROR_FAILURE; } @@ -886,6 +890,9 @@ NS_IMETHODIMP nsNPAPIPluginInstance::Stop(void) nsJSNPRuntime::OnPluginDestroy(&fNPP); + // Break our cycle with the peer that owns us. + mPeer = nsnull; + if (error != NPERR_NO_ERROR) return NS_ERROR_FAILURE; else diff --git a/modules/plugin/base/src/nsPluginHostImpl.cpp b/modules/plugin/base/src/nsPluginHostImpl.cpp index bf8ac9b377a..8857b626fc3 100644 --- a/modules/plugin/base/src/nsPluginHostImpl.cpp +++ b/modules/plugin/base/src/nsPluginHostImpl.cpp @@ -5909,16 +5909,6 @@ nsPluginHostImpl::StopPluginInstance(nsIPluginInstance* aInstance) } } } - - nsCOMPtr peer; - aInstance->GetPeer(getter_AddRefs(peer)); - - if (peer) { - // Break the reference cycle between the instance, peer, and - // owner. - ((nsPluginInstancePeerImpl*)peer.get())->SetOwner(nsnull); - } - return NS_OK; }