Bug 678818 - Ensure that the device motion is cancelled at ~nsGlobalWindow. r=jst
authorDoug Turner <dougt@dougt.org>
Thu, 18 Aug 2011 19:27:41 -0700
changeset 76008 1ac35ad29f03b52815b8a9362e3f12764cd7f7c4
parent 76007 2586082fbd94bc68baa1265f45c5a2b6a8279eae
child 76009 c9c694fa048cac880a91474b4ccedaad6bdbca66
push idunknown
push userunknown
push dateunknown
reviewersjst
bugs678818
milestone9.0a1
Bug 678818 - Ensure that the device motion is cancelled at ~nsGlobalWindow. r=jst
dom/base/nsGlobalWindow.cpp
--- a/dom/base/nsGlobalWindow.cpp
+++ b/dom/base/nsGlobalWindow.cpp
@@ -1032,26 +1032,27 @@ nsGlobalWindow::~nsGlobalWindow()
 
   mDocument = nsnull;           // Forces Release
   mDoc = nsnull;
 
   NS_ASSERTION(!mArguments, "mArguments wasn't cleaned up properly!");
 
   CleanUp(PR_TRUE);
 
-  NS_ASSERTION(!mHasDeviceMotion, "Window still registered with device motion.");
-
 #ifdef DEBUG
   nsCycleCollector_DEBUG_wasFreed(static_cast<nsIScriptGlobalObject*>(this));
 #endif
 
   if (mURLProperty) {
     mURLProperty->ClearWindowReference();
   }
 
+  DisableDeviceMotionUpdates();
+  mHasDeviceMotion = PR_FALSE;
+
   nsLayoutStatics::Release();
 }
 
 // static
 void
 nsGlobalWindow::ShutDown()
 {
   NS_IF_RELEASE(sGlobalStorageList);
@@ -1160,19 +1161,16 @@ nsGlobalWindow::CleanUp(PRBool aIgnoreMo
   mParentTarget = nsnull;
 
   nsGlobalWindow *inner = GetCurrentInnerWindowInternal();
 
   if (inner) {
     inner->CleanUp(aIgnoreModalDialog);
   }
 
-  DisableDeviceMotionUpdates();
-  mHasDeviceMotion = PR_FALSE;
-
   if (mCleanMessageManager) {
     NS_ABORT_IF_FALSE(mIsChrome, "only chrome should have msg manager cleaned");
     nsGlobalChromeWindow *asChrome = static_cast<nsGlobalChromeWindow*>(this);
     if (asChrome->mMessageManager) {
       static_cast<nsFrameMessageManager*>(
         asChrome->mMessageManager.get())->Disconnect();
     }
   }