1. Yuya Nishihara
  2. thg-qt-mq

Commits

Yuya Nishihara  committed f5fa8c3

fix segfault

  • Participants
  • Parent commits 07315a8
  • Branches default

Comments (0)

Files changed (2)

File dlgkeep-next.diff

View file
  • Ignore whitespace
+# HG changeset patch
+# Parent 01b0f961500bf8a4f79d0b9d5cf8af2d8753b513
+
+diff --git a/tortoisehg/hgqt/qtlib.py b/tortoisehg/hgqt/qtlib.py
+--- a/tortoisehg/hgqt/qtlib.py
++++ b/tortoisehg/hgqt/qtlib.py
+@@ -1197,6 +1197,20 @@ class DialogKeeper(QObject):
+ 
+         self._dialogs = DialogKeeper(self._createDialog)
+         self._dialogs = DialogKeeper(lambda *args: Foo(self))
++
++    XXX description here!
++
++    >>> dialogs = DialogKeeper(QDialog)
++    >>> dlgref = weakref.ref(dialogs.open())
++    >>> dialogs.count()
++    1
++    >>> esckeyev = QKeyEvent(QEvent.KeyPress, Qt.Key_Escape, Qt.NoModifier)
++    >>> QApplication.postEvent(dlgref(), esckeyev)
++    >>> QApplication.processEvents()
++    >>> dialogs.count()
++    0
++    >>> dlgref() is None
++    True
+     """
+ 
+     def __init__(self, createdlg, genkey=None, parent=None):
+@@ -1206,6 +1220,10 @@ class DialogKeeper(QObject):
+         self._keytodlgs = {}  # key: [dlg, ...]
+         self._dlgtokey = {}   # dlg: key
+ 
++        self._garbagedlgs = []
++        self._disposedlgslater = QTimer(self, interval=0, singleShot=True)
++        self._disposedlgslater.timeout.connect(self._disposedlgs)
++
+     def open(self, *args, **kwargs):
+         """Create new dialog or reactivate existing dialog"""
+         dlg = self._preparedlg(self._genkey(self.parent(), *args, **kwargs),
+@@ -1251,6 +1269,14 @@ class DialogKeeper(QObject):
+         if not self._keytodlgs[key]:
+             del self._keytodlgs[key]
+ 
++        # avoid deletion inside finished signal, which leads to crash
++        self._garbagedlgs.append(dlg)
++        self._disposedlgslater.start()
++
++    @pyqtSlot()
++    def _disposedlgs(self):
++        del self._garbagedlgs[:]
++
+     def count(self):
+         assert len(self._dlgtokey) == sum(len(dlgs) for dlgs
+                                           in self._keytodlgs.itervalues())

File series

View file
  • Ignore whitespace
 merge-close-delay.diff
 cmdui-running-fix.diff
+dlgkeep-next.diff
 wctxa-noannot.diff
 prio-syncw.diff
 serve-dropsingle.diff