Commits

Yuya Nishihara committed 888c8ac

debugtools: wrap qtrun globally instead of workbench.run

I'll fold workbench.run into run.log, but the current dispatcher does not
support command wrapping.

  • Participants
  • Parent commits 8224c08

Comments (0)

Files changed (1)

File contrib/thgdebugtools/core.py

 from PyQt4.QtCore import *
 from PyQt4.QtGui import *
 
-from mercurial import extensions
-from tortoisehg.hgqt import run, workbench
+from tortoisehg.hgqt import run
 
 import dbgutil, infobar, widgets
 
                                      % ', '.join(map(str, gc.get_count())))
         self._gcEnabledAction.setChecked(self.isGcEnabled())
 
-def _workbenchrun(orig, ui, *pats, **opts):
-    dlg = orig(ui, *pats, **opts)
-    m = dlg.menuBar().addMenu('&Debug')
-    DebugMenuActions(m, parent=dlg)
-    return dlg
+def extsetup(ui):
+    class dbgqtrun(run.qtrun.__class__):
+        def _createdialog(self, dlgfunc, ui, args, opts):
+            dlg = super(dbgqtrun, self)._createdialog(dlgfunc, ui, args, opts)
+            if isinstance(dlg, QMainWindow):
+                m = dlg.menuBar().addMenu('&Debug')
+                DebugMenuActions(m, parent=dlg)
+            return dlg
 
-def extsetup(ui):
-    extensions.wrapfunction(workbench, 'run', _workbenchrun)
+    run.qtrun.__class__ = dbgqtrun