Skip to content

Commit

Permalink
[Android] Fixes #2679 - Crash resuming from screen off
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
gabomdq committed Sep 17, 2014
1 parent 60df813 commit e7f2f85
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions android-project/src/org/libsdl/app/SDLActivity.java
Expand Up @@ -932,16 +932,16 @@ public void surfaceChanged(SurfaceHolder holder,
// 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{
Expand All @@ -951,7 +951,8 @@ public void run(){
}
}
}
}).start();
});
SDLActivity.mSDLThread.start();
}
}

Expand Down

0 comments on commit e7f2f85

Please sign in to comment.