Commits

Yuya Nishihara  committed d4c1271

thgextensions: call qtsetup() only once, but not for dlgsetup

  • Participants
  • Parent commits 1676973

Comments (0)

Files changed (1)

File hgext/thgextensions.py

 from mercurial.i18n import _
 
 _missing = object()
-_order = []
 
 def _loadextensions(lui):
     lui = lui.copy()
 
     newindex = len(extensions._order)
     extensions.loadall(lui)
-    _order.extend(extensions._order[newindex:])
+    return extensions._order[newindex:]
 
-def _callsetup(funcname, args):
-    for name in _order:
+def _callsetup(extnames, funcname, args):
+    for name in extnames:
         mod = extensions.find(name)
         setup = getattr(mod, funcname, None)
         if setup:
 
 def _wrapqtrun(lui, qtrun):
     class ExQtRunner(qtrun.__class__):
+        _loadedextnames = []
+
         def __call__(self, dlgfunc, ui, *args, **opts):
             # lui contains local-or-repo-specific settings, but ui doesn't
-            _loadextensions(lui)
+            extnames = _loadextensions(lui)
+            self._loadedextnames.extend(extnames)
 
             def exdlgfunc(ui, *args, **opts):
                 # here QApplication is instantiated
-                _callsetup('qtsetup', [lui])
+                _callsetup(extnames, 'qtsetup', [lui])
                 dlg = dlgfunc(ui, *args, **opts)
                 if dlg:
-                    _callsetup('dlgsetup', [dlg])
+                    _callsetup(self._loadedextnames, 'dlgsetup', [dlg])
                 return dlg
             exdlgfunc.func_name = dlgfunc.func_name