[PATCH] Re: dialog#run seems to block other threads
Richard Jones <[email protected]> Tue, 22 Jun 2010 18:53:38 +0100
| Newsgroups | gmane.comp.lang.ocaml.lib.gtk |
|---|---|
| Message-ID | <[email protected]> |
I looked at the lablgtk2 source and I can see the problem. The wrapper for dialog#run doesn't even attempt to release the OCaml GC lock. I have applied the following patch to my local copy, which appears to cure the problem for me. I don't know if it is safe to release the lock at this point, perhaps someone who knows the code a bit better could comment. Unless I'm doing it wrong, I don't see any calls to caml_enter_blocking_section in the whole of the lablgtk2 code base ... Rich. -- Richard Jones Red Hat _______________________________________________ Lablgtk mailing list [email protected] http://yquem.inria.fr/cgi-bin/mailman/listinfo/lablgtk
lablgtk2-2.14.0-dialog-run-non-blocking.patch
(text/x-diff, 1 KB)
--- lablgtk-2.14.0.orig/src/ml_gtk.c 2009-08-29 17:28:12.000000000 -0400
+++ lablgtk-2.14.0/src/ml_gtk.c 2010-06-22 13:35:53.566433805 -0400
@@ -29,6 +29,7 @@
#include <caml/memory.h>
#include <caml/callback.h>
#include <caml/fail.h>
+#include <caml/signals.h>
#include "wrappers.h"
#include "ml_glib.h"
@@ -676,7 +677,24 @@
ML_3 (gtk_dialog_add_button, GtkDialog_val, String_val, Int_val, Unit)
ML_3 (gtk_dialog_set_response_sensitive, GtkDialog_val, Int_val, Bool_val, Unit)
ML_2 (gtk_dialog_set_default_response, GtkDialog_val, Int_val, Unit)
-ML_1 (gtk_dialog_run, GtkDialog_val, Val_int)
+
+CAMLprim value
+ml_gtk_dialog_run (value dialogv)
+{
+ CAMLparam1 (dialogv);
+ GtkDialog *d = GtkDialog_val (dialogv);
+ int r;
+
+ /* Allow other OCaml threads to run while the dialog is being
+ * displayed. - RWMJ.
+ */
+ caml_enter_blocking_section ();
+ r = gtk_dialog_run (d);
+ caml_leave_blocking_section ();
+
+ CAMLreturn (Val_int (r));
+}
+
/* gtk_dialog_add_action_widget */
/* gtkinputdialog.h */