Commit d28f1241 authored by Julian Bouzas's avatar Julian Bouzas
Browse files

object: advance pending transitions if activation fails

parent d84d897b
Pipeline #331731 passed with stages
in 1 minute and 8 seconds
......@@ -317,29 +317,47 @@ static gboolean
wp_object_advance_transitions (WpObject * self)
{
WpObjectPrivate *priv = wp_object_get_instance_private (self);
g_autoptr (WpTransition) t = NULL;
/* clear before advancing; a transition may need to schedule
a new call to wp_object_advance_transitions() */
g_clear_pointer (&priv->idle_advnc_source, g_source_unref);
while (TRUE) {
g_autoptr (WpTransition) t = g_weak_ref_get (&priv->ongoing_transition);
if (t) {
wp_transition_advance (t);
if (!wp_transition_get_completed (t))
break;
}
if (g_queue_is_empty (priv->transitions))
break;
/* advance ongoing transition if any */
t = g_weak_ref_get (&priv->ongoing_transition);
if (t) {
wp_transition_advance (t);
if (!wp_transition_get_completed (t))
return G_SOURCE_REMOVE;
}
g_weak_ref_set (&priv->ongoing_transition,
g_queue_pop_head (priv->transitions));
/* set next transition and advance */
if (!g_queue_is_empty (priv->transitions)) {
WpTransition *next = g_queue_pop_head (priv->transitions);
g_weak_ref_set (&priv->ongoing_transition, next);
wp_transition_advance (next);
}
return G_SOURCE_REMOVE;
}
static void
on_transition_completed (WpTransition * transition, GParamSpec * param,
WpObject * self)
{
WpObjectPrivate *priv = wp_object_get_instance_private (self);
/* advance pending transitions */
if (!g_queue_is_empty (priv->transitions) && !priv->idle_advnc_source) {
g_autoptr (WpCore) core = g_weak_ref_get (&priv->core);
g_return_if_fail (core != NULL);
wp_core_idle_add (core, &priv->idle_advnc_source,
G_SOURCE_FUNC (wp_object_advance_transitions), g_object_ref (self),
g_object_unref);
}
}
/*!
* \brief Callback version of wp_object_activate_closure()
*
......@@ -396,6 +414,8 @@ wp_object_activate_closure (WpObject * self,
WP_TYPE_FEATURE_ACTIVATION_TRANSITION, self, cancellable, closure);
wp_transition_set_source_tag (transition, wp_object_activate);
wp_transition_set_data (transition, GUINT_TO_POINTER (features), NULL);
g_signal_connect_object (transition, "notify::completed",
G_CALLBACK (on_transition_completed), self, 0);
g_queue_push_tail (priv->transitions, transition);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment