From c1eaf97bc609469024671b86d93df62ab5625087 Mon Sep 17 00:00:00 2001 From: Xavier Claessens Date: Wed, 5 Jun 2013 14:49:14 +0200 Subject: [PATCH] RemoteMenu: Avoid useless signal connections If we are missing more than one action, every time action-added is called, it calls modelChanged() again and re-connect signal for all action still missing. This patch prevent from connecting signals again when doing a refresh because a missing action is now available. All necessary signals have already been connected. https://bugzilla.gnome.org/show_bug.cgi?id=694612 --- js/ui/popupMenu.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js index 1c6399747..9456b79ff 100644 --- a/js/ui/popupMenu.js +++ b/js/ui/popupMenu.js @@ -1826,6 +1826,8 @@ const RemoteMenu = new Lang.Class({ this._actionStateChangeId = this.actionGroup.connect('action-state-changed', Lang.bind(this, this._actionStateChanged)); this._actionEnableChangeId = this.actionGroup.connect('action-enabled-changed', Lang.bind(this, this._actionEnabledChanged)); + + this._skipSignalConnection = false; }, destroy: function() { @@ -1986,13 +1988,16 @@ const RemoteMenu = new Lang.Class({ target.addMenuItem(separator, k+1); k++; } - } else if (changeSignal) { + } else if (changeSignal && !this._skipSignalConnection) { let signalId = this.actionGroup.connect(changeSignal, Lang.bind(this, function(actionGroup, actionName) { actionGroup.disconnect(signalId); if (this._actions[actionName]) return; - // force a full update + /* force a full update but do not reconnect signals if other + * actions are missing */ + this._skipSignalConnection = true; this._modelChanged(model, 0, -1, model.get_n_items(), target); + this._skipSignalConnection = false; })); } }