From 9dc3eceea9c44112c5f1c75e0037b5b241d27feb Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Thu, 12 Oct 2017 12:25:39 -0400 Subject: [PATCH] Modify tray context menu instead of creating a new one Instead of creating a new context menu and setting it with setContextMenu, simply clear and modify the existing context menu. --- gui/qt/__init__.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gui/qt/__init__.py b/gui/qt/__init__.py index 33f08ff7c..4e6377387 100644 --- a/gui/qt/__init__.py +++ b/gui/qt/__init__.py @@ -114,8 +114,12 @@ class ElectrumGui: def build_tray_menu(self): # Avoid immediate GC of old menu when window closed via its action - self.old_menu = self.tray.contextMenu() - m = QMenu() + if self.tray.contextMenu() is None: + m = QMenu() + self.tray.setContextMenu(m) + else: + m = self.tray.contextMenu() + m.clear() for window in self.windows: submenu = m.addMenu(window.wallet.basename()) submenu.addAction(_("Show/Hide"), window.show_or_hide) @@ -123,7 +127,6 @@ class ElectrumGui: m.addAction(_("Dark/Light"), self.toggle_tray_icon) m.addSeparator() m.addAction(_("Exit Electrum"), self.close) - self.tray.setContextMenu(m) def tray_icon(self): if self.dark_icon: