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



commit 50f00aa750596da523cf6dd5cbc0198e7b931620
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.
    
    https://gitlab.gnome.org/GNOME/polari/issues/32

 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]