[polari/wip/fmuellner/invalid-object-access: 6/10] roomListRow: Disconnect room signals



commit 705aeaaa563ab8767b981bbc6fb8945a6f225d7f
Author: Florian Müllner <fmuellner gnome org>
Date:   Wed Dec 6 00:37:30 2017 +0100

    roomListRow: Disconnect room signals
    
    Room list rows are destroyed from a ::room-removed handler, which means
    it has a slightly shorter life time than the corresponding room; without
    disconnecting
    
    https://gitlab.gnome.org/GNOME/polari/issues/32

 src/roomList.js | 16 +++++++++++-----
 1 file changed, 11 insertions(+), 5 deletions(-)
---
diff --git a/src/roomList.js b/src/roomList.js
index 6635b67..514636c 100644
--- a/src/roomList.js
+++ b/src/roomList.js
@@ -34,20 +34,26 @@ var RoomRow = GObject.registerClass({
                                this._onButtonRelease.bind(this));
         this.connect('key-press-event', this._onKeyPress.bind(this));
 
-        room.connect('notify::channel', this._onChannelChanged.bind(this));
         room.bind_property('display-name', this._roomLabel, 'label',
                            GObject.BindingFlags.SYNC_CREATE);
 
+        let channelChangedId =
+            room.connect('notify::channel', this._onChannelChanged.bind(this));
+
+        let connectionStatusChangedId = 0;
+
         if (this._room.type == Tp.HandleType.ROOM) {
-            let connectionStatusChangedId =
+            connectionStatusChangedId =
                 this.account.connect('notify::connection-status',
                                      this._onConnectionStatusChanged.bind(this));
             this._onConnectionStatusChanged();
+        }
 
-            this.connect('destroy', () => {
+        this.connect('destroy', () => {
+            room.disconnect(channelChangedId);
+            if (connectionStatusChangedId)
                 this.account.disconnect(connectionStatusChangedId);
-            });
-        }
+        });
 
         this._updatePending();
         this._onChannelChanged();


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