Bug 589297 - nsWindow::GetViewWidget crashes when can't find view. r=romaxa a=npodb
authorTatiana Meshkova <tanya.meshkova@gmail.com>
Fri, 20 Aug 2010 18:12:14 -0700
changeset 51211 29ac0213b54cfaee7fdaf4aec9b5230dc8183abb
parent 51210 a7180c21bc26b63adef00df8f827f692869b1c77
child 51212 5fae1fe45a6bc027c5d2fee32d529cac2ae9a742
push id15242
push userromaxa@gmail.com
push dateSun, 22 Aug 2010 06:15:42 +0000
treeherdermozilla-central@29ac0213b54c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersromaxa, npodb
bugs589297
milestone2.0b5pre
first release with
nightly linux32
29ac0213b54c / 4.0b5pre / 20100822030835 / files
nightly linux64
29ac0213b54c / 4.0b5pre / 20100822030712 / files
nightly mac
29ac0213b54c / 4.0b5pre / 20100822030712 / files
nightly win32
29ac0213b54c / 4.0b5pre / 20100822040607 / files
nightly win64
29ac0213b54c / 4.0b5pre / 20100822022921 / files
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
releases
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 589297 - nsWindow::GetViewWidget crashes when can't find view. r=romaxa a=npodb
widget/src/qt/nsWindow.cpp
--- a/widget/src/qt/nsWindow.cpp
+++ b/widget/src/qt/nsWindow.cpp
@@ -669,17 +669,17 @@ nsWindow::Update()
 
 // Returns the graphics view widget for this nsWindow by iterating
 // the chain of parents until a toplevel window with a view/scene is found.
 // (This function always returns something or asserts if the precondition
 // is not met)
 QWidget* nsWindow::GetViewWidget()
 {
     NS_ASSERTION(mWidget, "Calling GetViewWidget without mWidget created");
-    if (!mWidget || !mWidget->scene())
+    if (!mWidget || !mWidget->scene() || !mWidget->scene()->views().size())
         return nsnull;
 
     NS_ASSERTION(mWidget->scene()->views().size() == 1, "Not exactly one view for our scene!");
     return mWidget->scene()->views()[0];
 }
 
 void*
 nsWindow::GetNativeData(PRUint32 aDataType)
@@ -1734,18 +1734,21 @@ void
 nsWindow::NativeResize(PRInt32 aWidth, PRInt32 aHeight, PRBool  aRepaint)
 {
     LOG(("nsWindow::NativeResize [%p] %d %d\n", (void *)this,
          aWidth, aHeight));
 
     mNeedsResize = PR_FALSE;
 
 #ifndef MOZ_ENABLE_MEEGOTOUCH
-    if (mIsTopLevel && XRE_GetProcessType() == GeckoProcessType_Default)
-        GetViewWidget()->resize(aWidth, aHeight);
+    if (mIsTopLevel && XRE_GetProcessType() == GeckoProcessType_Default) {
+        QWidget *widget = GetViewWidget();
+        NS_ENSURE_TRUE(widget,);
+        widget->resize(aWidth, aHeight);
+    }
 #endif
 
     mWidget->resize( aWidth, aHeight);
 
     if (aRepaint)
         mWidget->update();
 }
 
@@ -1757,18 +1760,21 @@ nsWindow::NativeResize(PRInt32 aX, PRInt
     LOG(("nsWindow::NativeResize [%p] %d %d %d %d\n", (void *)this,
          aX, aY, aWidth, aHeight));
 
     mNeedsResize = PR_FALSE;
     mNeedsMove = PR_FALSE;
 
 #ifndef MOZ_ENABLE_MEEGOTOUCH
     if (mIsTopLevel) {
-      if (XRE_GetProcessType() == GeckoProcessType_Default)
-          GetViewWidget()->setGeometry(aX, aY, aWidth, aHeight);
+        if (XRE_GetProcessType() == GeckoProcessType_Default) {
+            QWidget *widget = GetViewWidget();
+            NS_ENSURE_TRUE(widget,);
+            widget->setGeometry(aX, aY, aWidth, aHeight);
+        }
     }
 #endif
 
     mWidget->setGeometry(aX, aY, aWidth, aHeight);
 
     if (aRepaint)
         mWidget->update();
 }