From d37af8183d5139b7034bd502c64c5e18e69ad443 Mon Sep 17 00:00:00 2001 From: Mis012 Date: Thu, 5 Jan 2023 18:58:52 +0100 Subject: [PATCH] main-executable/main.c: set LC_ALL to en_US to fix weird locale-related issues; check for exceptions when running onDestroy --- src/main-executable/main.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main-executable/main.c b/src/main-executable/main.c index 9263cd94..9509c1d4 100644 --- a/src/main-executable/main.c +++ b/src/main-executable/main.c @@ -8,6 +8,7 @@ #include #include +#include #include #include @@ -21,9 +22,16 @@ GtkWidget *window; gboolean app_exit(GtkWindow* self, JNIEnv *env) // TODO: do more cleanup? { - /* -- run the main activity's onDestroy -- */ + // in case some exception was left unhandled in native code, print it here so we don't confuse it with an exception thrown by onDestroy + if((*env)->ExceptionCheck(env)) { + fprintf(stderr, "app_exit: seems there was a pending exception... :"); + (*env)->ExceptionDescribe(env); + } + /* -- run the main activity's onDestroy -- */ (*env)->CallVoidMethod(env, handle_cache.apk_main_activity.object, handle_cache.apk_main_activity.onDestroy, NULL); + if((*env)->ExceptionCheck(env)) + (*env)->ExceptionDescribe(env); return false; } @@ -400,6 +408,10 @@ int main(int argc, char **argv/*, JNIEnv *env*/) /* this has to be done in the main executable, so might as well do it here*/ init__r_debug(); + // locale on android always behaves as en_US, and some apps might unbeknownst to them depend on that + // for correct functionality + setenv("LC_ALL", "en_US", 1); + struct jni_callback_data *callback_data = malloc(sizeof(struct jni_callback_data)); callback_data->apk_main_activity_class = NULL; callback_data->window_width = 960;