[gnome-shell/wip/rstrode/rhel-7.9: 80/86] panel: Disconnect destroy signal handler when needed




commit ac91d5f182296772f8c92a0bccba77a29305da4c
Author: Ray Strode <rstrode redhat com>
Date:   Tue Oct 6 10:29:00 2020 -0400

    panel: Disconnect destroy signal handler when needed
    
    The panel corners try to match their style to the buttons closest
    to them. In order to make sure the corner styles stay in sync with
    their neighboring buttons, they connect to the style-changed signals
    of the buttons.
    
    In order to make sure the style-changed signal handler isn't leaked,
    it gets disconnected when the button is destroyed.
    
    Unfortunately, the destroy signal handler connection itself gets leaked!
    
    This commit ensures the destroy signal handler gets disconnected any
    time the neighboring button is re-determined.

 js/ui/panel.js | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)
---
diff --git a/js/ui/panel.js b/js/ui/panel.js
index 55111c50c1..2ac5886972 100644
--- a/js/ui/panel.js
+++ b/js/ui/panel.js
@@ -572,14 +572,20 @@ var PanelCorner = new Lang.Class({
             button = this._findRightmostButton(box);
 
         if (button) {
-            if (this._button && this._buttonStyleChangedSignalId) {
-                this._button.disconnect(this._buttonStyleChangedSignalId);
-                this._button.style = null;
+            if (this._button) {
+                if (this._buttonStyleChangedSignalId) {
+                    this._button.disconnect(this._buttonStyleChangedSignalId);
+                    this._button.style = null;
+                }
+
+                if (this._buttonDestroySignalId) {
+                    this._button.disconnect(this._buttonDestroySignalId);
+                }
             }
 
             this._button = button;
 
-            button.connect('destroy', () => {
+            this._buttonDestroySignalId = button.connect('destroy', () => {
                 if (this._button == button) {
                     this._button = null;
                     this._buttonStyleChangedSignalId = 0;


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