Lookup the view again since WillPaint() might lead to its destruction. b=378273 r+sr=roc
authormats.palmgren@bredband.net
Sun, 29 Apr 2007 17:46:27 -0700
changeset 919 1974f4b270d6d1c5b5b00a5590fe545fb87bb21a
parent 918 e0037c1de786983844e3b2a654a4f0d523d0ea01
child 920 068b74e144cd90c950e5d789c0d59c5f03cdabb2
push idunknown
push userunknown
push dateunknown
bugs378273
milestone1.9a5pre
Lookup the view again since WillPaint() might lead to its destruction. b=378273 r+sr=roc
view/src/nsViewManager.cpp
--- a/view/src/nsViewManager.cpp
+++ b/view/src/nsViewManager.cpp
@@ -1210,25 +1210,32 @@ NS_IMETHODIMP nsViewManager::DispatchEve
                 // observer may try to reenter this code from inside
                 // WillPaint() by trying to do a synchronous paint, but since
                 // refresh will be disabled it won't be able to do the paint.
                 // We should really sort out the rules on our synch painting
                 // api....
                 BeginUpdateViewBatch();
                 observer->WillPaint();
                 EndUpdateViewBatch(NS_VMREFRESH_NO_SYNC);
+
+                // Get the view pointer again since the code above might have
+                // destroyed it (bug 378273).
+                view = nsView::GetViewFor(aEvent->widget);
               }
             }
             // Make sure to sync up any widget geometry changes we
             // have pending before we paint.
             if (rootVM->mHasPendingUpdates) {
               rootVM->ProcessPendingUpdates(mRootView, PR_FALSE);
             }
-            Refresh(view, event->renderingContext, region,
-                    NS_VMREFRESH_DOUBLE_BUFFER);
+            
+            if (view) {
+              Refresh(view, event->renderingContext, region,
+                      NS_VMREFRESH_DOUBLE_BUFFER);
+            }
           }
         } else {
           // since we got an NS_PAINT event, we need to
           // draw something so we don't get blank areas.
           nsRect damRect;
           region->GetBoundingBox(&damRect.x, &damRect.y, &damRect.width, &damRect.height);
           PRInt32 p2a = mContext->AppUnitsPerDevPixel();
           damRect.ScaleRoundOut(float(p2a));