diff --git a/libs/surfaceflinger_client/SurfaceComposerClient.cpp b/libs/surfaceflinger_client/SurfaceComposerClient.cpp index 3117495d3f41b..85167da17c6c1 100644 --- a/libs/surfaceflinger_client/SurfaceComposerClient.cpp +++ b/libs/surfaceflinger_client/SurfaceComposerClient.cpp @@ -58,7 +58,7 @@ namespace android { // Must not be holding SurfaceComposerClient::mLock when acquiring gLock here. static Mutex gLock; static sp gSurfaceManager; -static DefaultKeyedVector< sp, sp > gActiveConnections; +static DefaultKeyedVector< sp, wp > gActiveConnections; static SortedVector > gOpenTransactions; static sp gServerCblkMemory; static volatile surface_flinger_cblk_t* gServerCblk; @@ -195,7 +195,7 @@ SurfaceComposerClient::clientForConnection(const sp& conn) { // scope for lock Mutex::Autolock _l(gLock); - client = gActiveConnections.valueFor(conn); + client = gActiveConnections.valueFor(conn).promote(); } if (client == 0) { @@ -383,8 +383,8 @@ void SurfaceComposerClient::openGlobalTransaction() const size_t N = gActiveConnections.size(); VERBOSE("openGlobalTransaction (%ld clients)", N); for (size_t i=0; i client(gActiveConnections.valueAt(i)); - if (gOpenTransactions.indexOf(client) < 0) { + sp client(gActiveConnections.valueAt(i).promote()); + if (client != 0 && gOpenTransactions.indexOf(client) < 0) { if (client->openTransaction() == NO_ERROR) { if (gOpenTransactions.add(client) < 0) { // Ooops!