[gtk+] tooltip: Ensure our quark is not 0



commit d91b8c91d3da735b25f0f3f1754cbc043e0cd286
Author: Matthias Clasen <mclasen redhat com>
Date:   Fri May 6 00:45:05 2016 -0400

    tooltip: Ensure our quark is not 0
    
    Many of the tooltip functions can be called before a tooltip
    object is created, and thus initializing the quark in class_init
    is not good enough.

 gtk/gtktooltip.c |   13 ++++++++++---
 1 files changed, 10 insertions(+), 3 deletions(-)
---
diff --git a/gtk/gtktooltip.c b/gtk/gtktooltip.c
index 269425f..6ce17ca 100644
--- a/gtk/gtktooltip.c
+++ b/gtk/gtktooltip.c
@@ -148,7 +148,16 @@ static void       gtk_tooltip_display_closed       (GdkDisplay      *display,
 static void       gtk_tooltip_set_last_window      (GtkTooltip      *tooltip,
                                                    GdkWindow       *window);
 
-static GQuark quark_current_tooltip;
+static inline GQuark tooltip_quark (void)
+{
+  static GQuark quark;
+
+  if G_UNLIKELY (quark == 0)
+    quark = g_quark_from_static_string ("gdk-display-current-tooltip");
+  return quark;
+}
+
+#define quark_current_tooltip tooltip_quark()
 
 G_DEFINE_TYPE (GtkTooltip, gtk_tooltip, G_TYPE_OBJECT);
 
@@ -160,8 +169,6 @@ gtk_tooltip_class_init (GtkTooltipClass *klass)
   object_class = G_OBJECT_CLASS (klass);
 
   object_class->dispose = gtk_tooltip_dispose;
-
-  quark_current_tooltip = g_quark_from_static_string ("gdk-display-current-tooltip");
 }
 
 static void


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]