[polari/wip/fmuellner/combined-gsoc: 98/103] fix watch() method and add checks for the signal id before calling unwatch()
- From: Florian Müllner <fmuellner src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [polari/wip/fmuellner/combined-gsoc: 98/103] fix watch() method and add checks for the signal id before calling unwatch()
- Date: Fri, 22 Jul 2016 13:42:12 +0000 (UTC)
commit 349969834bb4586cfe38bb97ce4b430f955ff947
Author: raresv <rares visalom gmail com>
Date: Wed Jul 20 19:26:27 2016 +0300
fix watch() method and add checks for the signal id before calling unwatch()
src/chatView.js | 5 ++++-
src/userList.js | 2 +-
src/userTracker.js | 6 ++----
3 files changed, 7 insertions(+), 6 deletions(-)
---
diff --git a/src/chatView.js b/src/chatView.js
index 1ab3476..e630c30 100644
--- a/src/chatView.js
+++ b/src/chatView.js
@@ -353,7 +353,10 @@ const ChatView = new Lang.Class({
Lang.bind(this, this._onNickStatusChanged));
this.connect('destroy', () => {
- this._userTracker.unwatchRoomStatus(this._room, this._nickStatusChangedId);
+ if (this._nickStatusChangedId > 0)
+ this._userTracker.unwatchRoomStatus(this._room, this._nickStatusChangedId);
+ this._nickStatusChangedId = 0;
+
this._userTracker = null;
});
},
diff --git a/src/userList.js b/src/userList.js
index dd60742..935e1e9 100644
--- a/src/userList.js
+++ b/src/userList.js
@@ -398,7 +398,7 @@ const UserPopover = new Lang.Class({
/* Nits:
* - Convention is to use 'id', not 'signal'
* - maybe this._roomStatusChangedId is clearer? */
- if (this._localStatusChangedSignal)
+ if (this._localStatusChangedSignal > 0)
this._userTracker.unwatchRoomStatus(this._room, this._localStatusChangedSignal);
/* this desparately needs line breaks, sth like
this._localStatusChangedId =
diff --git a/src/userTracker.js b/src/userTracker.js
index 5ac483d..4ad5f9c 100644
--- a/src/userTracker.js
+++ b/src/userTracker.js
@@ -297,20 +297,18 @@ const UserTracker = new Lang.Class({
watchRoomStatus: function(room, nick, callback) {
this._ensureRoomMappingForRoom(room);
- this._roomMapping.get(room)._handlerMapping.set(this._handlerCounter, {
+ this._roomMapping.get(room)._handlerMapping.set(++this._handlerCounter, {
nickName: nick ? Polari.util_get_basenick(nick) : undefined,
handler: callback
});
- this._handlerCounter++;
-
/* it would be good to follow gsignal semantics and not use 0 as
* a valid handler ID - see the pattern of
if (this._someSignalId > 0)
this._someObject.disconnect(this._someSignalId);
this._someSignalId = 0;
* used all over the place */
- return this._handlerCounter - 1;
+ return this._handlerCounter;
},
unwatchRoomStatus: function(room, handlerID) {
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]