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.
This commit is contained in:
Matthias Clasen 2015-12-22 23:46:59 -05:00
parent 8ffa8b3a49
commit b6d287aab5

View File

@ -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);