[polari/wip/fmuellner/invalid-object-access: 8/8] roomList: Remove timeout on destroy



commit 3e25fe61d726d239f34481b4fd9fd4ceb4ae6a39
Author: Florian Müllner <fmuellner gnome org>
Date:   Fri Dec 8 21:05:33 2017 +0100

    roomList: Remove timeout on destroy
    
    In case joining a room is not instant, we display a progress indication
    after a timeout. If the row is destroyed while the timeout is still
    active, we need to disconnect it to prevent accessing invalidated
    objects.

 src/roomList.js | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)
---
diff --git a/src/roomList.js b/src/roomList.js
index 95c7c2a..6d29a37 100644
--- a/src/roomList.js
+++ b/src/roomList.js
@@ -28,6 +28,7 @@ var RoomRow = GObject.registerClass({
         this._popover = null;
 
         this._popoverVisibleChangedId = 0;
+        this._connectingTimeoutId = 0;
 
         this._icon.gicon = room.icon;
         this._icon.visible = room.icon != null;
@@ -62,6 +63,9 @@ var RoomRow = GObject.registerClass({
             });
             if (connectionStatusChangedId)
                 this.account.disconnect(connectionStatusChangedId);
+            if (this._connectingTimeoutId)
+                Mainloop.source_remove(this._connectingTimeoutId);
+            this._connectingTimeoutId = 0;
         });
 
         this._updatePending();
@@ -113,7 +117,9 @@ var RoomRow = GObject.registerClass({
         let status = this._getConnectionStatus();
         // Show loading indicator if joining a room takes more than 3 seconds
         if (status == Tp.ConnectionStatus.CONNECTED && !this._room.channel)
-            Mainloop.timeout_add_seconds(3, () => {
+            this._connectingTimeoutId = Mainloop.timeout_add_seconds(3, () => {
+                this._connectingTimeoutId = 0;
+
                 if (this._room.channel)
                     return GLib.SOURCE_REMOVE;
                 this._eventStack.visible_child_name = 'connecting';


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