From c1fd24b30bb775b5071bc3743566e98892878418 Mon Sep 17 00:00:00 2001 From: Kartikaya Gupta Date: Thu, 28 Apr 2016 11:29:35 -0400 Subject: [PATCH] Bug 1268523 - Avoid leaking tasks when they are posted to a destroyed APZC instance. r=botond MozReview-Commit-ID: 9hAkzCVg7el --HG-- extra : rebase_source : 8f9a71ec1354fe57c1401655b81bcb178eb6d1c2 --- gfx/layers/apz/src/AsyncPanZoomController.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/gfx/layers/apz/src/AsyncPanZoomController.cpp b/gfx/layers/apz/src/AsyncPanZoomController.cpp index cef0f6c53767..8c6b03b4f7e8 100644 --- a/gfx/layers/apz/src/AsyncPanZoomController.cpp +++ b/gfx/layers/apz/src/AsyncPanZoomController.cpp @@ -3853,11 +3853,14 @@ AsyncPanZoomController::GetZoomConstraints() const void AsyncPanZoomController::PostDelayedTask(already_AddRefed aTask, int aDelayMs) { APZThreadUtils::AssertOnControllerThread(); + RefPtr task = aTask; RefPtr controller = GetGeckoContentController(); if (controller) { - controller->PostDelayedTask(Move(aTask), aDelayMs); + controller->PostDelayedTask(task.forget(), aDelayMs); } - // XXX khuey what is supposed to happen if there's no controller? We were leaking tasks ... + // If there is no controller, that means this APZC has been destroyed, and + // we probably don't need to run the task. It will get destroyed when the + // RefPtr goes out of scope. } bool AsyncPanZoomController::Matches(const ScrollableLayerGuid& aGuid)