Commit 4fbf29ff authored by verdre's avatar verdre
Browse files

clutter/stage: Use an own flag to prevent relayout reentry in the stage

The CLUTTER_IN_RELAYOUT flag is already set by
clutter_actor_allocate_internal() and it's a bad idea to set and unset
private flags in two places.

With the introduction of the shallow relayout API we also started
setting this flag inside clutter-stage.c on actors that are not the
stage, which seems to cause weird warnings because apparently the flag
is unset by the stage even though Clutter is still inside a
vfunc_allocate() and calling clutter_actor_set_allocation() is still
completely valid.

So stop setting those flags in _clutter_stage_maybe_relayout() and
instead introduce a new private flag for the stage to prevent reentries
(which for example could happen by calling
clutter_actor_get_allocation_box()) during the allocation cycle.

Fixes GNOME/gnome-shell#2710

GNOME/mutter!1266
parent 30d9d196
Pipeline #194774 passed with stages
in 14 minutes and 1 second
......@@ -147,6 +147,7 @@ struct _ClutterStagePrivate
guint min_size_changed : 1;
guint motion_events_enabled : 1;
guint actor_needs_immediate_relayout : 1;
guint in_relayout : 1;
};
enum
......@@ -1241,6 +1242,14 @@ clutter_stage_maybe_relayout (ClutterActor *actor)
CLUTTER_NOTE (ACTOR, ">>> Recomputing layout");
if (priv->in_relayout)
{
g_warning ("Tried to start a relayout while inside an allocation cycle");
return;
}
priv->in_relayout = TRUE;
stolen_list = g_steal_pointer (&priv->pending_relayouts);
for (l = stolen_list; l; l = l->next)
{
......@@ -1258,16 +1267,14 @@ clutter_stage_maybe_relayout (ClutterActor *actor)
CLUTTER_NOTE (ACTOR, " Shallow relayout of actor %s",
_clutter_actor_get_debug_name (queued_actor));
CLUTTER_SET_PRIVATE_FLAGS (queued_actor, CLUTTER_IN_RELAYOUT);
clutter_actor_get_fixed_position (queued_actor, &x, &y);
clutter_actor_allocate_preferred_size (queued_actor, x, y);
CLUTTER_UNSET_PRIVATE_FLAGS (queued_actor, CLUTTER_IN_RELAYOUT);
count++;
}
priv->in_relayout = FALSE;
CLUTTER_NOTE (ACTOR, "<<< Completed recomputing layout of %d subtrees", count);
if (count)
......
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