[Android] Fixes #2679 - Crash resuming from screen off
authorGabriel Jacobo <gabomdq@gmail.com>
Wed, 17 Sep 2014 08:59:43 -0300
changeset 9144 c197a316685a
parent 9143 b664273a455c
child 9145 aa99e029b12e
[Android] Fixes #2679 - Crash resuming from screen off Before destroying the static Java-side data, wait for the SDL native thread, *and* the listener thread that waits on it to trigger a clean up.
android-project/src/org/libsdl/app/SDLActivity.java
--- a/android-project/src/org/libsdl/app/SDLActivity.java	Tue Sep 16 23:09:32 2014 +0200
+++ b/android-project/src/org/libsdl/app/SDLActivity.java	Wed Sep 17 08:59:43 2014 -0300
@@ -932,16 +932,16 @@
             // This is the entry point to the C app.
             // Start up the C app thread and enable sensor input for the first time
 
-            SDLActivity.mSDLThread = new Thread(new SDLMain(), "SDLThread");
+            final Thread sdlThread = new Thread(new SDLMain(), "SDLThread");
             enableSensor(Sensor.TYPE_ACCELEROMETER, true);
-            SDLActivity.mSDLThread.start();
+            sdlThread.start();
             
             // Set up a listener thread to catch when the native thread ends
-            new Thread(new Runnable(){
+            SDLActivity.mSDLThread = new Thread(new Runnable(){
                 @Override
                 public void run(){
                     try {
-                        SDLActivity.mSDLThread.join();
+                        sdlThread.join();
                     }
                     catch(Exception e){}
                     finally{ 
@@ -951,7 +951,8 @@
                         }
                     }
                 }
-            }).start();
+            });
+            SDLActivity.mSDLThread.start();
         }
     }