[gnome-shell/wip/rstrode/rhel-7.9: 70/86] iconGrid: Clear meta_later callback on destruction




commit fe220f2a0687b2d69a3070ac3859b71b85e4dd43
Author: Ray Strode <rstrode redhat com>
Date:   Mon Jul 22 11:06:30 2019 -0400

    iconGrid: Clear meta_later callback on destruction
    
    The IconGrid code sometimes sets up a callback to be invoked
    later right before being destroyed.
    
    This commit adds a destroy handler to cancel the callback.
    
    https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/628

 js/ui/iconGrid.js | 16 ++++++++++++++--
 1 file changed, 14 insertions(+), 2 deletions(-)
---
diff --git a/js/ui/iconGrid.js b/js/ui/iconGrid.js
index 60f2653f09..9eb9a92817 100644
--- a/js/ui/iconGrid.js
+++ b/js/ui/iconGrid.js
@@ -264,6 +264,8 @@ var IconGrid = new Lang.Class({
 
         this.actor = new St.BoxLayout({ style_class: 'icon-grid',
                                         vertical: true });
+        this._updateIconSizesLaterId = 0;
+
         this._items = [];
         this._clonesAnimating = [];
         // Pulled from CSS, but hardcode some defaults here
@@ -286,6 +288,14 @@ var IconGrid = new Lang.Class({
         this._grid.connect('allocate', this._allocate.bind(this));
         this._grid.connect('actor-added', this._childAdded.bind(this));
         this._grid.connect('actor-removed', this._childRemoved.bind(this));
+        this.connect('destroy', this._onDestroy.bind(this));
+    },
+
+    _onDestroy() {
+        if (this._updateIconSizesLaterId) {
+            Meta.later_remove (this._updateIconSizesLaterId);
+            this._updateIconSizesLaterId = 0;
+        }
     },
 
     _keyFocusIn(actor) {
@@ -777,12 +787,14 @@ var IconGrid = new Lang.Class({
 
             this._updateSpacingForSize(availWidth, availHeight);
         }
-        Meta.later_add(Meta.LaterType.BEFORE_REDRAW,
-                       this._updateIconSizes.bind(this));
+        if (!this._updateIconSizesLaterId)
+            this._updateIconSizesLaterId = Meta.later_add(Meta.LaterType.BEFORE_REDRAW,
+                                                          this._updateIconSizes.bind(this));
     },
 
     // Note that this is ICON_SIZE as used by BaseIcon, not elsewhere in IconGrid; it's a bit messed up
     _updateIconSizes() {
+        this._updateIconSizesLaterId = 0;
         let scale = Math.min(this._fixedHItemSize, this._fixedVItemSize) / Math.max(this._hItemSize, 
this._vItemSize);
         let newIconSize = Math.floor(ICON_SIZE * scale);
         for (let i in this._items) {


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