Bug 528025. Hold a strong ref from the view manager to the device context. r=roc/bz
authorOleg Romashin <romaxa@gmail.com>
Wed, 18 Nov 2009 13:38:16 +1300
changeset 34962 daa0cd2375133277ad7a2d825a171dae89b25f58
parent 34961 8456ce23a1ece2718110ef0de4dbb48088fe515b
child 34963 163fd6aa31dfb80d47a2b404c66910d79ca28b25
push idunknown
push userunknown
push dateunknown
reviewersroc, bz
bugs528025
milestone1.9.3a1pre
Bug 528025. Hold a strong ref from the view manager to the device context. r=roc/bz
view/src/nsViewManager.cpp
view/src/nsViewManager.h
--- a/view/src/nsViewManager.cpp
+++ b/view/src/nsViewManager.cpp
@@ -214,17 +214,16 @@ nsViewManager::~nsViewManager()
     // has been destroyed and there is something to cleanup
 
     // Note: A global rendering context is needed because it is not possible 
     // to create a nsIRenderingContext during the shutdown of XPCOM. The last
     // viewmanager is typically destroyed during XPCOM shutdown.
     NS_IF_RELEASE(gCleanupContext);
   }
 
-  NS_IF_RELEASE(mContext);
   mObserver = nsnull;
 }
 
 NS_IMPL_ISUPPORTS1(nsViewManager, nsIViewManager)
 
 nsresult
 nsViewManager::CreateRegion(nsIRegion* *result)
 {
@@ -255,17 +254,16 @@ NS_IMETHODIMP nsViewManager::Init(nsIDev
 
   if (nsnull == aContext) {
     return NS_ERROR_NULL_POINTER;
   }
   if (nsnull != mContext) {
     return NS_ERROR_ALREADY_INITIALIZED;
   }
   mContext = aContext;
-  NS_ADDREF(mContext);
 
   mRefreshEnabled = PR_TRUE;
 
   return NS_OK;
 }
 
 NS_IMETHODIMP_(nsIView *)
 nsViewManager::CreateView(const nsRect& aBounds,
--- a/view/src/nsViewManager.h
+++ b/view/src/nsViewManager.h
@@ -362,17 +362,17 @@ public: // NOT in nsIViewManager, so pri
   PRBool IsRefreshEnabled() { return RootViewManager()->mRefreshEnabled; }
 
   nsIViewObserver* GetViewObserver() { return mObserver; }
 
   // Call this when you need to let the viewmanager know that it now has
   // pending updates.
   void PostPendingUpdate() { RootViewManager()->mHasPendingUpdates = PR_TRUE; }
 private:
-  nsIDeviceContext  *mContext;
+  nsCOMPtr<nsIDeviceContext> mContext;
   nsIViewObserver   *mObserver;
   nsIScrollableView *mRootScrollable;
   nsIntPoint        mMouseLocation; // device units, relative to mRootView
 
   // The size for a resize that we delayed until the root view becomes
   // visible again.
   nsSize            mDelayedResize;