From 8e132b5c6f56bf33538986c88c9b54179f0ea592 Mon Sep 17 00:00:00 2001 From: Johnny Stenback Date: Fri, 27 Jun 2008 12:37:21 -0700 Subject: [PATCH] Fixing bug 421833. Deal better with plugin frames going away while initializing a plugin. r+sr=jonas@sicking.cc --- layout/generic/nsObjectFrame.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/layout/generic/nsObjectFrame.cpp b/layout/generic/nsObjectFrame.cpp index d70e2df879b0..4bf2a67f550f 100644 --- a/layout/generic/nsObjectFrame.cpp +++ b/layout/generic/nsObjectFrame.cpp @@ -860,6 +860,8 @@ nsObjectFrame::InstantiatePlugin(nsIPluginHost* aPluginHost, mInstanceOwner); } + // Note that |this| may very well be destroyed already! + if (appShell) { appShell->ResumeNative(); } @@ -1598,7 +1600,8 @@ nsObjectFrame::HandleEvent(nsPresContext* aPresContext, return rv; } -nsresult nsObjectFrame::GetPluginInstance(nsIPluginInstance*& aPluginInstance) +nsresult +nsObjectFrame::GetPluginInstance(nsIPluginInstance*& aPluginInstance) { aPluginInstance = nsnull; @@ -1655,9 +1658,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; @@ -1683,6 +1693,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()); @@ -1696,9 +1708,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(); }