Be more careful when detaching an old window. b=374102 r+sr=roc
authormats.palmgren@bredband.net
Sun, 13 May 2007 17:43:13 -0700
changeset 1413 80fca7d92d1aaa5265fc6118202a386c53d9967c
parent 1412 6481d2a4dbfec4e1816895ca0066f3aa1f15557b
child 1414 2b72a74567b41b157ee72a50495cd49f87aa52a0
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
bugs374102
milestone1.9a5pre
Be more careful when detaching an old window. b=374102 r+sr=roc
view/src/nsView.cpp
--- a/view/src/nsView.cpp
+++ b/view/src/nsView.cpp
@@ -604,18 +604,23 @@ nsresult nsIView::CreateWidget(const nsI
                                nsNativeWidget aNative,
                                PRBool aEnableDragDrop,
                                PRBool aResetVisibility,
                                nsContentType aContentType)
 {
   nsIDeviceContext  *dx;
   nsRect            trect = mDimBounds;
 
-  NS_ASSERTION(!mWindow, "We already have a window for this view? BAD");
-  NS_IF_RELEASE(mWindow);
+  if (NS_UNLIKELY(mWindow)) {
+    NS_ERROR("We already have a window for this view? BAD");
+    ViewWrapper* wrapper = GetWrapperFor(mWindow);
+    NS_IF_RELEASE(wrapper);
+    mWindow->SetClientData(nsnull);
+    NS_RELEASE(mWindow);
+  }
 
   mViewManager->GetDeviceContext(dx);
   float scale = 1.0f / dx->AppUnitsPerDevPixel();
 
   trect *= scale;
 
   nsView* v = NS_STATIC_CAST(nsView*, this);
   if (NS_OK == v->LoadWidget(aWindowIID))