# HG changeset patch # User bsmith@81767d24-ef19-dc11-ae90-00e081727c95 # Date 1620385870 0 # Node ID 0fa54c34090247c6c918cf0fc2feaaa167e01053 # Parent e57765c7a437c1a5a8be95142243342c471cee6c Android: Second try at that new fix... move it into _dw_main_launch() This way we don't block the UI thread while waiting to see if the relaunch is requested, the old way we block the full 10 seconds no matter what. diff -r e57765c7a437 -r 0fa54c340902 android/dw.cpp --- a/android/dw.cpp Fri May 07 10:49:50 2021 +0000 +++ b/android/dw.cpp Fri May 07 11:11:10 2021 +0000 @@ -74,19 +74,6 @@ /* Call the dwmain entry point, Android has no args, so just pass the app path */ void _dw_main_launch(char *arg) { - char *argv[2] = { arg, NULL }; - dwmain(1, argv); -} - -/* Called when DWindows activity starts up... so we create a thread - * to call the dwmain() entrypoint... then we wait for dw_main() - * to be called and return. - * Parameters: - * path: The path to the Android app. - */ -JNIEXPORT void JNICALL -Java_org_dbsoft_dwindows_DWindows_dwindowsInit(JNIEnv* env, jobject obj, jstring path) -{ static HEV startup = 0; /* Safety check to prevent multiple initializations... */ @@ -100,7 +87,7 @@ } else { - char *arg; + char *argv[2] = {arg, NULL}; /* Wait for a short while to see if we get called again... * if we get called again we will be posted, if not... @@ -111,8 +98,24 @@ dw_event_wait(startup, 10000); /* Continue after being posted or after our timeout */ - arg = strdup(env->GetStringUTFChars((jstring) path, NULL)); - + dwmain(1, argv); + } + free(arg); +} + +/* Called when DWindows activity starts up... so we create a thread + * to call the dwmain() entrypoint... then we wait for dw_main() + * to be called and return. + * Parameters: + * path: The path to the Android app. + */ +JNIEXPORT void JNICALL +Java_org_dbsoft_dwindows_DWindows_dwindowsInit(JNIEnv* env, jobject obj, jstring path) +{ + char *arg = strdup(env->GetStringUTFChars((jstring) path, NULL)); + + if(!_dw_main_event) + { /* Save our class object pointer for later */ _dw_obj = env->NewGlobalRef(obj); @@ -122,10 +125,10 @@ /* Create the dwmain event */ _dw_main_event = dw_event_new(); - - /* Launch the new thread to execute dwmain() */ - dw_thread_new((void *) _dw_main_launch, arg, 0); } + + /* Launch the new thread to execute dwmain() */ + dw_thread_new((void *) _dw_main_launch, arg, 0); } typedef struct _sighandler