diff --git a/widget/src/windows/TaskbarTabPreview.cpp b/widget/src/windows/TaskbarTabPreview.cpp index 08b3f0b8c90a..f742a002298a 100644 --- a/widget/src/windows/TaskbarTabPreview.cpp +++ b/widget/src/windows/TaskbarTabPreview.cpp @@ -69,6 +69,13 @@ TaskbarTabPreview::~TaskbarTabPreview() { ::DestroyIcon(mIcon); mIcon = NULL; } + + // We need to ensure that proxy window disappears or else Bad Things happen. + if (mProxyWindow) + Disable(); + + NS_ASSERTION(!mProxyWindow, "Taskbar proxy window was not destroyed!"); + if (mWnd) DetachFromNSWindow(); } @@ -271,7 +278,11 @@ TaskbarTabPreview::Enable() { nsresult TaskbarTabPreview::Disable() { - TaskbarPreview::Disable(); + // TaskbarPreview::Disable assumes that mWnd is valid but this method can be + // called when it is null iff the nsWindow has already been destroyed and we + // are still visible for some reason during object destruction. + if (mWnd) + TaskbarPreview::Disable(); if (FAILED(mTaskbar->UnregisterTab(mProxyWindow))) return NS_ERROR_FAILURE;