Clean up pointer usage
authorAli Juma <ajuma@mozilla.com>
Wed, 21 Dec 2011 11:10:33 -0500
changeset 92339 0d11124ed86e1d75d9404a94588cc524ddd21aa8
parent 92338 b8c022acb96ee8f2ced32e8d4646e06ba5fef6e6
child 92340 9a06644c9e86779eef3f211aa92f508c235c17bf
push id886
push userlsblakk@mozilla.com
push dateMon, 04 Jun 2012 19:57:52 +0000
treeherdermozilla-beta@bbd8d5efd6d1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone11.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
Clean up pointer usage
gfx/layers/ipc/ShadowLayersParent.cpp
widget/src/xpwidgets/nsBaseWidget.cpp
--- a/gfx/layers/ipc/ShadowLayersParent.cpp
+++ b/gfx/layers/ipc/ShadowLayersParent.cpp
@@ -139,16 +139,17 @@ void
 ShadowLayersParent::Destroy()
 {
   mDestroyed = true;
   for (size_t i = 0; i < ManagedPLayerParent().Length(); ++i) {
     ShadowLayerParent* slp =
       static_cast<ShadowLayerParent*>(ManagedPLayerParent()[i]);
     slp->Destroy();
   }
+  mHost = NULL;
 }
 
 bool
 ShadowLayersParent::RecvUpdate(const InfallibleTArray<Edit>& cset,
                                InfallibleTArray<EditReply>* reply)
 {
   MOZ_LAYERS_LOG(("[ParentSide] received txn with %d edits", cset.Length()));
 
@@ -413,17 +414,21 @@ ShadowLayersParent::DeallocPLayer(PLayer
 {
   delete actor;
   return true;
 }
 
 RenderFrameParent*
 ShadowLayersParent::Frame()
 {
-  return mHost->GetRenderFrameParent();
+  if (mDestroyed) {
+    return NULL;
+  } else {
+    return mHost->GetRenderFrameParent();
+  }
 }
 
 void
 ShadowLayersParent::DestroySharedSurface(gfxSharedImageSurface* aSurface)
 {
   layer_manager()->DestroySharedSurface(aSurface, this);
 }
 
--- a/widget/src/xpwidgets/nsBaseWidget.cpp
+++ b/widget/src/xpwidgets/nsBaseWidget.cpp
@@ -140,20 +140,20 @@ nsBaseWidget::~nsBaseWidget()
   if (mLayerManager &&
       mLayerManager->GetBackendType() == LayerManager::LAYERS_BASIC) {
     static_cast<BasicLayerManager*>(mLayerManager.get())->ClearRetainerWidget();
   }
 
 
   if (mLayerManager) {
     mLayerManager->Destroy();
-    mLayerManager = NULL;
   }
 
   if (mCompositor) {
+    mLayerManager = NULL;
     mCompositor->Destroy();
   }
 
 #ifdef NOISY_WIDGET_LEAKS
   gNumWidgets--;
   printf("WIDGETS- = %d\n", gNumWidgets);
 #endif