Fixing bug 421833. Deal better with plugin frames going away while initializing a plugin. r+sr=jonas@sicking.cc

This commit is contained in:
Johnny Stenback 2008-06-27 12:37:21 -07:00
parent a93b574466
commit 8e132b5c6f

View File

@ -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();
}