Skip to content

Commit 5b9fb5a

Browse files
Jean-Baptiste QueruAndroid Code Review
authored andcommitted
Merge "Only hold a weak pointer on SurfaceComposerClients"
2 parents a2adf8f + d0964b3 commit 5b9fb5a

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

libs/ui/SurfaceComposerClient.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ namespace android {
5656
// Must not be holding SurfaceComposerClient::mLock when acquiring gLock here.
5757
static Mutex gLock;
5858
static sp<ISurfaceComposer> gSurfaceManager;
59-
static DefaultKeyedVector< sp<IBinder>, sp<SurfaceComposerClient> > gActiveConnections;
59+
static DefaultKeyedVector< sp<IBinder>, wp<SurfaceComposerClient> > gActiveConnections;
6060
static SortedVector<sp<SurfaceComposerClient> > gOpenTransactions;
6161
static sp<IMemoryHeap> gServerCblkMemory;
6262
static volatile surface_flinger_cblk_t* gServerCblk;
@@ -193,7 +193,7 @@ SurfaceComposerClient::clientForConnection(const sp<IBinder>& conn)
193193

194194
{ // scope for lock
195195
Mutex::Autolock _l(gLock);
196-
client = gActiveConnections.valueFor(conn);
196+
client = gActiveConnections.valueFor(conn).promote();
197197
}
198198

199199
if (client == 0) {
@@ -361,8 +361,8 @@ void SurfaceComposerClient::openGlobalTransaction()
361361
const size_t N = gActiveConnections.size();
362362
VERBOSE("openGlobalTransaction (%ld clients)", N);
363363
for (size_t i=0; i<N; i++) {
364-
sp<SurfaceComposerClient> client(gActiveConnections.valueAt(i));
365-
if (gOpenTransactions.indexOf(client) < 0) {
364+
sp<SurfaceComposerClient> client(gActiveConnections.valueAt(i).promote());
365+
if (client != 0 && gOpenTransactions.indexOf(client) < 0) {
366366
if (client->openTransaction() == NO_ERROR) {
367367
if (gOpenTransactions.add(client) < 0) {
368368
// Ooops!

0 commit comments

Comments
 (0)