diff --git a/dom/base/nsGlobalWindow.cpp b/dom/base/nsGlobalWindow.cpp index 4b4cd5034f8e..0510d484485c 100644 --- a/dom/base/nsGlobalWindow.cpp +++ b/dom/base/nsGlobalWindow.cpp @@ -1143,7 +1143,6 @@ nsGlobalWindow::nsGlobalWindow(nsGlobalWindow *aOuterWindow) mObserver = new nsGlobalWindowObserver(this); if (mObserver) { - NS_ADDREF(mObserver); nsCOMPtr os = mozilla::services::GetObserverService(); if (os) { // Watch for online/offline status changes so we can fire events. Use @@ -1163,8 +1162,6 @@ nsGlobalWindow::nsGlobalWindow(nsGlobalWindow *aOuterWindow) // remain frozen until they get an inner window, so freeze this // outer window here. Freeze(); - - mObserver = nullptr; } // We could have failed the first time through trying @@ -1462,7 +1459,6 @@ nsGlobalWindow::CleanUp() // Drop its reference to this dying window, in case for some bogus reason // the object stays around. mObserver->Forget(); - NS_RELEASE(mObserver); } if (mNavigator) { diff --git a/dom/base/nsGlobalWindow.h b/dom/base/nsGlobalWindow.h index 58485263d28f..0597ce35d1b8 100644 --- a/dom/base/nsGlobalWindow.h +++ b/dom/base/nsGlobalWindow.h @@ -1625,7 +1625,7 @@ protected: nsRefPtr mWindowUtils; nsString mStatus; nsString mDefaultStatus; - nsGlobalWindowObserver* mObserver; // Inner windows only. + nsRefPtr mObserver; // Inner windows only. nsRefPtr mCrypto; nsRefPtr mCacheStorage; nsRefPtr mConsole;