[gnome-shell] UserWidget: replace vfunc_destroy override with a signal connection



commit 98b50fd9423e574b96ad23e4269fadb2040657f0
Author: Giovanni Campagna <gcampagna src gnome org>
Date:   Mon Dec 2 23:50:45 2013 +0100

    UserWidget: replace vfunc_destroy override with a signal connection
    
    The destroy vfunc might be called during object finalization, and
    we can't call any JS from a GC finalizer, so we use a signal
    connection instead, as that is removed by GObject the first time
    the object is disposed.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=719730

 js/ui/userWidget.js |   11 ++++++++---
 1 files changed, 8 insertions(+), 3 deletions(-)
---
diff --git a/js/ui/userWidget.js b/js/ui/userWidget.js
index e8574c4..b16f9e3 100644
--- a/js/ui/userWidget.js
+++ b/js/ui/userWidget.js
@@ -79,9 +79,16 @@ const UserWidgetLabel = new Lang.Class({
         this._userLoadedId = this._user.connect('notify::is-loaded', Lang.bind(this, this._updateUser));
         this._userChangedId = this._user.connect('changed', Lang.bind(this, this._updateUser));
         this._updateUser();
+
+        // We can't override the destroy vfunc because that might be called during
+        // object finalization, and we can't call any JS inside a GC finalize callback,
+        // so we use a signal, that will be disconnected by GObject the first time
+        // the actor is destroyed (which is guaranteed to be as part of a normal
+        // destroy() call from JS, possibly from some ancestor)
+        this.connect('destroy', Lang.bind(this, this._onDestroy));
     },
 
-    vfunc_destroy: function() {
+    _onDestroy: function() {
         if (this._userLoadedId != 0) {
             this._user.disconnect(this._userLoadedId);
             this._userLoadedId = 0;
@@ -91,8 +98,6 @@ const UserWidgetLabel = new Lang.Class({
             this._user.disconnect(this._userChangedId);
             this._userChangedId = 0;
         }
-
-        this.parent();
     },
 
     vfunc_allocate: function(box, flags) {


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