main-executable/main.c: set LC_ALL to en_US to fix weird locale-related issues; check for exceptions when running onDestroy

This commit is contained in:
Mis012
2023-01-05 18:58:52 +01:00
parent bc66fb69da
commit d37af8183d

View File

@@ -8,6 +8,7 @@
#include <dlfcn.h> #include <dlfcn.h>
#include <errno.h> #include <errno.h>
#include <locale.h>
#include <stdio.h> #include <stdio.h>
#include <sys/stat.h> #include <sys/stat.h>
@@ -21,9 +22,16 @@ GtkWidget *window;
gboolean app_exit(GtkWindow* self, JNIEnv *env) // TODO: do more cleanup? 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); (*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; 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*/ /* this has to be done in the main executable, so might as well do it here*/
init__r_debug(); 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)); struct jni_callback_data *callback_data = malloc(sizeof(struct jni_callback_data));
callback_data->apk_main_activity_class = NULL; callback_data->apk_main_activity_class = NULL;
callback_data->window_width = 960; callback_data->window_width = 960;