From d6fdd6fff8a86a4f8e106188478e72c451e6363f Mon Sep 17 00:00:00 2001 From: Dmitry Kalyanov Date: Wed, 30 Dec 2009 23:10:53 +0300 Subject: [PATCH] When multithreading is supported, run gtk_main with Gdk threads lock acquired --- gdk/gdk.threads.lisp | 8 ++++++++ gtk/gtk.main_loop_events.lisp | 10 +++++++++- 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/gdk/gdk.threads.lisp b/gdk/gdk.threads.lisp index fc13d8e..5be7743 100644 --- a/gdk/gdk.threads.lisp +++ b/gdk/gdk.threads.lisp @@ -9,6 +9,14 @@ (defcfun gdk-threads-leave :void) (export 'gdk-threads-leave) +(defmacro with-gdk-threads-lock (&body body) + `(progn + (gdk-threads-enter) + (unwind-protect + (progn ,@body) + (gdk-threads-leave)))) +(export 'with-gdk-threads-lock) + ;; ignored: ;; void gdk_threads_set_lock_functions (GCallback enter_fn, ;; GCallback leave_fn); diff --git a/gtk/gtk.main_loop_events.lisp b/gtk/gtk.main_loop_events.lisp index 961b357..b26f147 100644 --- a/gtk/gtk.main_loop_events.lisp +++ b/gtk/gtk.main_loop_events.lisp @@ -19,7 +19,15 @@ (at-init () (gtk-init)) -(defcfun gtk-main :void) +(defcfun (%gtk-main "gtk_main") :void) + +#+thread-support +(defun gtk-main () + (with-gdk-threads-lock (%gtk-main))) + +#-thread-support +(defun gtk-main () + (%gtk-main)) #+thread-support (defvar *main-thread* nil) -- 1.7.10.4