Commits

Yuya Nishihara committed d0ae7b9

work around reverse dependency from model to parent

Comments (0)

Files changed (3)

reporeg-connect.diff

 # HG changeset patch
-# Parent 13661eb892516e91cbdebe88bbe81bfd7484a31a
-reporegistry: drop reverse dependency from model to parent widget
+# 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

reporeg-dummystart.diff

 # HG changeset patch
-# Parent e26cce3b5b94d97f0adac1d0e2639f114dd47401
+# Parent 1617a8c5946250581fbe4ce0d6787ec7f77c8c16
 reporegistry: move responsibility of initial reloadModel to workbench
 
 Because loading RepoTreeModel is expensive, it shouldn't be done by the
 diff --git a/tortoisehg/hgqt/reporegistry.py b/tortoisehg/hgqt/reporegistry.py
 --- a/tortoisehg/hgqt/reporegistry.py
 +++ b/tortoisehg/hgqt/reporegistry.py
-@@ -243,11 +243,11 @@ class RepoRegistryView(QDockWidget):
+@@ -243,10 +243,11 @@ class RepoRegistryView(QDockWidget):
          self.contextmenu = QMenu(self)
          self.tview = tv = RepoTreeView(self)
  
 -        tv.setModel(repotreemodel.RepoTreeModel(sfile, self,
 -            showSubrepos=self._isSettingEnabled('showSubrepos'),
 -            showNetworkSubrepos=self._isSettingEnabled('showNetworkSubrepos')))
--        tv.model().updateProgress.connect(self.updateProgress)
 +        # start with dummy because loading RepoTreeModel is expensive;
 +        # the owner should call reloadModel() later
 +        dummymodel = repotreemodel.RepoTreeModel(filename=None, parent=self)
  
          mainframe.layout().addWidget(tv)
  
-@@ -267,10 +267,11 @@ class RepoRegistryView(QDockWidget):
+@@ -266,10 +267,11 @@ class RepoRegistryView(QDockWidget):
          # anytime it is modified by another thg instance
          # Note that we must make sure that the settings file exists before
          # setting thefile watcher
          self.watcher = QFileSystemWatcher(self)
          self.watcher.addPath(sfile)
          self._reloadModelTimer = QTimer(self, interval=2000, singleShot=True)
-@@ -279,11 +280,6 @@ class RepoRegistryView(QDockWidget):
+@@ -278,11 +280,6 @@ class RepoRegistryView(QDockWidget):
          self._activeTabRepo = None
  
          self._loadSettings()
          self._updateColumnVisibility()
  
      def _loadSettings(self):
-@@ -295,9 +291,6 @@ class RepoRegistryView(QDockWidget):
+@@ -294,9 +291,6 @@ class RepoRegistryView(QDockWidget):
              action.setChecked(s.value(key, defaultmap[key]).toBool())
          s.endGroup()
  
      def _saveSettings(self):
          s = QSettings()
          s.beginGroup('Workbench')  # for compatibility with old release
-@@ -366,6 +359,7 @@ class RepoRegistryView(QDockWidget):
-         newmodel.updateProgress.connect(self.updateProgress)
+@@ -364,6 +358,7 @@ class RepoRegistryView(QDockWidget):
+                 self._isSettingEnabled('showShortPaths')))
          oldmodel.deleteLater()
          self.expand()
 +        self._updateColumnVisibility()  # resize columns to fit
          self._reloadModelTimer.stop()
  
      def _getItemAndAncestors(self, it):
+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,13 @@ 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)
++        if parent:
++            # TODO: fix reverse dependency to parent; currently updateProgress
++            # is emitted during __init__().
++            self.updateProgress.connect(parent.updateProgress)
+         self.showSubrepos = showSubrepos
+         self.showNetworkSubrepos = showNetworkSubrepos
+         self.showShortPaths = showShortPaths
 diff --git a/tortoisehg/hgqt/workbench.py b/tortoisehg/hgqt/workbench.py
 --- a/tortoisehg/hgqt/workbench.py
 +++ b/tortoisehg/hgqt/workbench.py
 reporeg-loadsettings.diff
 reporeg-settings-begin.diff
 reporeg-modsettingtimer.diff
-reporeg-connect.diff
 reporeg-dummystart.diff
 wb-createserver.diff
 wb-launch.diff
 no-processevent.diff
 wb-run-timeit.diff
 wb-time-constructor.diff
+reporeg-connect.diff
 reporeg-cache-exp.diff
 annotate-new-icon.diff
 sync-exc.diff