Bug 820814. Call nsIWidget::Destroy from a runnable when destroying the widget for a view. r=mats

nsIWidget::Destroy can re-enter so do it when it is safe.
This commit is contained in:
Timothy Nikkel 2013-05-28 03:11:11 -05:00
parent 052dbe5e55
commit a705d0c6c5

View File

@ -94,6 +94,24 @@ nsView::~nsView()
delete mDirtyRegion;
}
class DestroyWidgetRunnable : public nsRunnable {
public:
NS_DECL_NSIRUNNABLE
explicit DestroyWidgetRunnable(nsIWidget* aWidget) : mWidget(aWidget) {}
private:
nsCOMPtr<nsIWidget> mWidget;
};
NS_IMETHODIMP DestroyWidgetRunnable::Run()
{
mWidget->Destroy();
mWidget = nullptr;
return NS_OK;
}
void nsView::DestroyWidget()
{
if (mWindow)
@ -107,7 +125,11 @@ void nsView::DestroyWidget()
}
else {
mWindow->SetWidgetListener(nullptr);
mWindow->Destroy();
nsCOMPtr<nsIRunnable> widgetDestroyer =
new DestroyWidgetRunnable(mWindow);
NS_DispatchToMainThread(widgetDestroyer);
}
NS_RELEASE(mWindow);