]> Pileus Git - ~andy/gtk/commitdiff
Based on a patch by Martin Kretzschmar; #122448
authorMichael Meeks <michael@ximian.com>
Mon, 8 Dec 2003 17:13:13 +0000 (17:13 +0000)
committerMichael Meeks <michael@src.gnome.org>
Mon, 8 Dec 2003 17:13:13 +0000 (17:13 +0000)
2003-12-02  Michael Meeks  <michael@ximian.com>

Based on a patch by Martin Kretzschmar; #122448

* gdk/gdk.h: new gdk_threads_lock, gdk_threads_unlock, point to
implementation of GDK_THREADS_ENTER / GDK_THREADS_LEAVE.
(GDK_THREADS_ENTER, GDK_THREADS_LEAVE): use gdk_threads_[un]lock
function pointers. Deprecate the global gdk_threads_mutex variable.

* gdk/gdk.c (gdk_threads_impl_lock, gdk_threads_impl_unlock): new,
extracted from GTK_THREADS_ENTER/LEAVE macros.
(gdk_threads_init): init gtk_threads_[un]lock if not set.
(gdk_threads_set_lock_functions): impl.

* gdk/gdkglobals.c: add definitions of gdk_threads_[un]lock.

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-4
ChangeLog.pre-2-6
ChangeLog.pre-2-8
gdk/gdk.c
gdk/gdk.h
gdk/gdkglobals.c

index ee3b9a6db1ad19ce6a2b62a8f36b7a2c98a607a4..e91b2581abc501894bf32870bc5526fea8f47b4f 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,19 @@
+2003-12-02  Michael Meeks  <michael@ximian.com>
+
+       Based on a patch by Martin Kretzschmar; #122448
+       
+       * gdk/gdk.h: new gdk_threads_lock, gdk_threads_unlock, point to
+       implementation of GDK_THREADS_ENTER / GDK_THREADS_LEAVE.
+       (GDK_THREADS_ENTER, GDK_THREADS_LEAVE): use gdk_threads_[un]lock
+       function pointers. Deprecate the global gdk_threads_mutex variable.
+       
+       * gdk/gdk.c (gdk_threads_impl_lock, gdk_threads_impl_unlock): new,
+       extracted from GTK_THREADS_ENTER/LEAVE macros.
+       (gdk_threads_init): init gtk_threads_[un]lock if not set.
+       (gdk_threads_set_lock_functions): impl.
+
+       * gdk/gdkglobals.c: add definitions of gdk_threads_[un]lock.
+
 Sun Dec  7 23:45:40 2003  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkicontheme.c (gtk_icon_theme_has_icon): Don't crash if
@@ -544,7 +560,7 @@ Wed Nov 12 21:40:10 2003  Matthias Clasen  <maclas@gmx.de>
 Wed Nov 12 21:00:10 2003  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkinputdialog.c (gtk_input_dialog_init): Clarify the
