plugins/default: Use local vars for refs

Since the completion callback (on_switch_workspace_effect_complete) sets
priv->tml_switch_workspace1 to NULL, the unref was trying to unref NULL,
and the reffed ClutterTimeline was not getting unreffed.

This could be triggered by rapidly switching workspaces, switching again
before the animation of the initial switch was done.

Found while working on #2038.

Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/2120>
This commit is contained in:
Erik Massop 2021-11-28 00:14:28 +00:00 committed by Marge Bot
parent d5f2ec6f1e
commit 7bb0055acd

View File

@ -903,11 +903,14 @@ kill_switch_workspace (MetaPlugin *plugin)
if (priv->tml_switch_workspace1) if (priv->tml_switch_workspace1)
{ {
g_object_ref (priv->tml_switch_workspace1); g_autoptr (ClutterTimeline) timeline1 = NULL;
clutter_timeline_stop (priv->tml_switch_workspace1); g_autoptr (ClutterTimeline) timeline2 = NULL;
clutter_timeline_stop (priv->tml_switch_workspace2);
g_signal_emit_by_name (priv->tml_switch_workspace1, "completed", NULL); timeline1 = g_object_ref (priv->tml_switch_workspace1);
g_object_unref (priv->tml_switch_workspace1); timeline2 = g_object_ref (priv->tml_switch_workspace2);
finish_timeline (timeline1);
finish_timeline (timeline2);
} }
} }