Source

thg-qt-mq / cmdui-objtree-deletable.diff

# HG changeset patch
# Parent ed10c74e46421ec8298edff796611c18695cc789
diff --git a/tortoisehg/hgqt/cmdui.py b/tortoisehg/hgqt/cmdui.py
--- a/tortoisehg/hgqt/cmdui.py
+++ b/tortoisehg/hgqt/cmdui.py
@@ -151,13 +151,16 @@ class Core(QObject):
         self.queue = []
         self.display = None
         self.internallog = useInternal
-        self.parent = parent
         if useInternal:
             self.output_text = QPlainTextEdit()
             self.output_text.setReadOnly(True)
             self.output_text.setMaximumBlockCount(1024)
             self.output_text.setWordWrapMode(QTextOption.NoWrap)
 
+    def __del__(self):
+        print 'del cmdui.Core'
+        super(Core, self).__del__()
+
     ### Public Methods ###
 
     def run(self, cmdline, *cmdlines, **opts):
@@ -192,7 +195,7 @@ class Core(QObject):
     def run_next(self):
         try:
             cmdline = self.queue.pop(0)
-            self.thread = thread.CmdThread(cmdline, self.display, self.parent)
+            self.thread = thread.CmdThread(cmdline, self.display, self)
         except IndexError:
             return False
 
@@ -315,6 +318,11 @@ class Widget(QWidget):
         # widget setting
         self.setLayout(vbox)
 
+    def __del__(self):
+        print 'del cmdui.Widget'
+        self.core.output_text.deleteLater()
+        super(Widget, self).__del__()
+
     ### Public Methods ###
 
     def run(self, cmdline, *args, **opts):
diff --git a/tortoisehg/hgqt/repowidget.py b/tortoisehg/hgqt/repowidget.py
--- a/tortoisehg/hgqt/repowidget.py
+++ b/tortoisehg/hgqt/repowidget.py
@@ -572,6 +572,7 @@ class RepoWidget(QWidget):
         dlg.makeLogVisible.connect(self.makeLogVisible)
         dlg.progress.connect(self.progress)
         dlg.exec_()
+        dlg.deleteLater()
 
     def manifestRevision(self):
         run.manifest(self.repo.ui, repo=self.repo, rev=self.rev)
diff --git a/tortoisehg/hgqt/thread.py b/tortoisehg/hgqt/thread.py
--- a/tortoisehg/hgqt/thread.py
+++ b/tortoisehg/hgqt/thread.py
@@ -151,11 +151,10 @@ class CmdThread(QThread):
     commandFinished = pyqtSignal(DataWrapper)
 
     def __init__(self, cmdline, display, parent=None):
-        super(CmdThread, self).__init__()
+        super(CmdThread, self).__init__(parent)
 
         self.cmdline = cmdline
         self.display = display
-        self.parent = parent
         self.ret = None
         self.abortbyuser = False
         self.responseq = Queue.Queue()
@@ -163,6 +162,10 @@ class CmdThread(QThread):
 
         self.finished.connect(self.thread_finished)
 
+    def __del__(self):
+        print 'del CmdThread'
+        super(CmdThread, self).__del__()
+
     def abort(self):
         if self.isRunning() and hasattr(self, 'thread_id'):
             self.abortbyuser = True
@@ -181,7 +184,7 @@ class CmdThread(QThread):
         if choices:
             dlg = QMessageBox(QMessageBox.Question,
                         _('TortoiseHg Prompt'), prompt,
-                        QMessageBox.Yes | QMessageBox.Cancel, self.parent)
+                        QMessageBox.Yes | QMessageBox.Cancel, self.parent())
             dlg.setDefaultButton(QMessageBox.Cancel)
             dlg.setWindowFlags(Qt.Sheet)
             dlg.setWindowModality(Qt.WindowModal)
@@ -200,7 +203,7 @@ class CmdThread(QThread):
         else:
             mode = password and QLineEdit.Password \
                              or QLineEdit.Normal
-            dlg = QInputDialog(self.parent, Qt.Sheet)
+            dlg = QInputDialog(self.parent(), Qt.Sheet)
             dlg.setWindowModality(Qt.WindowModal)
             dlg.setWindowTitle(_('TortoiseHg Prompt'))
             dlg.setLabelText(prompt.title())
diff --git a/tortoisehg/hgqt/update.py b/tortoisehg/hgqt/update.py
--- a/tortoisehg/hgqt/update.py
+++ b/tortoisehg/hgqt/update.py
@@ -155,6 +155,10 @@ class UpdateDialog(QDialog):
         self.showlog_chk.setHidden(True)
         self.update_info()
 
+    def __del__(self):
+        print 'del UpdateDialog'
+        super(UpdateDialog, self).__del__()
+
     ### Private Methods ###
 
     def update_info(self):