From 39eeb173fce3e69381202b96748c0305e59c0bb7 Mon Sep 17 00:00:00 2001 From: "danm%netscape.com" Date: Thu, 16 Sep 1999 23:35:05 +0000 Subject: [PATCH] stop webshell embed if the the window in which to embed has been destroyed. fixes bug 14020 git-svn-id: svn://10.0.0.236/trunk@47865 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/docshell/base/nsWebShell.cpp | 9 ++++++++- mozilla/webshell/src/nsWebShell.cpp | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/mozilla/docshell/base/nsWebShell.cpp b/mozilla/docshell/base/nsWebShell.cpp index f49b40f7914..d2cff547989 100644 --- a/mozilla/docshell/base/nsWebShell.cpp +++ b/mozilla/docshell/base/nsWebShell.cpp @@ -857,7 +857,14 @@ nsWebShell::Embed(nsIContentViewer* aContentViewer, NS_ADDREF(aContentViewer); // check to see if we have a window to embed into --dwc0001 - if(mWindow) { + /* Note we also need to check for the presence of a native widget. If the + webshell is hidden before it's embedded, which can happen in an onload + handler, the native widget is destroyed before this code is run. This + appears to be mostly harmless except on Windows, where the subsequent + attempt to create a child window without a parent is met with disdain + by the OS. It's handy, then, that GetNativeData on Windows returns + null in this case. */ + if(mWindow && mWindow->GetNativeData(NS_NATIVE_WIDGET)) { mWindow->GetClientBounds(bounds); bounds.x = bounds.y = 0; rv = mContentViewer->Init(mWindow->GetNativeData(NS_NATIVE_WIDGET), diff --git a/mozilla/webshell/src/nsWebShell.cpp b/mozilla/webshell/src/nsWebShell.cpp index f49b40f7914..d2cff547989 100644 --- a/mozilla/webshell/src/nsWebShell.cpp +++ b/mozilla/webshell/src/nsWebShell.cpp @@ -857,7 +857,14 @@ nsWebShell::Embed(nsIContentViewer* aContentViewer, NS_ADDREF(aContentViewer); // check to see if we have a window to embed into --dwc0001 - if(mWindow) { + /* Note we also need to check for the presence of a native widget. If the + webshell is hidden before it's embedded, which can happen in an onload + handler, the native widget is destroyed before this code is run. This + appears to be mostly harmless except on Windows, where the subsequent + attempt to create a child window without a parent is met with disdain + by the OS. It's handy, then, that GetNativeData on Windows returns + null in this case. */ + if(mWindow && mWindow->GetNativeData(NS_NATIVE_WIDGET)) { mWindow->GetClientBounds(bounds); bounds.x = bounds.y = 0; rv = mContentViewer->Init(mWindow->GetNativeData(NS_NATIVE_WIDGET),