diff android/dw.cpp @ 2983:81611e54ff1d

Android: Fix DW_SIGNAL_HTML_MESSAGE, there were 3 problems in the last commit. Passed HTML_CHANGE instead of HTML_MESSAGE in a copy and paste problem. The injected javascript code needed the first parameter quoted. The interface callback seems to be run on a thread that was not initialized. Presumably the web content has its own thread so need to initialize the environment.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Mon, 27 Mar 2023 04:34:29 +0000
parents e6fb2558e29e
children ebb94fc2b19f
line wrap: on
line diff
--- a/android/dw.cpp	Mon Mar 27 00:40:17 2023 +0000
+++ b/android/dw.cpp	Mon Mar 27 04:34:29 2023 +0000
@@ -272,7 +272,7 @@
         { _DW_EVENT_HTML_RESULT,    DW_SIGNAL_HTML_RESULT },
         { _DW_EVENT_HTML_CHANGED,   DW_SIGNAL_HTML_CHANGED },
         { _DW_EVENT_HTML_MESSAGE,   DW_SIGNAL_HTML_MESSAGE },
-        { 0,                                    "" }
+        { 0,                        "" }
 };
 
 #define _DW_EVENT_PARAM_SIZE 10
@@ -592,8 +592,7 @@
         params[9] = (void *)handler;
 
         /* We have to handle draw events in the main thread...
-         * If it isn't a draw event, either queue the event
-         * or launch a new thread to handle it.
+         * If it isn't a draw event, queue the event.
          */
         if(DW_POINTER_TO_INT(params[8]) != _DW_EVENT_EXPOSE)
         {
@@ -691,6 +690,9 @@
                                            nullptr, nullptr, nullptr, nullptr, nullptr,
                                            DW_INT_TO_POINTER(message), nullptr };
 
+    // This seems callback seems to run on an uninitialized thread...
+    pthread_setspecific(_dw_env_key, env);
+
     _dw_event_handler(obj1, params);
     if(name)
         env->ReleaseStringUTFChars(htmlName, name);