Bug 672361 - Fix memory management of mIOSurface; r=smichaud
authorBenoit Girard <b56girard@gmail.com>
Tue, 19 Jul 2011 11:14:00 -0400
changeset 73015 4c27fe0139bf4f56a46419df9bed7230d975307f
parent 73014 cedefaaaaceb477bfec52bb2bc272e36aabd7899
child 73016 b8785cf106115dfff02ae16c6e11af53a4520f0b
push id637
push userb56girard@gmail.com
push dateTue, 19 Jul 2011 15:54:49 +0000
treeherdermozilla-inbound@4c27fe0139bf [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmichaud
bugs672361
milestone8.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 672361 - Fix memory management of mIOSurface; r=smichaud
dom/plugins/base/nsPluginInstanceOwner.cpp
--- a/dom/plugins/base/nsPluginInstanceOwner.cpp
+++ b/dom/plugins/base/nsPluginInstanceOwner.cpp
@@ -300,17 +300,16 @@ nsPluginInstanceOwner::nsPluginInstanceO
   mTagText = nsnull;
 #ifdef XP_MACOSX
   memset(&mCGPluginPortCopy, 0, sizeof(NP_CGContext));
 #ifndef NP_NO_QUICKDRAW
   memset(&mQDPluginPortCopy, 0, sizeof(NP_Port));
 #endif
   mInCGPaintLevel = 0;
   mSentInitialTopLevelWindowEvent = PR_FALSE;
-  mIOSurface = nsnull;
   mColorProfile = nsnull;
   mPluginPortChanged = PR_FALSE;
 #endif
   mContentFocused = PR_FALSE;
   mWidgetVisible = PR_TRUE;
   mPluginWindowVisible = PR_FALSE;
   mNumCachedAttrs = 0;
   mNumCachedParams = 0;
@@ -1467,30 +1466,28 @@ void nsPluginInstanceOwner::RenderCoreAn
                                                 int aWidth, int aHeight)
 {
   if (aWidth == 0 || aHeight == 0)
     return;
 
   if (!mIOSurface || 
       (mIOSurface->GetWidth() != (size_t)aWidth || 
        mIOSurface->GetHeight() != (size_t)aHeight)) {
-    delete mIOSurface;
+    mIOSurface = nsnull;
 
     // If the renderer is backed by an IOSurface, resize it as required.
     mIOSurface = nsIOSurface::CreateIOSurface(aWidth, aHeight);
     if (mIOSurface) {
       nsRefPtr<nsIOSurface> attachSurface = nsIOSurface::LookupSurface(
                                               mIOSurface->GetIOSurfaceID());
       if (attachSurface) {
         mCARenderer.AttachIOSurface(attachSurface);
       } else {
         NS_ERROR("IOSurface attachment failed");
-        delete attachSurface;
-        delete mIOSurface;
-        mIOSurface = NULL;
+        mIOSurface = nsnull;
       }
     }
   }
 
   if (!mColorProfile) {
     mColorProfile = CreateSystemColorSpace();
   }
 
@@ -2494,17 +2491,16 @@ nsresult
 nsPluginInstanceOwner::Destroy()
 {
 #ifdef MAC_CARBON_PLUGINS
   // stop the timer explicitly to reduce reference count.
   CancelTimer();
 #endif
 #ifdef XP_MACOSX
   RemoveFromCARefreshTimer(this);
-  delete mIOSurface;
   if (mColorProfile)
     ::CGColorSpaceRelease(mColorProfile);  
 #endif
 
   // unregister context menu listener
   if (mCXMenuListener) {
     mCXMenuListener->Destroy(mContent);
     mCXMenuListener = nsnull;