GtkTimeline: protect the timeline from unref

The timeline frame function emits several signals, assuming that the
timeline will exist after these signals return.  This assumption can be
invalid if signal handlers unref the timeline.

https://bugzilla.gnome.org/show_bug.cgi?id=668675
This commit is contained in:
Ryan Lortie
2012-01-25 11:30:11 -05:00
parent eed307713b
commit e2750a4f5e

View File

@ -311,6 +311,9 @@ gtk_timeline_run_frame (GtkTimeline *timeline)
gdouble delta_progress, progress;
guint elapsed_time;
/* the user may unref us during the signals, so save ourselves */
g_object_ref (timeline);
priv = timeline->priv;
elapsed_time = (guint) (g_timer_elapsed (priv->timer, NULL) * 1000);
@ -355,10 +358,13 @@ gtk_timeline_run_frame (GtkTimeline *timeline)
}
g_timer_stop (priv->timer);
g_signal_emit (timeline, signals [FINISHED], 0);
g_object_unref (timeline);
return FALSE;
}
}
g_object_unref (timeline);
return TRUE;
}