From 8b6b32182d1c4f37e00b2c539f2f81ef2c846e63 Mon Sep 17 00:00:00 2001 From: Robert Carr Date: Tue, 29 Jan 2019 15:27:55 -0800 Subject: SurfaceControl: Allow calling destroy when mOwned is true mOwned was just put in place to prevent the finalizer in SysUI from destroying leashes, it was never meant to prevent explicit calls to destroy. On another note we should probably remove destroy or call it "release" but we can come back to that. Change-Id: I72b0ab467105dc63094994de5482cec651fffaa3 Fixes: 113820778 Test: Builds --- libs/gui/SurfaceControl.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'libs/gui/SurfaceControl.cpp') diff --git a/libs/gui/SurfaceControl.cpp b/libs/gui/SurfaceControl.cpp index 008f520bb0..f06d36aea3 100644 --- a/libs/gui/SurfaceControl.cpp +++ b/libs/gui/SurfaceControl.cpp @@ -63,6 +63,8 @@ SurfaceControl::SurfaceControl(const sp& other) { SurfaceControl::~SurfaceControl() { + // Avoid reparenting the server-side surface to null if we are not the owner of it, + // meaning that we retrieved it from another process. if (mClient != nullptr && mHandle != nullptr && mOwned) { SurfaceComposerClient::doDropReferenceTransaction(mHandle, mClient->getClient()); } @@ -74,9 +76,7 @@ SurfaceControl::~SurfaceControl() void SurfaceControl::destroy() { - // Avoid destroying the server-side surface if we are not the owner of it, meaning that we - // retrieved it from another process. - if (isValid() && mOwned) { + if (isValid()) { SurfaceComposerClient::Transaction().reparent(this, nullptr).apply(); } // clear all references and trigger an IPC now, to make sure things -- cgit v1.2.3-59-g8ed1b