Commits

Yuya Nishihara committed f52050f

simply own dialogs by workbench

Comments (0)

Files changed (3)

qtapp-ownbywb.diff

+# HG changeset patch
+# Parent 06ecd157c32d11d3262a1c2639ee1872c0c69d05
+
+diff --git a/tortoisehg/hgqt/qtapp.py b/tortoisehg/hgqt/qtapp.py
+--- a/tortoisehg/hgqt/qtapp.py
++++ b/tortoisehg/hgqt/qtapp.py
+@@ -290,7 +290,6 @@ class QtRunner(QObject):
+         self._repomanager = None
+         self._reporeleaser = None
+         self._workbench = None
+-        self._dialogs = {}  # dlg: reporoot
+ 
+     def __call__(self, dlgfunc, ui, *args, **opts):
+         if self._mainapp:
+@@ -380,21 +379,16 @@ class QtRunner(QObject):
+         if not dlg:
+             return
+ 
+-        self._dialogs[dlg] = reporoot  # avoid garbage collection
+         dlg.setAttribute(Qt.WA_DeleteOnClose)
+-        # NOTE: Somehow `destroyed` signal doesn't emit the original obj.
+-        # So we cannot write `dlg.destroyed.connect(self._forgetdialog)`.
+-        dlg.destroyed.connect(lambda: self._forgetdialog(dlg))
+         if reporoot:
+             dlg.destroyed[()].connect(self._reporeleaser.map)
+             self._reporeleaser.setMapping(dlg, reporoot)
++        if dlg is not self._workbench and not dlg.parent():
++            # avoid garbage collection
++            assert self._workbench
++            dlg.setParent(self._workbench, dlg.windowFlags())
+         dlg.show()
+ 
+-    def _forgetdialog(self, dlg):
+-        """forget the dialog to be garbage collectable"""
+-        assert dlg in self._dialogs
+-        reporoot = self._dialogs.pop(dlg)
+-
+     def createWorkbench(self):
+         """Create Workbench window and keep single reference"""
+         assert self._ui and self._mainapp and self._repomanager

qtapp-sigmap-release.diff

+# HG changeset patch
+# Parent 19bf531fee81b13516db9b769fccc5024a7f8e5c
+
+diff --git a/tortoisehg/hgqt/qtapp.py b/tortoisehg/hgqt/qtapp.py
+--- a/tortoisehg/hgqt/qtapp.py
++++ b/tortoisehg/hgqt/qtapp.py
+@@ -288,6 +288,7 @@ class QtRunner(QObject):
+         self._exccatcher = None
+         self._server = None
+         self._repomanager = None
++        self._reporeleaser = None
+         self._workbench = None
+         self._dialogs = {}  # dlg: reporoot
+ 
+@@ -316,6 +317,8 @@ class QtRunner(QObject):
+         self._mainapp.setWindowIcon(qtlib.geticon('thg-logo'))
+ 
+         self._repomanager = thgrepo.RepoManager(ui, self)
++        self._reporeleaser = mapper = QSignalMapper(self)
++        mapper.mapped[unicode].connect(self._repomanager.releaseRepoAgent)
+ 
+         dlg, reporoot = self._createdialog(dlgfunc, args, opts)
+         try:
+@@ -382,14 +385,15 @@ class QtRunner(QObject):
+         # NOTE: Somehow `destroyed` signal doesn't emit the original obj.
+         # So we cannot write `dlg.destroyed.connect(self._forgetdialog)`.
+         dlg.destroyed.connect(lambda: self._forgetdialog(dlg))
++        if reporoot:
++            dlg.destroyed[()].connect(self._reporeleaser.map)
++            self._reporeleaser.setMapping(dlg, reporoot)
+         dlg.show()
+ 
+     def _forgetdialog(self, dlg):
+         """forget the dialog to be garbage collectable"""
+         assert dlg in self._dialogs
+         reporoot = self._dialogs.pop(dlg)
+-        if reporoot:
+-            self._repomanager.releaseRepoAgent(reporoot)
+ 
+     def createWorkbench(self):
+         """Create Workbench window and keep single reference"""
+diff --git a/tortoisehg/hgqt/thgrepo.py b/tortoisehg/hgqt/thgrepo.py
+--- a/tortoisehg/hgqt/thgrepo.py
++++ b/tortoisehg/hgqt/thgrepo.py
+@@ -454,6 +454,7 @@ class RepoManager(QObject):
+             self._sigmappers.append(mapper)
+             QObject.connect(mapper, SIGNAL('mapped(QString)'), self, slot)
+ 
++    @pyqtSlot(unicode)
+     def openRepoAgent(self, path):
+         """Return RepoAgent for the specified path and increment refcount"""
+         path = _normreporoot(path)
+@@ -477,6 +478,7 @@ class RepoManager(QObject):
+         self.repositoryOpened.emit(path)
+         return agent
+ 
++    @pyqtSlot(unicode)
+     def releaseRepoAgent(self, path):
+         """Decrement refcount of RepoAgent and close it if possible"""
+         path = _normreporoot(path)
+qtapp-deleteonclose.diff
+qtapp-sigmap-release.diff
+qtapp-ownbywb.diff
 dlgkeeper-usemapper.diff
 dlgkeeper-intser.diff
 dlgkeeper-destroyed.diff
 dlgkeeper-serbased.diff
 dlgkeeper-lessmapping.diff
-qtapp-deleteonclose.diff
 qtapp-sigmapper.diff
 delete-dummyfinished.diff
 modeltest-move.diff