From cd8c5e29c245e55a5f648b7a10f8586baf64e622 Mon Sep 17 00:00:00 2001 From: Mathias Agopian Date: Fri, 19 Jun 2009 16:24:02 -0700 Subject: release the last reference to surfaces explicitely instead of letting it go implicitely when the message is destroyed --- libs/surfaceflinger/SurfaceFlinger.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/libs/surfaceflinger/SurfaceFlinger.cpp b/libs/surfaceflinger/SurfaceFlinger.cpp index a56ecd886e..90e0bb56cf 100644 --- a/libs/surfaceflinger/SurfaceFlinger.cpp +++ b/libs/surfaceflinger/SurfaceFlinger.cpp @@ -1322,6 +1322,8 @@ status_t SurfaceFlinger::destroySurface(const sp& layer) SurfaceFlinger* flinger, const sp& layer) : flinger(flinger), layer(layer) { } virtual bool handler() { + sp l(layer); + layer.clear(); // clear it outside of the lock; Mutex::Autolock _l(flinger->mStateLock); // remove the layer from the current list -- chances are that it's // not in the list anyway, because it should have been removed @@ -1329,7 +1331,7 @@ status_t SurfaceFlinger::destroySurface(const sp& layer) // However, a buggy client could have not done that. // Since we know we don't have any more clients, we don't need // to use the purgatory. - status_t err = flinger->removeLayer_l(layer); + status_t err = flinger->removeLayer_l(l); if (err == NAME_NOT_FOUND) { // The surface wasn't in the current list, which means it was // removed already, which means it is in the purgatory, @@ -1338,9 +1340,9 @@ status_t SurfaceFlinger::destroySurface(const sp& layer) // must run from there (b/c of OpenGL ES). Additionally, we // can't really acquire our internal lock from // destroySurface() -- see postMessage() below. - ssize_t idx = flinger->mLayerPurgatory.remove(layer); + ssize_t idx = flinger->mLayerPurgatory.remove(l); LOGE_IF(idx < 0, - "layer=%p is not in the purgatory list", layer.get()); + "layer=%p is not in the purgatory list", l.get()); } return true; } -- cgit v1.2.3-59-g8ed1b