[polari/wip/fmuellner/invalid-object-access: 6/8] roomList: Disconnect channel signals
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/wip/fmuellner/invalid-object-access: 6/8] roomList: Disconnect channel signals
- Date: Sat, 9 Dec 2017 21:16:26 +0000 (UTC)
commit 75c82bf5f65c37bb76c58f2f994d4ec02ce0672c
Author: Florian Müllner <fmuellner gnome org>
Date: Wed Dec 6 01:14:45 2017 +0100
roomList: Disconnect channel signals
When leaving a room, the corresponding row is destroyed immediately to
respond to the user action as fast as possible; actually disconnecting
from the room can take a bit longer, so its quite possible for a channel
to outlive the row, so we need to disconnect any signals to avoid access
to invalidated objects.
src/roomList.js | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
---
diff --git a/src/roomList.js b/src/roomList.js
index 514636c..f7dc284 100644
--- a/src/roomList.js
+++ b/src/roomList.js
@@ -51,6 +51,9 @@ var RoomRow = GObject.registerClass({
this.connect('destroy', () => {
room.disconnect(channelChangedId);
+ this._channelSignals.forEach(id => {
+ room.channel.disconnect(id);
+ });
if (connectionStatusChangedId)
this.account.disconnect(connectionStatusChangedId);
});
@@ -128,13 +131,17 @@ var RoomRow = GObject.registerClass({
}
_onChannelChanged() {
+ this._channelSignals = [];
+
if (!this._room.channel)
return;
this._eventStack.visible_child_name = 'messages';
- this._room.channel.connect('message-received',
- this._updatePending.bind(this));
- this._room.channel.connect('pending-message-removed',
- this._updatePending.bind(this));
+
+ for (let signal of ['message-received', 'pending-message-removed'])
+ this._channelSignals.push(
+ this._room.channel.connect(signal,
+ this._updatePending.bind(this))
+ );
this._updatePending();
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]