Blame SOURCES/fix-double-disposed-backgrounds.patch

12a93f
From 49d066234f9f528122bb40c5144b40d8b19a0071 Mon Sep 17 00:00:00 2001
12a93f
From: rpm-build <rpm-build>
12a93f
Date: Mon, 22 Aug 2022 12:52:19 +0200
12a93f
Subject: [PATCH] Background: Avoid double dispose and actors recreations
12a93f
12a93f
Subject: [PATCH 1/2] background: Use Garbage Collector to dispose background:
12a93f
12a93f
The same Meta.Background could be used by multiple instances of background
12a93f
actors, and so should not be disposed when the actor using it is destroyed.
12a93f
12a93f
Instead of calling `run_dispose` directly on it, just nullify the reference
12a93f
on destroy method, leaving the job of doing the proper disposition to the
12a93f
gabage collector that keeps the proper reference count on the Meta.Background.
12a93f
12a93f
Fixes https://gitlab.gnome.org/GNOME/gnome-shell/issues/501
12a93f
12a93f
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/558
12a93f
12a93f
Subject: [PATCH 2/2] background: Group 'changed' signal emission
12a93f
12a93f
Background is monitoring the whole `org.gnome.desktop.background` gsettings keys
12a93f
for changes connecting to the non-specialized 'changed' signal and re-emitting
12a93f
this as-is.
12a93f
This means that when the background is changed via control-center, we get
12a93f
multiple 'changed' signal events from GSettings, and for each one of this we
12a93f
recreate a Background and a BackgroundActor.
12a93f
12a93f
Avoid this by using an idle to delay the emission of the 'changed' signal
12a93f
grouping the events.
12a93f
12a93f
https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/558
12a93f
---
12a93f
 js/ui/background.js | 26 +++++++++++++++++++++-----
12a93f
 1 file changed, 21 insertions(+), 5 deletions(-)
12a93f
12a93f
diff --git a/js/ui/background.js b/js/ui/background.js
12a93f
index 06e0388..2a404ae 100644
12a93f
--- a/js/ui/background.js
12a93f
+++ b/js/ui/background.js
12a93f
@@ -257,14 +257,15 @@ var Background = class Background {
12a93f
                 this._refreshAnimation();
12a93f
             });
12a93f
 
12a93f
-        this._settingsChangedSignalId = this._settings.connect('changed', () => {
12a93f
-            this.emit('changed');
12a93f
-        });
12a93f
+        this._settingsChangedSignalId =
12a93f
+            this._settings.connect('changed', this._emitChangedSignal.bind(this));
12a93f
 
12a93f
         this._load();
12a93f
     }
12a93f
 
12a93f
     destroy() {
12a93f
+        this.background = null;
12a93f
+
12a93f
         this._cancellable.cancel();
12a93f
         this._removeAnimationTimeout();
12a93f
 
12a93f
@@ -288,6 +289,22 @@ var Background = class Background {
12a93f
         if (this._settingsChangedSignalId != 0)
12a93f
             this._settings.disconnect(this._settingsChangedSignalId);
12a93f
         this._settingsChangedSignalId = 0;
12a93f
+
12a93f
+        if (this._changedIdleId) {
12a93f
+            GLib.source_remove(this._changedIdleId);
12a93f
+            this._changedIdleId = 0;
12a93f
+        }
12a93f
+    }
12a93f
+
12a93f
+    _emitChangedSignal() {
12a93f
+        if (this._changedIdleId)
12a93f
+            return;
12a93f
+
12a93f
+        this._changedIdleId = GLib.idle_add(GLib.PRIORITY_DEFAULT, () => {
12a93f
+            this._changedIdleId = 0;
12a93f
+            this.emit('changed');
12a93f
+            return GLib.SOURCE_REMOVE;
12a93f
+        });
12a93f
     }
12a93f
 
12a93f
     updateResolution() {
12a93f
@@ -343,7 +360,7 @@ var Background = class Background {
12a93f
                                                if (changedFile.equal(file)) {
12a93f
                                                    let imageCache = Meta.BackgroundImageCache.get_default();
12a93f
                                                    imageCache.purge(changedFile);
12a93f
-                                                   this.emit('changed');
12a93f
+                                                   this._emitChangedSignal();
12a93f
                                                }
12a93f
                                            });
12a93f
         this._fileWatches[key] = signalId;
12a93f
@@ -699,7 +716,6 @@ var BackgroundManager = class BackgroundManager {
12a93f
                            time: FADE_ANIMATION_TIME,
12a93f
                            transition: 'easeOutQuad',
12a93f
                            onComplete() {
12a93f
-                               oldBackgroundActor.background.run_dispose();
12a93f
                                oldBackgroundActor.destroy();
12a93f
                            }
12a93f
                          });
12a93f
-- 
12a93f
2.35.3
12a93f