diff --git a/mozilla/layout/generic/nsObjectFrame.cpp b/mozilla/layout/generic/nsObjectFrame.cpp index 6452d1a4861..6189e3e014b 100644 --- a/mozilla/layout/generic/nsObjectFrame.cpp +++ b/mozilla/layout/generic/nsObjectFrame.cpp @@ -864,6 +864,8 @@ nsObjectFrame::InstantiatePlugin(nsIPluginHost* aPluginHost, mInstanceOwner); } + // Note that |this| may very well be destroyed already! + if (appShell) { appShell->ResumeNative(); } @@ -1589,7 +1591,8 @@ nsObjectFrame::HandleEvent(nsPresContext* aPresContext, return rv; } -nsresult nsObjectFrame::GetPluginInstance(nsIPluginInstance*& aPluginInstance) +nsresult +nsObjectFrame::GetPluginInstance(nsIPluginInstance*& aPluginInstance) { aPluginInstance = nsnull; @@ -1646,9 +1649,16 @@ nsObjectFrame::Instantiate(nsIChannel* aChannel, nsIStreamListener** aStreamList // This must be done before instantiating the plugin FixupWindow(mRect.Size()); + nsWeakFrame weakFrame(this); + NS_ASSERTION(!mPreventInstantiation, "Say what?"); mPreventInstantiation = PR_TRUE; rv = pluginHost->InstantiatePluginForChannel(aChannel, mInstanceOwner, aStreamListener); + + if (!weakFrame.IsAlive()) { + return NS_ERROR_NOT_AVAILABLE; + } + NS_ASSERTION(mPreventInstantiation, "Instantiation should still be prevented!"); mPreventInstantiation = PR_FALSE; @@ -1674,6 +1684,8 @@ nsObjectFrame::Instantiate(const char* aMimeType, nsIURI* aURI) nsresult rv = PrepareInstanceOwner(); NS_ENSURE_SUCCESS(rv, rv); + nsWeakFrame weakFrame(this); + // This must be done before instantiating the plugin FixupWindow(mRect.Size()); @@ -1687,9 +1699,18 @@ nsObjectFrame::Instantiate(const char* aMimeType, nsIURI* aURI) rv = InstantiatePlugin(pluginHost, aMimeType, aURI); + if (!weakFrame.IsAlive()) { + return NS_ERROR_NOT_AVAILABLE; + } + // finish up if (NS_SUCCEEDED(rv)) { TryNotifyContentObjectWrapper(); + + if (!weakFrame.IsAlive()) { + return NS_ERROR_NOT_AVAILABLE; + } + CallSetWindow(); }