[polari/wip/fmuellner/invalid-object-access: 5/10] chatView: Disconnect ::room-focus-changed



commit 1bbfef32a917f91a847d02cd48ee0b00499c6789
Author: Florian Müllner <fmuellner gnome org>
Date:   Wed Dec 6 00:35:13 2017 +0100

    chatView: Disconnect ::room-focus-changed
    
    The chat log is not bound to the life time of the application, so
    we need to disconnect any handlers to avoid accessing invalidated
    objects.
    
    https://gitlab.gnome.org/GNOME/polari/issues/32

 src/chatView.js | 9 +++++++--
 1 file changed, 7 insertions(+), 2 deletions(-)
---
diff --git a/src/chatView.js b/src/chatView.js
index fd4e6ba..09cf902 100644
--- a/src/chatView.js
+++ b/src/chatView.js
@@ -364,8 +364,9 @@ var ChatView = GObject.registerClass({
         this._app = Gio.Application.get_default();
         DropTargetIface.addTargets(this, this._view);
 
-        this._app.connect('room-focus-changed',
-                          this._checkMessages.bind(this));
+        this._roomFocusChangedId =
+            this._app.connect('room-focus-changed',
+                              this._checkMessages.bind(this));
 
         this._hoverCursor = Gdk.Cursor.new_from_name(this.get_display(),
                                                      'pointer');
@@ -510,6 +511,10 @@ var ChatView = GObject.registerClass({
             this._room.disconnect(this._roomSignals[i]);
         this._roomSignals = [];
 
+        if (this._roomFocusChangedId)
+            this._app.disconnect(this._roomFocusChangedId);
+        this._roomFocusChangedId = 0;
+
         if (this._backlogTimeoutId)
             Mainloop.source_remove(this._backlogTimeoutId);
         this._backlogTimeoutId = 0;


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