mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-09 19:35:51 +00:00
Bug 884334 - Make sure WidgetShutdownObserver doesn't attempt to use the widget pointer after it has been destroyed. r=roc
This commit is contained in:
parent
9e8bcc1d69
commit
f84e41801b
@ -130,7 +130,8 @@ WidgetShutdownObserver::Observe(nsISupports *aSubject,
|
||||
const char *aTopic,
|
||||
const PRUnichar *aData)
|
||||
{
|
||||
if (strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) == 0) {
|
||||
if (strcmp(aTopic, NS_XPCOM_SHUTDOWN_OBSERVER_ID) == 0 &&
|
||||
mWidget) {
|
||||
mWidget->Shutdown();
|
||||
nsContentUtils::UnregisterShutdownObserver(this);
|
||||
}
|
||||
@ -195,6 +196,11 @@ nsBaseWidget::~nsBaseWidget()
|
||||
}
|
||||
|
||||
if (mShutdownObserver) {
|
||||
// If the shutdown observer is currently processing observers,
|
||||
// then UnregisterShutdownObserver won't stop our Observer
|
||||
// function from being called. Make sure we don't try
|
||||
// to reference the dead widget.
|
||||
mShutdownObserver->mWidget = nullptr;
|
||||
nsContentUtils::UnregisterShutdownObserver(mShutdownObserver);
|
||||
}
|
||||
|
||||
|
@ -51,7 +51,6 @@ public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIOBSERVER
|
||||
|
||||
private:
|
||||
nsBaseWidget *mWidget;
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user