URI: 
       tQT handler improvements - electrum - Electrum Bitcoin wallet
  HTML git clone https://git.parazyd.org/electrum
   DIR Log
   DIR Files
   DIR Refs
   DIR Submodules
       ---
   DIR commit 9cf0a9720fac7020486530462319a6b61fae73a2
   DIR parent 83cc5e2001a1413920bd3afe61211d9f7246c039
  HTML Author: Neil Booth <kyuupichan@gmail.com>
       Date:   Sun, 10 Jan 2016 12:16:34 +0900
       
       QT handler improvements
       
       Now we have the top_level_window() function, stop using the window
       stack.
       
       Diffstat:
         M gui/qt/util.py                      |       3 ++-
         M plugins/trezor/qt_generic.py        |      28 ++++++++++------------------
       
       2 files changed, 12 insertions(+), 19 deletions(-)
       ---
   DIR diff --git a/gui/qt/util.py b/gui/qt/util.py
       t@@ -159,7 +159,8 @@ class MessageBoxMixin(object):
            def top_level_window(self, window=None):
                window = window or self
                for n, child in enumerate(window.children()):
       -            if isinstance(child, WindowModalDialog):
       +            # Test for visibility as old closed dialogs may not be GC-ed
       +            if isinstance(child, WindowModalDialog) and child.isVisible():
                        return self.top_level_window(child)
                return window
        
   DIR diff --git a/plugins/trezor/qt_generic.py b/plugins/trezor/qt_generic.py
       t@@ -31,13 +31,15 @@ class QtHandler(PrintError):
                win.connect(win, SIGNAL('pin_dialog'), self.pin_dialog)
                win.connect(win, SIGNAL('passphrase_dialog'), self.passphrase_dialog)
                win.connect(win, SIGNAL('word_dialog'), self.word_dialog)
       -        self.window_stack = [win]
                self.win = win
                self.pin_matrix_widget_class = pin_matrix_widget_class
                self.device = device
                self.dialog = None
                self.done = threading.Event()
        
       +    def top_level_window(self):
       +        return self.win.top_level_window()
       +
            def watching_only_changed(self):
                self.win.emit(SIGNAL('watching_only_changed'))
        
       t@@ -71,7 +73,7 @@ class QtHandler(PrintError):
            def pin_dialog(self, msg):
                # Needed e.g. when resetting a device
                self.clear_dialog()
       -        dialog = WindowModalDialog(self.window_stack[-1], _("Enter PIN"))
       +        dialog = WindowModalDialog(self.top_level_window(), _("Enter PIN"))
                matrix = self.pin_matrix_widget_class()
                vbox = QVBoxLayout()
                vbox.addWidget(QLabel(msg))
       t@@ -83,7 +85,7 @@ class QtHandler(PrintError):
                self.done.set()
        
            def passphrase_dialog(self, msg):
       -        d = PasswordDialog(self.window_stack[-1], None, msg,
       +        d = PasswordDialog(self.top_level_window(), None, msg,
                                   PasswordDialog.PW_PASSPHRASE)
                confirmed, p, passphrase = d.run()
                if confirmed:
       t@@ -92,7 +94,7 @@ class QtHandler(PrintError):
                self.done.set()
        
            def word_dialog(self, msg):
       -        dialog = WindowModalDialog(self.window_stack[-1], "")
       +        dialog = WindowModalDialog(self.top_level_window(), "")
                hbox = QHBoxLayout(dialog)
                hbox.addWidget(QLabel(msg))
                text = QLineEdit()
       t@@ -100,7 +102,7 @@ class QtHandler(PrintError):
                text.returnPressed.connect(dialog.accept)
                hbox.addWidget(text)
                hbox.addStretch(1)
       -        if not self.exec_dialog(dialog):
       +        if not dialog.exec_():
                    return None
                self.word = unicode(text.text())
                self.done.set()
       t@@ -109,8 +111,7 @@ class QtHandler(PrintError):
                # Called more than once during signing, to confirm output and fee
                self.clear_dialog()
                title = _('Please check your %s device') % self.device
       -        self.dialog = dialog = WindowModalDialog(self.window_stack[-1], title)
       -        self.window_stack.append(dialog)
       +        self.dialog = dialog = WindowModalDialog(self.top_level_window(), title)
                l = QLabel(msg)
                vbox = QVBoxLayout(dialog)
                if cancel_callback:
       t@@ -120,21 +121,13 @@ class QtHandler(PrintError):
                dialog.show()
        
            def error_dialog(self, msg):
       -        self.win.show_error(msg, parent=self.window_stack[-1])
       +        self.win.show_error(msg, parent=self.top_level_window())
        
            def clear_dialog(self):
                if self.dialog:
                    self.dialog.accept()
       -            self.window_stack.remove(self.dialog)
                    self.dialog = None
        
       -    def exec_dialog(self, dialog):
       -        self.window_stack.append(dialog)
       -        try:
       -            return dialog.exec_()
       -        finally:
       -            assert dialog == self.window_stack.pop()
       -
            def query_choice(self, msg, labels):
                return self.win.query_choice(msg, labels)
        
       t@@ -263,8 +256,7 @@ def qt_plugin_class(base_plugin_class):
            def settings_dialog(self, window):
                hid_id = self.choose_device(window)
                if hid_id:
       -            dialog = SettingsDialog(window, self, hid_id)
       -            window.wallet.handler.exec_dialog(dialog)
       +            SettingsDialog(window, self, hid_id).exec_()
        
            def choose_device(self, window):
                '''This dialog box should be usable even if the user has