Similar to previous commit drop the unneeded NULL check (left over from commit c42522c76a94e82907b218c7670c89a8f92f952c (Android: Fix surface setup segfault) and teardown things in the inverse order of creating them (by using droid_destroy_surface).
Add a comment about the seemingly strange clear() in droid_destroy_surface(), and don't forget to teardown the actual surface object. XXX: the comment does not cover the question if we should still delete the object. Cc: Juha-Pekka Heikkila <juha-pekka.heikk...@linux.intel.com> Cc: Chad Versace <chad.vers...@linux.intel.com> Signed-off-by: Emil Velikov <emil.l.veli...@gmail.com> --- src/waffle/android/droid_surfaceflingerlink.cpp | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) diff --git a/src/waffle/android/droid_surfaceflingerlink.cpp b/src/waffle/android/droid_surfaceflingerlink.cpp index e8c31ab..c3e2fc8 100644 --- a/src/waffle/android/droid_surfaceflingerlink.cpp +++ b/src/waffle/android/droid_surfaceflingerlink.cpp @@ -94,7 +94,10 @@ droid_destroy_surface( droid_surfaceflinger_container* pSFContainer, droid_ANativeWindow_container* pANWContainer) { + delete pANWContainer->window; pSFContainer->composer_client->openGlobalTransaction(); + // Admire the lengthy comment in the implementation of clear() why we + // need it over the normal dtor. pANWContainer->surface_control->clear(); pSFContainer->composer_client->closeGlobalTransaction(); delete pANWContainer; @@ -113,9 +116,6 @@ droid_setup_surface( pANWContainer = new droid_ANativeWindow_container; - if (pANWContainer == NULL) - goto error; - // The signature of SurfaceComposerClient::createSurface() differs across // Android versions. #if WAFFLE_ANDROID_MAJOR_VERSION == 4 && \ @@ -137,7 +137,6 @@ droid_setup_surface( if (pANWContainer->surface_control == NULL) { wcore_errorf(WAFFLE_ERROR_UNKNOWN, "Unable to get android::SurfaceControl"); - delete pANWContainer; goto error; } @@ -145,21 +144,19 @@ droid_setup_surface( if (bRVal != true) { wcore_errorf(WAFFLE_ERROR_UNKNOWN, "Acquired android::SurfaceControl is invalid"); - delete pANWContainer; goto error; } pSFContainer->composer_client->openGlobalTransaction(); iRVal = pANWContainer->surface_control->setLayer(droid_magic_surface_z); + pSFContainer->composer_client->closeGlobalTransaction(); + if (iRVal != NO_ERROR) { wcore_errorf(WAFFLE_ERROR_UNKNOWN, "Error in android::SurfaceControl->setLayer"); - delete pANWContainer; - goto error_closeTransaction; + goto error; } - pSFContainer->composer_client->closeGlobalTransaction(); - pANWContainer->window = pANWContainer->surface_control->getSurface(); pSFContainer->composer_client->openGlobalTransaction(); @@ -169,7 +166,6 @@ droid_setup_surface( if (iRVal != NO_ERROR) { wcore_errorf(WAFFLE_ERROR_UNKNOWN, "error in android::SurfaceControl->setSize"); - delete pANWContainer; goto error; } @@ -177,11 +173,8 @@ droid_setup_surface( return pANWContainer; -error_closeTransaction: - pSFContainer->composer_client->closeGlobalTransaction(); - error: - droid_tear_down_surfaceflinger_link(pSFContainer); + droid_destroy_surface(pSFContainer, pANWContainer) return NULL; } -- 2.8.0 _______________________________________________ waffle mailing list waffle@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/waffle