Source

thg-qt-mq / reporeg-connect.diff

# HG changeset patch
# Parent 1617a8c5946250581fbe4ce0d6787ec7f77c8c16
reporegistry: drop reverse dependency from model to parent widget XXX

BUG: __init__() populates all nodes, so connecting updateProgress() after
instantiation does nothing!

diff --git a/tortoisehg/hgqt/reporegistry.py b/tortoisehg/hgqt/reporegistry.py
--- a/tortoisehg/hgqt/reporegistry.py
+++ b/tortoisehg/hgqt/reporegistry.py
@@ -247,6 +247,7 @@ class RepoRegistryView(QDockWidget):
         tv.setModel(repotreemodel.RepoTreeModel(sfile, self,
             showSubrepos=self._isSettingEnabled('showSubrepos'),
             showNetworkSubrepos=self._isSettingEnabled('showNetworkSubrepos')))
+        tv.model().updateProgress.connect(self.updateProgress)
 
         mainframe.layout().addWidget(tv)
 
@@ -357,11 +358,12 @@ class RepoRegistryView(QDockWidget):
     @pyqtSlot()
     def reloadModel(self):
         oldmodel = self.tview.model()
-        self.tview.setModel(
-            repotreemodel.RepoTreeModel(settingsfilename(), self,
+        newmodel = repotreemodel.RepoTreeModel(settingsfilename(), self,
                 self._isSettingEnabled('showSubrepos'),
                 self._isSettingEnabled('showNetworkSubrepos'),
-                self._isSettingEnabled('showShortPaths')))
+                self._isSettingEnabled('showShortPaths'))
+        self.tview.setModel(newmodel)
+        newmodel.updateProgress.connect(self.updateProgress)
         oldmodel.deleteLater()
         self.expand()
         self._reloadModelTimer.stop()
diff --git a/tortoisehg/hgqt/repotreemodel.py b/tortoisehg/hgqt/repotreemodel.py
--- a/tortoisehg/hgqt/repotreemodel.py
+++ b/tortoisehg/hgqt/repotreemodel.py
@@ -77,10 +77,9 @@ class RepoTreeModel(QAbstractItemModel):
 
     updateProgress = pyqtSignal(int, int, QString, QString)
 
-    def __init__(self, filename, parent, showSubrepos=False,
+    def __init__(self, filename, parent=None, showSubrepos=False,
             showNetworkSubrepos=False, showShortPaths=False):
         QAbstractItemModel.__init__(self, parent)
-        self.updateProgress.connect(parent.updateProgress)
         self.showSubrepos = showSubrepos
         self.showNetworkSubrepos = showNetworkSubrepos
         self.showShortPaths = showShortPaths