-       label for the empty list. String change.  (#95446, Tomas Ögren)
+       label for the empty list. String change.  (#95446, Tomas Ã\83Â\96gren)
 
 Wed Nov 12 20:57:50 2003  Matthias Clasen  <maclas@gmx.de>
 
@@ -4449,7 +4465,7 @@ Fri Jun  6 11:07:33 2003  Owen Taylor  <otaylor@redhat.com>
        * gtk/gtkwidget.c (event_window_still_viewable): 
        Before delivering an event to a widget, check that
        (if relevant), the event's window is still viewable.
-       (#105642, Dennis Björklund)
+       (#105642, Dennis BjÃ\83¶rklund)
 
        * gdk/gdkwindow.c (_gdk_window_destroy_hierarchy): 
        NULL out private->parent, since after destruction
@@ -4598,7 +4614,7 @@ Thu Jun  5 16:52:54 2003  Owen Taylor  <otaylor@redhat.com>
 
 Thu Jun  5 17:20:40 2003  Owen Taylor  <otaylor@redhat.com>
         
-        #107883, Gustavo Giráldez
+        #107883, Gustavo GirÃ\83¡ldez
 
        * gtk/gtktextlayout.c (gtk_text_layout_emit_changed):
        Split out the case where we know we changed, and 
@@ -5930,7 +5946,7 @@ Mon Jan 27 22:43:11 2003  Kristian Rietveld  <kris@gtk.org>
 
        * gtk/gtktreestore.c (gtk_tree_store_sort_helper): don't just bail
        out if the level only has one item, recurse over the child if there
-       is one. (Fixes #100458, reported by Gaël Le Mignot).
+       is one. (Fixes #100458, reported by GaÃ\83«l Le Mignot).
 
 Mon Jan 27 22:41:26 2003  Kristian Rietveld  <kris@gtk.org>
 
index ee3b9a6db1ad19ce6a2b62a8f36b7a2c98a607a4..e91b2581abc501894bf32870bc5526fea8f47b4f 100644 (file)
@@ -1,3 +1,19 @@
+2003-12-02  Michael Meeks  <michael@ximian.com>
+
+       Based on a patch by Martin Kretzschmar; #122448
+       
+       * gdk/gdk.h: new gdk_threads_lock, gdk_threads_unlock, point to
+       implementation of GDK_THREADS_ENTER / GDK_THREADS_LEAVE.
+       (GDK_THREADS_ENTER, GDK_THREADS_LEAVE): use gdk_threads_[un]lock
+       function pointers. Deprecate the global gdk_threads_mutex variable.
+       
+       * gdk/gdk.c (gdk_threads_impl_lock, gdk_threads_impl_unlock): new,
+       extracted from GTK_THREADS_ENTER/LEAVE macros.
+       (gdk_threads_init): init gtk_threads_[un]lock if not set.
+       (gdk_threads_set_lock_functions): impl.
+
+       * gdk/gdkglobals.c: add definitions of gdk_threads_[un]lock.
+
 Sun Dec  7 23:45:40 2003  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkicontheme.c (gtk_icon_theme_has_icon): Don't crash if
@@ -544,7 +560,7 @@ Wed Nov 12 21:40:10 2003  Matthias Clasen  <maclas@gmx.de>
 Wed Nov 12 21:00:10 2003  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkinputdialog.c (gtk_input_dialog_init): Clarify the
-       label for the empty list. String change.  (#95446, Tomas Ögren)
+       label for the empty list. String change.  (#95446, Tomas Ã\83Â\96gren)
 
 Wed Nov 12 20:57:50 2003  Matthias Clasen  <maclas@gmx.de>
 
@@ -4449,7 +4465,7 @@ Fri Jun  6 11:07:33 2003  Owen Taylor  <otaylor@redhat.com>
        * gtk/gtkwidget.c (event_window_still_viewable): 
        Before delivering an event to a widget, check that
        (if relevant), the event's window is still viewable.
-       (#105642, Dennis Björklund)
+       (#105642, Dennis BjÃ\83¶rklund)
 
        * gdk/gdkwindow.c (_gdk_window_destroy_hierarchy): 
        NULL out private->parent, since after destruction
@@ -4598,7 +4614,7 @@ Thu Jun  5 16:52:54 2003  Owen Taylor  <otaylor@redhat.com>
 
 Thu Jun  5 17:20:40 2003  Owen Taylor  <otaylor@redhat.com>
         
-        #107883, Gustavo Giráldez
+        #107883, Gustavo GirÃ\83¡ldez
 
        * gtk/gtktextlayout.c (gtk_text_layout_emit_changed):
        Split out the case where we know we changed, and 
@@ -5930,7 +5946,7 @@ Mon Jan 27 22:43:11 2003  Kristian Rietveld  <kris@gtk.org>
 
        * gtk/gtktreestore.c (gtk_tree_store_sort_helper): don't just bail
        out if the level only has one item, recurse over the child if there
-       is one. (Fixes #100458, reported by Gaël Le Mignot).
+       is one. (Fixes #100458, reported by GaÃ\83«l Le Mignot).
 
 Mon Jan 27 22:41:26 2003  Kristian Rietveld  <kris@gtk.org>
 
index ee3b9a6db1ad19ce6a2b62a8f36b7a2c98a607a4..e91b2581abc501894bf32870bc5526fea8f47b4f 100644 (file)
@@ -1,3 +1,19 @@
+2003-12-02  Michael Meeks  <michael@ximian.com>
+
+       Based on a patch by Martin Kretzschmar; #122448
+       
+       * gdk/gdk.h: new gdk_threads_lock, gdk_threads_unlock, point to
+       implementation of GDK_THREADS_ENTER / GDK_THREADS_LEAVE.
+       (GDK_THREADS_ENTER, GDK_THREADS_LEAVE): use gdk_threads_[un]lock
+       function pointers. Deprecate the global gdk_threads_mutex variable.
+       
+       * gdk/gdk.c (gdk_threads_impl_lock, gdk_threads_impl_unlock): new,
+       extracted from GTK_THREADS_ENTER/LEAVE macros.
+       (gdk_threads_init): init gtk_threads_[un]lock if not set.
+       (gdk_threads_set_lock_functions): impl.
+
+       * gdk/gdkglobals.c: add definitions of gdk_threads_[un]lock.
+
 Sun Dec  7 23:45:40 2003  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkicontheme.c (gtk_icon_theme_has_icon): Don't crash if
@@ -544,7 +560,7 @@ Wed Nov 12 21:40:10 2003  Matthias Clasen  <maclas@gmx.de>
 Wed Nov 12 21:00:10 2003  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkinputdialog.c (gtk_input_dialog_init): Clarify the
-       label for the empty list. String change.  (#95446, Tomas Ögren)
+       label for the empty list. String change.  (#95446, Tomas Ã\83Â\96gren)
 
 Wed Nov 12 20:57:50 2003  Matthias Clasen  <maclas@gmx.de>
 
@@ -4449,7 +4465,7 @@ Fri Jun  6 11:07:33 2003  Owen Taylor  <otaylor@redhat.com>
        * gtk/gtkwidget.c (event_window_still_viewable): 
        Before delivering an event to a widget, check that
        (if relevant), the event's window is still viewable.
-       (#105642, Dennis Björklund)
+       (#105642, Dennis BjÃ\83¶rklund)
 
        * gdk/gdkwindow.c (_gdk_window_destroy_hierarchy): 
        NULL out private->parent, since after destruction
@@ -4598,7 +4614,7 @@ Thu Jun  5 16:52:54 2003  Owen Taylor  <otaylor@redhat.com>
 
 Thu Jun  5 17:20:40 2003  Owen Taylor  <otaylor@redhat.com>
         
-        #107883, Gustavo Giráldez
+        #107883, Gustavo GirÃ\83¡ldez
 
        * gtk/gtktextlayout.c (gtk_text_layout_emit_changed):
        Split out the case where we know we changed, and 
@@ -5930,7 +5946,7 @@ Mon Jan 27 22:43:11 2003  Kristian Rietveld  <kris@gtk.org>
 
        * gtk/gtktreestore.c (gtk_tree_store_sort_helper): don't just bail
        out if the level only has one item, recurse over the child if there
-       is one. (Fixes #100458, reported by Gaël Le Mignot).
+       is one. (Fixes #100458, reported by GaÃ\83«l Le Mignot).
 
 Mon Jan 27 22:41:26 2003  Kristian Rietveld  <kris@gtk.org>
 
index ee3b9a6db1ad19ce6a2b62a8f36b7a2c98a607a4..e91b2581abc501894bf32870bc5526fea8f47b4f 100644 (file)
@@ -1,3 +1,19 @@
+2003-12-02  Michael Meeks  <michael@ximian.com>
+
+       Based on a patch by Martin Kretzschmar; #122448
+       
+       * gdk/gdk.h: new gdk_threads_lock, gdk_threads_unlock, point to
+       implementation of GDK_THREADS_ENTER / GDK_THREADS_LEAVE.
+       (GDK_THREADS_ENTER, GDK_THREADS_LEAVE): use gdk_threads_[un]lock
+       function pointers. Deprecate the global gdk_threads_mutex variable.
+       
+       * gdk/gdk.c (gdk_threads_impl_lock, gdk_threads_impl_unlock): new,
+       extracted from GTK_THREADS_ENTER/LEAVE macros.
+       (gdk_threads_init): init gtk_threads_[un]lock if not set.
+       (gdk_threads_set_lock_functions): impl.
+
+       * gdk/gdkglobals.c: add definitions of gdk_threads_[un]lock.
+
 Sun Dec  7 23:45:40 2003  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkicontheme.c (gtk_icon_theme_has_icon): Don't crash if
@@ -544,7 +560,7 @@ Wed Nov 12 21:40:10 2003  Matthias Clasen  <maclas@gmx.de>
 Wed Nov 12 21:00:10 2003  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkinputdialog.c (gtk_input_dialog_init): Clarify the
-       label for the empty list. String change.  (#95446, Tomas Ögren)
+       label for the empty list. String change.  (#95446, Tomas Ã\83Â\96gren)
 
 Wed Nov 12 20:57:50 2003  Matthias Clasen  <maclas@gmx.de>
 
@@ -4449,7 +4465,7 @@ Fri Jun  6 11:07:33 2003  Owen Taylor  <otaylor@redhat.com>
        * gtk/gtkwidget.c (event_window_still_viewable): 
        Before delivering an event to a widget, check that
        (if relevant), the event's window is still viewable.
-       (#105642, Dennis Björklund)
+       (#105642, Dennis BjÃ\83¶rklund)
 
        * gdk/gdkwindow.c (_gdk_window_destroy_hierarchy): 
        NULL out private->parent, since after destruction
@@ -4598,7 +4614,7 @@ Thu Jun  5 16:52:54 2003  Owen Taylor  <otaylor@redhat.com>
 
 Thu Jun  5 17:20:40 2003  Owen Taylor  <otaylor@redhat.com>
         
-        #107883, Gustavo Giráldez
+        #107883, Gustavo GirÃ\83¡ldez
 
        * gtk/gtktextlayout.c (gtk_text_layout_emit_changed):
        Split out the case where we know we changed, and 
@@ -5930,7 +5946,7 @@ Mon Jan 27 22:43:11 2003  Kristian Rietveld  <kris@gtk.org>
 
        * gtk/gtktreestore.c (gtk_tree_store_sort_helper): don't just bail
        out if the level only has one item, recurse over the child if there
-       is one. (Fixes #100458, reported by Gaël Le Mignot).
+       is one. (Fixes #100458, reported by GaÃ\83«l Le Mignot).
 
 Mon Jan 27 22:41:26 2003  Kristian Rietveld  <kris@gtk.org>
 
index ee3b9a6db1ad19ce6a2b62a8f36b7a2c98a607a4..e91b2581abc501894bf32870bc5526fea8f47b4f 100644 (file)
@@ -1,3 +1,19 @@
+2003-12-02  Michael Meeks  <michael@ximian.com>
+
+       Based on a patch by Martin Kretzschmar; #122448
+       
+       * gdk/gdk.h: new gdk_threads_lock, gdk_threads_unlock, point to
+       implementation of GDK_THREADS_ENTER / GDK_THREADS_LEAVE.
+       (GDK_THREADS_ENTER, GDK_THREADS_LEAVE): use gdk_threads_[un]lock
+       function pointers. Deprecate the global gdk_threads_mutex variable.
+       
+       * gdk/gdk.c (gdk_threads_impl_lock, gdk_threads_impl_unlock): new,
+       extracted from GTK_THREADS_ENTER/LEAVE macros.
+       (gdk_threads_init): init gtk_threads_[un]lock if not set.
+       (gdk_threads_set_lock_functions): impl.
+
+       * gdk/gdkglobals.c: add definitions of gdk_threads_[un]lock.
+
 Sun Dec  7 23:45:40 2003  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkicontheme.c (gtk_icon_theme_has_icon): Don't crash if
@@ -544,7 +560,7 @@ Wed Nov 12 21:40:10 2003  Matthias Clasen  <maclas@gmx.de>
 Wed Nov 12 21:00:10 2003  Matthias Clasen  <maclas@gmx.de>
 
        * gtk/gtkinputdialog.c (gtk_input_dialog_init): Clarify the
-       label for the empty list. String change.  (#95446, Tomas Ögren)
+       label for the empty list. String change.  (#95446, Tomas Ã\83Â\96gren)
 
 Wed Nov 12 20:57:50 2003  Matthias Clasen  <maclas@gmx.de>
 
@@ -4449,7 +4465,7 @@ Fri Jun  6 11:07:33 2003  Owen Taylor  <otaylor@redhat.com>
        * gtk/gtkwidget.c (event_window_still_viewable): 
        Before delivering an event to a widget, check that
        (if relevant), the event's window is still viewable.
-       (#105642, Dennis Björklund)
+       (#105642, Dennis BjÃ\83¶rklund)
 
        * gdk/gdkwindow.c (_gdk_window_destroy_hierarchy): 
        NULL out private->parent, since after destruction
@@ -4598,7 +4614,7 @@ Thu Jun  5 16:52:54 2003  Owen Taylor  <otaylor@redhat.com>
 
 Thu Jun  5 17:20:40 2003  Owen Taylor  <otaylor@redhat.com>
         
-        #107883, Gustavo Giráldez
+        #107883, Gustavo GirÃ\83¡ldez
 
        * gtk/gtktextlayout.c (gtk_text_layout_emit_changed):
        Split out the case where we know we changed, and 
@@ -5930,7 +5946,7 @@ Mon Jan 27 22:43:11 2003  Kristian Rietveld  <kris@gtk.org>
 
        * gtk/gtktreestore.c (gtk_tree_store_sort_helper): don't just bail
        out if the level only has one item, recurse over the child if there
-       is one. (Fixes #100458, reported by Gaël Le Mignot).
+       is one. (Fixes #100458, reported by GaÃ\83«l Le Mignot).
 
 Mon Jan 27 22:41:26 2003  Kristian Rietveld  <kris@gtk.org>
 
index a9f2078f7d38db2d3a572fbe6ef683e2340fa8e0..67faeab40246b0b665104a0799ef2488aed7ec09 100644 (file)
--- a/gdk/gdk.c
+++ b/gdk/gdk.c
@@ -495,6 +495,20 @@ gdk_threads_leave ()
   GDK_THREADS_LEAVE ();
 }
 
+static void
+gdk_threads_impl_lock (void)
+{
+  if (gdk_threads_mutex)
+    g_mutex_lock (gdk_threads_mutex);
+}
+
+static void
+gdk_threads_impl_unlock (void)
+{
+  if (gdk_threads_mutex)
+    g_mutex_unlock (gdk_threads_mutex);
+}
+
 /**
  * gdk_threads_init:
  * 
@@ -512,6 +526,48 @@ gdk_threads_init ()
     g_error ("g_thread_init() must be called before gdk_threads_init()");
 
   gdk_threads_mutex = g_mutex_new ();
+  if (!gdk_threads_lock)
+    gdk_threads_lock = gdk_threads_impl_lock;
+  if (!gdk_threads_unlock)
+    gdk_threads_unlock = gdk_threads_impl_unlock;
+}
+
+/**
+ * gdk_threads_set_lock_functions:
+ * @enter_fn:   function called to guard gtk+
+ * @leave_fn: function called to release the guard
+ *
+ * Allows the application to replace the standard method that
+ * GDK uses to protect its data structures. Normally, GDK
+ * creates a single #GMutex that is locked by gdk_threads_enter(),
+ * and released by gdk_threads_leave(); using this function an
+ * application provides, instead, a function @enter_fn that is
+ * called by gdk_threads_enter() and a function @leave_fn that is
+ * called by gdk_threads_leave().
+ *
+ * The functions must provide at least same locking functionality
+ * as the default implementation, but can also do extra application
+ * specific processing.
+ *
+ * As an example, consider an application that has its own recursive
+ * lock that when held, holds the GTK+ lock as well. When GTK+ unlocks
+ * the GTK+ lock when entering a recursive main loop, the application
+ * must temporarily release its lock as well.
+ *
+ * Most threaded GTK+ apps won't need to use this method.
+ *
+ * This method must be called before gdk_threads_init, and cannot
+ * be called multiple times.
+ **/
+void
+gdk_threads_set_lock_functions (GCallback enter_fn,
+                               GCallback leave_fn)
+{
+  g_return_if_fail (gdk_threads_lock == NULL &&
+                   gdk_threads_unlock == NULL);
+
+  gdk_threads_lock = enter_fn;
+  gdk_threads_unlock = leave_fn;
 }
 
 G_CONST_RETURN char *
index 44ef60467e4d761f478e64f64443fb60ed65cb6d..fce64e7d4515b0d549507ec2797c7c625618eec8 100644 (file)
--- a/gdk/gdk.h
+++ b/gdk/gdk.h
@@ -171,20 +171,27 @@ void gdk_notify_startup_complete (void);
 /* Threading
  */
 
-GDKVAR GMutex *gdk_threads_mutex;
+#if !defined (GDK_DISABLE_DEPRECATED) || defined (GDK_COMPILATION)
+GDKVAR GMutex *gdk_threads_mutex; /* private */
+#endif
+
+GDKVAR GCallback gdk_threads_lock;
+GDKVAR GCallback gdk_threads_unlock;
 
 void     gdk_threads_enter                (void);
 void     gdk_threads_leave                (void);
-void     gdk_threads_init                 (void);  
+void     gdk_threads_init                 (void);
+void     gdk_threads_set_lock_functions   (GCallback enter_fn,
+                                          GCallback leave_fn);
 
 #ifdef G_THREADS_ENABLED
 #  define GDK_THREADS_ENTER()  G_STMT_START {  \
-      if (gdk_threads_mutex)                   \
-        g_mutex_lock (gdk_threads_mutex);      \
+      if (gdk_threads_lock)                    \
+        (*gdk_threads_lock) ();                        \
    } G_STMT_END
 #  define GDK_THREADS_LEAVE()  G_STMT_START {  \
-      if (gdk_threads_mutex)                   \
-        g_mutex_unlock (gdk_threads_mutex);    \
+      if (gdk_threads_unlock)                  \
+        (*gdk_threads_unlock) ();              \
    } G_STMT_END
 #else  /* !G_THREADS_ENABLED */
 #  define GDK_THREADS_ENTER()
index a4ec6574579d071047cfbbf7afc38c872f4a857b..d3d332f5dcc6ddaa2ed9c836c8048fb178df3706 100644 (file)
@@ -40,5 +40,6 @@ gchar              *_gdk_display_arg_name = NULL;
 
 GSList             *_gdk_displays = NULL;
 
-GMutex           *gdk_threads_mutex = NULL;          /* Global GDK lock */
-
+GMutex              *gdk_threads_mutex = NULL;          /* Global GDK lock */
+GCallback            gdk_threads_lock = NULL;
+GCallback            gdk_threads_unlock = NULL;