Commits

Yuya Nishihara committed c624e91

quickop: change HeadlessQuickop to QObject and pass to qtrun as dummy QWidget

Since 3380d68b55d3, Qt's eventloop won't be executed if dlgfunc returns None.

Instead of keeping hidden widget by quickop, now quickop.run returns dummy
QWidget-like object to qtrun. This also fixes temporary appearance of empty
window on drag_copy and drag_move.

Comments (0)

Files changed (1)

tortoisehg/hgqt/quickop.py

             self.files = lfiles
             self.cmd.run(cmdline)
 
-instance = None
-class HeadlessQuickop(QWidget):
+class HeadlessQuickop(QObject):
     def __init__(self, repo, cmdline):
-        QWidget.__init__(self)
+        QObject.__init__(self)
         self.files = cmdline[1:]
         os.chdir(repo.root)
-        self.cmd = cmdui.Runner(True, self)
+        self.cmd = cmdui.Runner(True, None)  # parent must be QWidget or None
         self.cmd.commandFinished.connect(self.commandFinished)
         self.cmd.run(cmdline)
-        self.hide()
 
     def commandFinished(self, ret):
         if ret == 0:
             shlib.shell_notify(self.files)
             sys.exit(0)
 
+    # dummy methods to act as QWidget (see run.qtrun)
+    def show(self):
+        pass
+    def raise_(self):
+        pass
+
 def run(ui, *pats, **opts):
     pats = hglib.canonpaths(pats)
     if opts.get('canonpats'):
     imm = repo.ui.config('tortoisehg', 'immediate', '')
     if command in imm.lower():
         cmdline = [command] + pats
-        global instance
-        instance = HeadlessQuickop(repo, cmdline)
-        return None
+        return HeadlessQuickop(repo, cmdline)
     else:
         return QuickOpDialog(repo, command, pats, None)