electrum

Electrum Bitcoin wallet
git clone https://git.parazyd.org/electrum
Log | Files | Refs | Submodules

commit 985fe24f1809adc1b4417a2c4f0ba7159d56249b
parent a03449c1be97eda1c4f6e32195417c6658321171
Author: SomberNight <somber.night@protonmail.com>
Date:   Sun,  8 Apr 2018 15:13:12 +0200

fix #4240

Diffstat:
Mgui/qt/main_window.py | 8+++++---
Mgui/qt/util.py | 16++++++++++------
2 files changed, 15 insertions(+), 9 deletions(-)

diff --git a/gui/qt/main_window.py b/gui/qt/main_window.py @@ -254,10 +254,12 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): def pop_top_level_window(self, window): self.tl_windows.remove(window) - def top_level_window(self): + def top_level_window(self, test_func=None): '''Do the right thing in the presence of tx dialog windows''' override = self.tl_windows[-1] if self.tl_windows else None - return self.top_level_window_recurse(override) + if override and test_func and not test_func(override): + override = None # only override if ok for test_func + return self.top_level_window_recurse(override, test_func) def diagnostic_name(self): return "%s/%s" % (PrintError.diagnostic_name(self), @@ -1613,7 +1615,7 @@ class ElectrumWindow(QMainWindow, MessageBoxMixin, PrintError): return status, msg # Capture current TL window; override might be removed on return - parent = self.top_level_window() + parent = self.top_level_window(lambda win: isinstance(win, MessageBoxMixin)) def broadcast_done(result): # GUI thread diff --git a/gui/qt/util.py b/gui/qt/util.py @@ -165,17 +165,21 @@ class CancelButton(QPushButton): self.clicked.connect(dialog.reject) class MessageBoxMixin(object): - def top_level_window_recurse(self, window=None): + def top_level_window_recurse(self, window=None, test_func=None): window = window or self classes = (WindowModalDialog, QMessageBox) + if test_func is None: + test_func = lambda x: True for n, child in enumerate(window.children()): - # Test for visibility as old closed dialogs may not be GC-ed - if isinstance(child, classes) and child.isVisible(): - return self.top_level_window_recurse(child) + # Test for visibility as old closed dialogs may not be GC-ed. + # Only accept children that confirm to test_func. + if isinstance(child, classes) and child.isVisible() \ + and test_func(child): + return self.top_level_window_recurse(child, test_func=test_func) return window - def top_level_window(self): - return self.top_level_window_recurse() + def top_level_window(self, test_func=None): + return self.top_level_window_recurse(test_func) def question(self, msg, parent=None, title=None, icon=None): Yes, No = QMessageBox.Yes, QMessageBox.No