Commits

Yuya Nishihara committed 63addd4

add extension to test issue2513

  • Participants
  • Parent commits c98a02b

Comments (0)

Files changed (1)

File hgext/thgissue2513.py

+# thgissue2513.py - force bundled Qt plugins
+"""force bundled Qt plugin (issue2513)
+
+Usage::
+
+    [extensions]
+    thgissue2513 = path/to/hgext/thgissue2513.py
+"""
+
+import os, sys
+
+def _setuplibpath(app):
+    print 'Qt Library Paths (original):'
+    print list(app.libraryPaths())
+    # http://qt-project.org/doc/qt-4.8/deployment-windows.html#qt-plugins
+    if os.name == 'nt' and getattr(sys, 'frozen', False):
+        print 'Add path:', app.applicationDirPath()
+        app.addLibraryPath(app.applicationDirPath())
+        print 'Qt Library Paths (added):'
+        print list(app.libraryPaths())
+
+def uisetup(ui):
+    run = sys.modules.get('tortoisehg.hgqt.run')
+    if not run:
+        return  # not a TortoiseHg
+
+    class ExQtRunner(run.qtrun.__class__):
+        def __call__(self, dlgfunc, ui, *args, **opts):
+            def exdlgfunc(ui, *args, **opts):
+                # here QApplication is instantiated
+                _setuplibpath(self._mainapp)
+                return dlgfunc(ui, *args, **opts)
+            exdlgfunc.func_name = dlgfunc.func_name
+            return super(ExQtRunner, self).__call__(exdlgfunc, ui, *args, **opts)
+
+    run.qtrun.__class__ = ExQtRunner