Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit cc6d4839 authored by Robert Carr's avatar Robert Carr
Browse files

SurfaceControl: Fix release

Currently we call decStrong causing ~SurfaceControl to be invoked.
If mOwned=true this will cause a reparent to null which is not the
intended behavior of release. We call SurfaceControl#release before
decStrong to fix this. Also we have destroy call destroy to be less
confusing.

Bug: 123587983
Test: SurfaceControlTest
Change-Id: I86faa9d1eb850ac6437fc870b126a1473ee091e3
parent affa55b4
Loading
Loading
Loading
Loading
+2 −1
Original line number Original line Diff line number Diff line
@@ -178,12 +178,13 @@ static jlong nativeCreate(JNIEnv* env, jclass clazz, jobject sessionObj,


static void nativeRelease(JNIEnv* env, jclass clazz, jlong nativeObject) {
static void nativeRelease(JNIEnv* env, jclass clazz, jlong nativeObject) {
    sp<SurfaceControl> ctrl(reinterpret_cast<SurfaceControl *>(nativeObject));
    sp<SurfaceControl> ctrl(reinterpret_cast<SurfaceControl *>(nativeObject));
    ctrl->release();
    ctrl->decStrong((void *)nativeCreate);
    ctrl->decStrong((void *)nativeCreate);
}
}


static void nativeDestroy(JNIEnv* env, jclass clazz, jlong nativeObject) {
static void nativeDestroy(JNIEnv* env, jclass clazz, jlong nativeObject) {
    sp<SurfaceControl> ctrl(reinterpret_cast<SurfaceControl *>(nativeObject));
    sp<SurfaceControl> ctrl(reinterpret_cast<SurfaceControl *>(nativeObject));
    ctrl->clear();
    ctrl->destroy();
    ctrl->decStrong((void *)nativeCreate);
    ctrl->decStrong((void *)nativeCreate);
}
}