]> Pileus Git - ~andy/gtk/commitdiff
gdk: Deprecate thread functions
authorMatthias Clasen <mclasen@redhat.com>
Sat, 28 Jul 2012 15:23:17 +0000 (17:23 +0200)
committerMatthias Clasen <mclasen@redhat.com>
Mon, 30 Jul 2012 16:01:47 +0000 (18:01 +0200)
This commit deprecates gdk_threads_init, gdk_threads_enter,
gdk_threads_leave and gdk_threads_set_lock_functions. Using GTK+
from multiple threads does not work at all on Windows, and is
problematic on other platforms as well. We want to move to a world
where all GTK+ calls are made from the main thread.
Use g_main_context_invoke, g_idle_add and related functions if you
need to schedule GTK+ calls from other threads.

http://bugzilla.gnome.org/show_bug.cgi?id=680754

gdk/gdk.c
gdk/gdkthreads.h

index 3c8c71153b485a12f3bf755effc1f66d9ff8722b..cf81863a1d8f429389eea0ab76537cbf7a65a072 100644 (file)
--- a/gdk/gdk.c
+++ b/gdk/gdk.c
@@ -663,6 +663,9 @@ gdk_init (int *argc, char ***argv)
  * GDK and GTK+ functions can be called safely and without causing race
  * conditions. Only one thread at a time can be in such a critial
  * section.
+ *
+ * Deprecated:3.6: All GDK and GTK+ calls should be made from the main
+ *     thread
  */
 void
 gdk_threads_enter (void)
@@ -675,6 +678,9 @@ gdk_threads_enter (void)
  * gdk_threads_leave:
  *
  * Leaves a critical region begun with gdk_threads_enter().
+ *
+ * Deprecated:3.6: All GDK and GTK+ calls should be made from the main
+ *     thread
  */
 void
 gdk_threads_leave (void)
@@ -703,6 +709,9 @@ gdk_threads_impl_unlock (void)
  *
  * This call must be made before any use of the main loop from
  * GTK+; to be safe, call it before gtk_init().
+ *
+ * Deprecated:3.6: All GDK and GTK+ calls should be made from the main
+ *     thread
  */
 void
 gdk_threads_init (void)
@@ -740,6 +749,9 @@ gdk_threads_init (void)
  * This method must be called before gdk_threads_init(), and cannot
  * be called multiple times.
  *
+ * Deprecated:3.6: All GDK and GTK+ calls should be made from the main
+ *     thread
+ *
  * Since: 2.4
  **/
 void
index 74e48992cd65de35ef40e62331709864bc440733..172e1b165730b8c11a2f83421cc9e2d4c9f9d580 100644 (file)
 
 G_BEGIN_DECLS
 
+#if defined(GDK_COMPILATION) || defined(GTK_COMPILATION)
+#define GDK_THREADS_DEPRECATED
+#else
+#define GDK_THREADS_DEPRECATED GDK_DEPRECATED_IN_3_6
+#endif
+
+GDK_THREADS_DEPRECATED
 void     gdk_threads_init                     (void);
+GDK_THREADS_DEPRECATED
 void     gdk_threads_enter                    (void);
+GDK_THREADS_DEPRECATED
 void     gdk_threads_leave                    (void);
+GDK_THREADS_DEPRECATED
 void     gdk_threads_set_lock_functions       (GCallback enter_fn,
                                                GCallback leave_fn);
 
@@ -62,6 +72,9 @@ guint    gdk_threads_add_timeout_seconds      (guint          interval,
                                                GSourceFunc    function,
                                                gpointer       data);
 
+
+#if !(GDK_VERSION_MIN_REQUIRED >= GDK_VERSION_3_6)
+
 /**
  * GDK_THREADS_ENTER:
  *
@@ -71,6 +84,9 @@ guint    gdk_threads_add_timeout_seconds      (guint          interval,
  * section. The macro expands to a no-op if #G_THREADS_ENABLED has not
  * been defined. Typically gdk_threads_enter() should be used instead of
  * this macro.
+ *
+ * Deprecated:3.6: Use g_main_context_invoke(), g_idle_add() and related
+ *     functions if you need to schedule GTK+ calls from other threads.
  */
 #define GDK_THREADS_ENTER() gdk_threads_enter()
 
@@ -79,9 +95,15 @@ guint    gdk_threads_add_timeout_seconds      (guint          interval,
  *
  * This macro marks the end of a critical section
  * begun with #GDK_THREADS_ENTER.
+ *
+ * Deprecated:3.6: Deprecated in 3.6.
  */
 #define GDK_THREADS_LEAVE() gdk_threads_leave()
 
+#endif
+
+#undef GDK_THREADS_DEPRECATED
+
 G_END_DECLS
 
 #endif /* __GDK_THREADS_H__ */