@@ -960,6 +960,10 @@ static void *mobile_main(void *arg)
960960 {
961961 MCLog (" X_init failed" , 0 );
962962
963+ // IM-2013-05-01: [[ BZ 10586 ]] signal java ui thread to exit
964+ // finish LiveCodeActivity
965+ MCAndroidEngineRemoteCall (" finishActivity" , " v" , nil);
966+
963967 // Yield for now as we don't detect error states correctly.
964968 co_yield_to_android ();
965969
@@ -1001,16 +1005,17 @@ static void *mobile_main(void *arg)
10011005 }
10021006
10031007 MCLog (" Shutting down project" , 0 );
1004- MCexitall = False;
1005- MCdefaultstackptr->getcard ()->message (MCM_shut_down);
1006- MCQuit ();
1007-
1008- while (s_engine_running)
1009- X_main_loop_iteration ();
1010-
1008+
10111009 MCLog (" Calling X_close" , 0 );
10121010 X_close ();
10131011
1012+ // IM-2013-05-01: [[ BZ 10586 ]] signal java ui thread
1013+ // and wait for it to exit
1014+ MCAndroidEngineRemoteCall (" finishActivity" , " v" , nil);
1015+
1016+ while (s_engine_running)
1017+ co_yield_to_android ();
1018+
10141019 // Free argument.
10151020 MCCStringFree (t_args[0 ]);
10161021
@@ -1555,11 +1560,10 @@ JNIEXPORT void JNICALL Java_com_runrev_android_Engine_doDestroy(JNIEnv *env, job
15551560
15561561 s_engine_running = false ;
15571562
1558- // Set the global exit vars appropriately and yield to the engine thread
1559- // which should heed them and exit.
1563+ // IM-2013-05-01: [[ BZ 10586 ]] we should now only be called when the
1564+ // engine thread is about to exit, so set s_engine_running to false & yield
1565+ // so it can finish terminating
15601566 MCLog (" Yielding to engine thread to perform finalization phase" , 0 );
1561- MCquit = True;
1562- MCexitall = True;
15631567 co_yield_to_engine ();
15641568
15651569 // Finalize bitmap mutex
0 commit comments