From 0acc379cb9f4ae1e5a031b09faf8cd28a594ccb0 Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Fri, 25 Oct 2013 11:30:17 +0200 Subject: [PATCH] Bug 923482 - Fix an edge case where we might try to re-use a destroyed APZC instance. r=botond --- gfx/layers/composite/APZCTreeManager.cpp | 6 +++++- gfx/layers/ipc/AsyncPanZoomController.cpp | 6 ++++++ gfx/layers/ipc/AsyncPanZoomController.h | 5 +++++ 3 files changed, 16 insertions(+), 1 deletion(-) diff --git a/gfx/layers/composite/APZCTreeManager.cpp b/gfx/layers/composite/APZCTreeManager.cpp index a9a47e0ac00..9cc3277481e 100644 --- a/gfx/layers/composite/APZCTreeManager.cpp +++ b/gfx/layers/composite/APZCTreeManager.cpp @@ -117,7 +117,11 @@ APZCTreeManager::UpdatePanZoomControllerTree(CompositorParent* aCompositor, apzc = container->GetAsyncPanZoomController(); - bool newApzc = (apzc == nullptr); + // The APZC we get off the layer may have been destroyed previously if the layer was inactive + // or omitted from the layer tree for whatever reason from a layers update. If it later comes + // back it will have a reference to a destroyed APZC and so we need to throw that out and make + // a new one. + bool newApzc = (apzc == nullptr || apzc->IsDestroyed()); if (newApzc) { apzc = new AsyncPanZoomController(aLayersId, this, state->mController, AsyncPanZoomController::USE_GESTURE_DETECTOR); diff --git a/gfx/layers/ipc/AsyncPanZoomController.cpp b/gfx/layers/ipc/AsyncPanZoomController.cpp index 67ce0ce4705..a82b0b299a9 100644 --- a/gfx/layers/ipc/AsyncPanZoomController.cpp +++ b/gfx/layers/ipc/AsyncPanZoomController.cpp @@ -326,6 +326,12 @@ AsyncPanZoomController::Destroy() mTreeManager = nullptr; } +bool +AsyncPanZoomController::IsDestroyed() +{ + return mTreeManager == nullptr; +} + /* static */float AsyncPanZoomController::GetTouchStartTolerance() { diff --git a/gfx/layers/ipc/AsyncPanZoomController.h b/gfx/layers/ipc/AsyncPanZoomController.h index 39c1d380a9b..0937147f738 100644 --- a/gfx/layers/ipc/AsyncPanZoomController.h +++ b/gfx/layers/ipc/AsyncPanZoomController.h @@ -203,6 +203,11 @@ public: */ void Destroy(); + /** + * Returns true if Destroy() has already been called on this APZC instance. + */ + bool IsDestroyed(); + /** * Returns the incremental transformation corresponding to the async pan/zoom * in progress. That is, when this transform is multiplied with the layer's