From 4f1780c7828737266b7aa1ae8372b7f1c7711b69 Mon Sep 17 00:00:00 2001 From: Matthias Clasen Date: Fri, 30 Jan 2015 06:07:34 -0500 Subject: [PATCH] Robustness fixes for drag cancel animation gtk_widget_get_frame_clock() can return NULL. Deal with that by silently stopping the drag cancel animation in this case. --- gtk/gtkdnd.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) diff --git a/gtk/gtkdnd.c b/gtk/gtkdnd.c index 6e829d14ed..733af5e398 100644 --- a/gtk/gtkdnd.c +++ b/gtk/gtkdnd.c @@ -3942,16 +3942,24 @@ gtk_drag_anim_destroy (GtkDragAnim *anim) static gboolean gtk_drag_anim_timeout (gpointer data) { - GtkWidget *icon_window; GtkDragAnim *anim = data; GtkDragSourceInfo *info = anim->info; - GtkWidget *widget = info->widget; - GdkFrameClock *frame_clock = gtk_widget_get_frame_clock (widget); - gint64 current_time = gdk_frame_clock_get_frame_time (frame_clock); + GtkWidget *icon_window; + GdkFrameClock *frame_clock; + gint64 current_time; int hot_x, hot_y; - double f = (current_time - anim->start_time) / (double) ANIM_TIME; + double f; double t; + frame_clock = gtk_widget_get_frame_clock (info->widget); + + if (!frame_clock) + return G_SOURCE_REMOVE; + + current_time = gdk_frame_clock_get_frame_time (frame_clock); + + f = (current_time - anim->start_time) / (double) ANIM_TIME; + if (f >= 1.0) return G_SOURCE_REMOVE;