Răsfoiți Sursa

JmeSurfaceView: Removed explicit nullifying GlSurfaceView onDestroy (#1802)

* JmeSurfaceView: Removed explicit nullifying GlSurfaceView onDestroy

* JmeSurfaceView: destroying the GlSurfaceView using `ViewGroup#removeView(view:android.View)`

* fixed-conflicting-changes
Scrappers Team 3 ani în urmă
părinte
comite
1adbd56f10

+ 10 - 2
jme3-android/src/main/java/com/jme3/app/jmeSurfaceView/JmeSurfaceView.java

@@ -338,6 +338,14 @@ public class JmeSurfaceView extends RelativeLayout implements SystemListener, Di
         }
     }
 
+    private void removeGlSurfaceView() {
+        ((Activity)getContext()).runOnUiThread(() -> {
+            if (glSurfaceView != null) {
+                JmeSurfaceView.this.removeView(glSurfaceView);
+            }
+        });
+    }
+
     //******************Overridden methods by the implemented interfaces************************
 
     @Override
@@ -503,6 +511,7 @@ public class JmeSurfaceView extends RelativeLayout implements SystemListener, Di
         if (legacyApplication == null) {
             return;
         }
+        removeGlSurfaceView();
         legacyApplication.destroy();
         /*help the Dalvik Garbage collector to destruct the pointers, by making them nullptr*/
         /*context instances*/
@@ -510,7 +519,6 @@ public class JmeSurfaceView extends RelativeLayout implements SystemListener, Di
         appSettings = null;
         oglesContext = null;
         configurationInfo = null;
-        glSurfaceView = null;
         /*extra data instances*/
         crashLogWriter = null;
         crashLog = null;
@@ -970,4 +978,4 @@ public class JmeSurfaceView extends RelativeLayout implements SystemListener, Di
     public boolean isShowErrorDialog() {
         return showErrorDialog;
     }
-}
+}