changeset 2030:2cbbbc850b8d

GTK3: Fix deadlock when calling dw_messagebox() from HTML_RESULT event handler. It isn't clear to me why this is necessary but it fixed the deadlock so committing for now.
author bsmith@81767d24-ef19-dc11-ae90-00e081727c95
date Thu, 14 Nov 2019 12:08:54 +0000
parents 10ca3e9d199f
children c4fc33d70a8e
files gtk3/dw.c
diffstat 1 files changed, 5 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/gtk3/dw.c	Tue Nov 12 00:26:10 2019 +0000
+++ b/gtk3/dw.c	Thu Nov 14 12:08:54 2019 +0000
@@ -1211,7 +1211,9 @@
     int (*htmlresultfunc)(HWND, int, char *, void *, void *) = NULL;
     gint handlerdata = GPOINTER_TO_INT(g_object_get_data(object, "_dw_html_result_id"));
     void *user_data = NULL;
-
+    pthread_t saved_thread = _dw_thread;
+
+    _dw_thread = (pthread_t)-1;
     if(handlerdata)
     {
         SignalHandler work;
@@ -1231,6 +1233,7 @@
         if(htmlresultfunc)
            htmlresultfunc((HWND)object, DW_ERROR_UNKNOWN, error->message, user_data, script_data);
         g_error_free (error);
+        _dw_thread = saved_thread;
         return;
     }
 
@@ -1271,6 +1274,7 @@
         htmlresultfunc((HWND)object, DW_ERROR_UNKNOWN, NULL, user_data, script_data);
     webkit_javascript_result_unref (js_result);
 #endif
+   _dw_thread = saved_thread;
 }
 
 #ifdef USE_WEBKIT