[mutter] plugins/default: Hold reference on timelines while stopping



commit fb6e2743ec64f8445067b42784188faf9286df40
Author: Jonas Ådahl <jadahl gmail com>
Date:   Mon Oct 7 19:54:31 2019 +0200

    plugins/default: Hold reference on timelines while stopping
    
    We get implicit, thus auto-removed, transitions, then manage them
    manually by stopping them and emitting "completed" signals. This doesn't
    work since they are removed and freed when stopped. To be able to emit
    the "completed" signal, hold a reference while stopping, so that we
    still can emit the signal as before.
    
    https://gitlab.gnome.org/GNOME/mutter/merge_requests/828

 src/compositor/plugins/default.c | 26 ++++++++++++++------------
 1 file changed, 14 insertions(+), 12 deletions(-)
---
diff --git a/src/compositor/plugins/default.c b/src/compositor/plugins/default.c
index 089c6299d..e7203ee11 100644
--- a/src/compositor/plugins/default.c
+++ b/src/compositor/plugins/default.c
@@ -811,6 +811,15 @@ hide_tile_preview (MetaPlugin *plugin)
   clutter_actor_hide (preview->actor);
 }
 
+static void
+finish_timeline (ClutterTimeline *timeline)
+{
+  g_object_ref (timeline);
+  clutter_timeline_stop (timeline);
+  g_signal_emit_by_name (timeline, "completed", NULL);
+  g_object_unref (timeline);
+}
+
 static void
 kill_switch_workspace (MetaPlugin     *plugin)
 {
@@ -818,9 +827,11 @@ kill_switch_workspace (MetaPlugin     *plugin)
 
   if (priv->tml_switch_workspace1)
     {
+      g_object_ref (priv->tml_switch_workspace1);
       clutter_timeline_stop (priv->tml_switch_workspace1);
       clutter_timeline_stop (priv->tml_switch_workspace2);
       g_signal_emit_by_name (priv->tml_switch_workspace1, "completed", NULL);
+      g_object_unref (priv->tml_switch_workspace1);
     }
 }
 
@@ -833,22 +844,13 @@ kill_window_effects (MetaPlugin      *plugin,
   apriv = get_actor_private (window_actor);
 
   if (apriv->tml_minimize)
-    {
-      clutter_timeline_stop (apriv->tml_minimize);
-      g_signal_emit_by_name (apriv->tml_minimize, "completed", NULL);
-    }
+    finish_timeline (apriv->tml_minimize);
 
   if (apriv->tml_map)
-    {
-      clutter_timeline_stop (apriv->tml_map);
-      g_signal_emit_by_name (apriv->tml_map, "completed", NULL);
-    }
+    finish_timeline (apriv->tml_map);
 
   if (apriv->tml_destroy)
-    {
-      clutter_timeline_stop (apriv->tml_destroy);
-      g_signal_emit_by_name (apriv->tml_destroy, "completed", NULL);
-    }
+    finish_timeline (apriv->tml_destroy);
 }
 
 static const MetaPluginInfo *


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]