1. Yuya Nishihara
  2. thg-work


Yuya Nishihara  committed 9018371

repowidget: keep reference to active infobar

I'll remove _infobarlayout in next commit, so it needs to manage reference

  • Participants
  • Parent commits 2a8e8f5
  • Branches default

Comments (0)

Files changed (1)

File tortoisehg/hgqt/repowidget.py

View file
  • Ignore whitespace
         self._infobarlayout = QVBoxLayout()  # placeholder for InfoBar
+        self._activeInfoBar = None
         self.filterbar = RepoFilterBar(self.repo, self)
         if not cleared:
         w = cls(*args, **kwargs)
+        w.finished.connect(self._freeInfoBar)
+        self._activeInfoBar = w
         self._infobarlayout.insertWidget(0, w)
         w.setFocus()  # to handle key press by InfoBar
         return w
     def clearInfoBar(self, priority=None):
         """Close current infobar if available; return True if got empty"""
         it = self._infobarlayout.itemAt(0)
-        if not it:
+        assert it is self._activeInfoBar or it.widget() is self._activeInfoBar
+        if not self._activeInfoBar:
             return True
-        if priority is None or it.widget().infobartype <= priority:
+        if priority is None or self._activeInfoBar.infobartype <= priority:
             # removes current infobar explicitly, because close() seems to
             # delay deletion until next eventloop.
-            it.widget().close()
+            self._activeInfoBar.finished.disconnect(self._freeInfoBar)
+            self._activeInfoBar.close()
+            self._freeInfoBar()  # call directly in case of event delay
             return True
             return False
+    @pyqtSlot()
+    def _freeInfoBar(self):
+        """Disown closed infobar"""
+        self._activeInfoBar = None
     @pyqtSlot(unicode, unicode)
     def _showOutputOnInfoBar(self, msg, label, maxlines=2, maxwidth=140):
         labelslist = unicode(label).split()