Bug 1458999: Nullcheck for release, assert elsewhere. r=enn

This should allow us to figure out what's killing the window mid-flight, in case
there's something to fix in the chrome JS code.

MozReview-Commit-ID: 1xx1AVdspB2
This commit is contained in:
Emilio Cobos Álvarez 2018-05-22 21:37:29 +02:00
parent aa2cf73671
commit b8a33cdbac
2 changed files with 23 additions and 0 deletions

View File

@ -449,6 +449,9 @@ NS_IMETHODIMP nsXULWindow::Create()
NS_IMETHODIMP nsXULWindow::Destroy()
{
MOZ_DIAGNOSTIC_ASSERT(!mSyncingAttributesToWidget,
"Destroying the window from SyncAttributesToWidget?");
if (!mWindow)
return NS_OK;
@ -1549,6 +1552,11 @@ void nsXULWindow::SyncAttributesToWidget()
if (!windowElement)
return;
AutoRestore<bool> scope { mSyncingAttributesToWidget };
mSyncingAttributesToWidget = true;
MOZ_DIAGNOSTIC_ASSERT(mWindow, "No widget on SyncAttributesToWidget?");
nsAutoString attr;
// "hidechrome" attribute
@ -1557,6 +1565,8 @@ void nsXULWindow::SyncAttributesToWidget()
mWindow->HideWindowChrome(true);
}
NS_ENSURE_TRUE_VOID(mWindow);
// "chromemargin" attribute
nsIntMargin margins;
windowElement->GetAttribute(NS_LITERAL_STRING("chromemargin"), attr);
@ -1565,12 +1575,16 @@ void nsXULWindow::SyncAttributesToWidget()
mWindow->SetNonClientMargins(tmp);
}
NS_ENSURE_TRUE_VOID(mWindow);
// "windowtype" attribute
windowElement->GetAttribute(WINDOWTYPE_ATTRIBUTE, attr);
if (!attr.IsEmpty()) {
mWindow->SetWindowClass(attr);
}
NS_ENSURE_TRUE_VOID(mWindow);
// "id" attribute for icon
windowElement->GetAttribute(NS_LITERAL_STRING("id"), attr);
if (attr.IsEmpty()) {
@ -1578,18 +1592,26 @@ void nsXULWindow::SyncAttributesToWidget()
}
mWindow->SetIcon(attr);
NS_ENSURE_TRUE_VOID(mWindow);
// "drawtitle" attribute
windowElement->GetAttribute(NS_LITERAL_STRING("drawtitle"), attr);
mWindow->SetDrawsTitle(attr.LowerCaseEqualsLiteral("true"));
NS_ENSURE_TRUE_VOID(mWindow);
// "toggletoolbar" attribute
windowElement->GetAttribute(NS_LITERAL_STRING("toggletoolbar"), attr);
mWindow->SetShowsToolbarButton(attr.LowerCaseEqualsLiteral("true"));
NS_ENSURE_TRUE_VOID(mWindow);
// "fullscreenbutton" attribute
windowElement->GetAttribute(NS_LITERAL_STRING("fullscreenbutton"), attr);
mWindow->SetShowsFullScreenButton(attr.LowerCaseEqualsLiteral("true"));
NS_ENSURE_TRUE_VOID(mWindow);
// "macanimationtype" attribute
windowElement->GetAttribute(NS_LITERAL_STRING("macanimationtype"), attr);
if (attr.EqualsLiteral("document")) {

View File

@ -180,6 +180,7 @@ protected:
// mDestroying is used to prevent reentry into into Destroy(), which can
// otherwise happen due to script running as we tear down various things.
bool mDestroying;
bool mSyncingAttributesToWidget = false;
bool mRegistered;
uint32_t mPersistentAttributesDirty; // persistentAttributes
uint32_t mPersistentAttributesMask;