From a7bd9f811b97580e6a227cb2d5958e1dfc31ceee Mon Sep 17 00:00:00 2001 From: Giovanni Campagna Date: Mon, 12 Dec 2011 20:36:00 +0100 Subject: [PATCH] PopupMenu: disconnect from 'destroy' signals of destroyed items After an item is destroyed, all its signals were disconnected, except for 'destroy' itself. This could lead to exceptions, if destroy was called more than once on the item. https://bugzilla.gnome.org/show_bug.cgi?id=665680 --- js/ui/popupMenu.js | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/js/ui/popupMenu.js b/js/ui/popupMenu.js index c6dc3df31..93ac2f33e 100644 --- a/js/ui/popupMenu.js +++ b/js/ui/popupMenu.js @@ -939,7 +939,12 @@ const PopupMenuBase = new Lang.Class({ this.emit('activate', menuItem); this.close(true); })); - menuItem.connect('destroy', Lang.bind(this, function(emitter) { + // the weird name is to avoid a conflict with some random property + // the menuItem may have, called destroyId + // (FIXME: in the future it may make sense to have container objects + // like PopupMenuManager does) + menuItem._popupMenuDestroyId = menuItem.connect('destroy', Lang.bind(this, function(menuItem) { + menuItem.disconnect(menuItem._popupMenuDestroyId); menuItem.disconnect(menuItem._activateId); menuItem.disconnect(menuItem._activeChangeId); menuItem.disconnect(menuItem._sensitiveChangeId);