[gtk+] widget: Be safe against windows losing their frame clock



commit b6d287aab5606f6cd40f871d16e73fcb0558b55c
Author: Matthias Clasen <mclasen redhat com>
Date:   Tue Dec 22 23:46:59 2015 -0500

    widget: Be safe against windows losing their frame clock
    
    gdk_widget_get_frame_clock can return NULL. In particular,
    this can happen when the drag window is destroyed at the end
    of a DND operation. Handle this gracefully when it happens.

 gtk/gtkwidget.c |   15 ++++++++++-----
 1 files changed, 10 insertions(+), 5 deletions(-)
---
diff --git a/gtk/gtkwidget.c b/gtk/gtkwidget.c
index e72b563..ee11c3f 100644
--- a/gtk/gtkwidget.c
+++ b/gtk/gtkwidget.c
@@ -5252,6 +5252,7 @@ gtk_widget_add_tick_callback (GtkWidget       *widget,
 {
   GtkWidgetPrivate *priv;
   GtkTickCallbackInfo *info;
+  GdkFrameClock *frame_clock;
 
   g_return_val_if_fail (GTK_IS_WIDGET (widget), 0);
 
@@ -5259,11 +5260,15 @@ gtk_widget_add_tick_callback (GtkWidget       *widget,
 
   if (priv->realized && !priv->clock_tick_id)
     {
-      GdkFrameClock *frame_clock = gtk_widget_get_frame_clock (widget);
-      priv->clock_tick_id = g_signal_connect (frame_clock, "update",
-                                              G_CALLBACK (gtk_widget_on_frame_clock_update),
-                                              widget);
-      gdk_frame_clock_begin_updating (frame_clock);
+      frame_clock = gtk_widget_get_frame_clock (widget);
+
+      if (frame_clock)
+        {
+          priv->clock_tick_id = g_signal_connect (frame_clock, "update",
+                                                  G_CALLBACK (gtk_widget_on_frame_clock_update),
+                                                  widget);
+          gdk_frame_clock_begin_updating (frame_clock);
+        }
     }
 
   info = g_slice_new0 (GtkTickCallbackInfo);


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