@@ -56,7 +56,7 @@ namespace android {
5656// Must not be holding SurfaceComposerClient::mLock when acquiring gLock here.
5757static Mutex gLock ;
5858static sp<ISurfaceComposer> gSurfaceManager ;
59- static DefaultKeyedVector< sp<IBinder>, sp <SurfaceComposerClient> > gActiveConnections ;
59+ static DefaultKeyedVector< sp<IBinder>, wp <SurfaceComposerClient> > gActiveConnections ;
6060static SortedVector<sp<SurfaceComposerClient> > gOpenTransactions ;
6161static sp<IMemoryHeap> gServerCblkMemory ;
6262static 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