android: better clean-up on exit
git-svn-id: https://svn.code.sf.net/p/freeglut/code/trunk@1290 7f0cb862-5218-0410-a997-914c9d46530a
This commit is contained in:
parent
d7eef58fb4
commit
d807511ff9
@ -133,6 +133,7 @@ static unsigned char key_ascii(struct android_app* app, AInputEvent* event) {
|
||||
int ascii = (*env)->CallIntMethod(env, keyEvent, KeyEvent_getUnicodeChar, AKeyEvent_getMetaState(event));
|
||||
|
||||
/* LOGI("getUnicodeChar(%d) = %d ('%c')", AKeyEvent_getKeyCode(event), ascii, ascii); */
|
||||
(*vm)->DetachCurrentThread(vm);
|
||||
|
||||
return ascii;
|
||||
}
|
||||
@ -319,8 +320,8 @@ void handle_cmd(struct android_app* app, int32_t cmd) {
|
||||
fgDestroyWindow(fgDisplay.pDisplay.single_window);
|
||||
break;
|
||||
case APP_CMD_DESTROY:
|
||||
/* Not reached because GLUT exit()s when last window is closed */
|
||||
LOGI("handle_cmd: APP_CMD_DESTROY");
|
||||
/* glue has already set android_app->destroyRequested=1 */
|
||||
break;
|
||||
case APP_CMD_GAINED_FOCUS:
|
||||
LOGI("handle_cmd: APP_CMD_GAINED_FOCUS");
|
||||
@ -393,7 +394,7 @@ void fgPlatformProcessSingleEvent ( void )
|
||||
|
||||
void fgPlatformMainLoopPreliminaryWork ( void )
|
||||
{
|
||||
printf("fgPlatformMainLoopPreliminaryWork\n");
|
||||
LOGI("fgPlatformMainLoopPreliminaryWork\n");
|
||||
|
||||
key_init();
|
||||
|
||||
|
@ -127,6 +127,8 @@ static void extract_assets(struct android_app* app) {
|
||||
AAssetDir_close(assetDir);
|
||||
}
|
||||
}
|
||||
|
||||
(*vm)->DetachCurrentThread(vm);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -155,5 +157,13 @@ void android_main(struct android_app* app) {
|
||||
}
|
||||
|
||||
LOGI("android_main: end");
|
||||
|
||||
/* Finish processing all events (namely APP_CMD_DESTROY) before
|
||||
exiting thread */
|
||||
while (!app->destroyRequested)
|
||||
fgPlatformProcessSingleEvent();
|
||||
|
||||
/* In theory we should let NativeActivity restart us, however this
|
||||
doesn't work well yet, so force exit */
|
||||
exit(0);
|
||||
}
|
||||
|
Reference in New Issue
Block a user