Source

thg-qt-mq / test-memleak.diff

Full commit
# HG changeset patch
# Parent ab8483ee88be0a9885f9b84c3e70d8dc549cc498

diff --git a/tortoisehg/hgqt/filelistview.py b/tortoisehg/hgqt/filelistview.py
--- a/tortoisehg/hgqt/filelistview.py
+++ b/tortoisehg/hgqt/filelistview.py
@@ -47,6 +47,9 @@ class HgFileListView(QTableView):
         self.setSelectionBehavior(QAbstractItemView.SelectRows)
         self.setTextElideMode(Qt.ElideLeft)
 
+    def __del__(self):
+        print 'del %r' % self
+
     def setModel(self, model):
         QTableView.setModel(self, model)
         model.layoutChanged.connect(self.layoutChanged)
diff --git a/tortoisehg/hgqt/fileview.py b/tortoisehg/hgqt/fileview.py
--- a/tortoisehg/hgqt/fileview.py
+++ b/tortoisehg/hgqt/fileview.py
@@ -204,6 +204,9 @@ class HgFileView(QFrame):
         self.timer.setSingleShot(False)
         self.timer.timeout.connect(self.timerBuildDiffMarkers)
 
+    def __del__(self):
+        print 'del %r' % self
+
     def launchShelve(self):
         from tortoisehg.hgqt import shelve
         # TODO: pass self._filename
diff --git a/tortoisehg/hgqt/repofilter.py b/tortoisehg/hgqt/repofilter.py
--- a/tortoisehg/hgqt/repofilter.py
+++ b/tortoisehg/hgqt/repofilter.py
@@ -101,6 +101,9 @@ class RepoFilterBar(QToolBar):
         self._initbranchfilter()
         self.refresh()
 
+    def __del__(self):
+        print 'del %r' % self
+
     def onClearButtonClicked(self):
         if self.revsetcombo.lineEdit().text():
             self.revsetcombo.lineEdit().clear()
diff --git a/tortoisehg/hgqt/repomodel.py b/tortoisehg/hgqt/repomodel.py
--- a/tortoisehg/hgqt/repomodel.py
+++ b/tortoisehg/hgqt/repomodel.py
@@ -84,6 +84,7 @@ class HgRepoListModel(QAbstractTableMode
         """
         repo is a hg repo instance
         """
+        print 'new %r' % self
         QAbstractTableModel.__init__(self, parent)
         self._cache = []
         self.graph = None
@@ -103,13 +104,13 @@ class HgRepoListModel(QAbstractTableMode
         self._branch_colors = {}
 
         self._columnmap = {
-            'Rev':      self.getrev,
+            #'Rev':      self.getrev,
             'Node':     lambda ctx, gnode: str(ctx),
             'Graph':    lambda ctx, gnode: "",
-            'Description': self.getlog,
-            'Author':   self.getauthor,
-            'Tags':     self.gettags,
-            'Branch':   self.getbranch,
+            #'Description': self.getlog,
+            #'Author':   self.getauthor,
+            #'Tags':     self.gettags,
+            #'Branch':   self.getbranch,
             'Filename': lambda ctx, gnode: gnode.extra[0],
             'Age':      lambda ctx, gnode: hglib.age(ctx.date()).decode('utf-8'),
             'LocalTime':lambda ctx, gnode: hglib.displaytime(ctx.date()),
@@ -122,6 +123,9 @@ class HgRepoListModel(QAbstractTableMode
             self.updateColumns()
             self.setBranch(branch)
 
+    def __del__(self):
+        print 'del %r' % self
+
     def setBranch(self, branch=None, allparents=True):
         self.filterbranch = branch  # unicode
         self.invalidateCache()
diff --git a/tortoisehg/hgqt/repoview.py b/tortoisehg/hgqt/repoview.py
--- a/tortoisehg/hgqt/repoview.py
+++ b/tortoisehg/hgqt/repoview.py
@@ -75,6 +75,9 @@ class HgRepoView(QTableView):
         self.doubleClicked.connect(self.revActivated)
         self.clicked.connect(self.revClicked)
 
+    def __del__(self):
+        print 'del %r' % self
+
     def setRepo(self, repo):
         self.repo = repo
 
diff --git a/tortoisehg/hgqt/repowidget.py b/tortoisehg/hgqt/repowidget.py
--- a/tortoisehg/hgqt/repowidget.py
+++ b/tortoisehg/hgqt/repowidget.py
@@ -146,6 +146,9 @@ class RepoWidget(QWidget):
             if widgetIndex > 0:
                 self.taskTabsWidget.setCurrentIndex(widgetIndex)
 
+    def __del__(self):
+        print 'del %r' % self
+
     def setupUi(self):
         SP = QSizePolicy
 
diff --git a/tortoisehg/hgqt/revdetails.py b/tortoisehg/hgqt/revdetails.py
--- a/tortoisehg/hgqt/revdetails.py
+++ b/tortoisehg/hgqt/revdetails.py
@@ -50,6 +50,9 @@ class RevDetailsWidget(QWidget, qtlib.Ta
         self._deschtmlize = qtlib.descriptionhtmlizer(repo.ui)
         repo.configChanged.connect(self._updatedeschtmlizer)
 
+    def __del__(self):
+        print 'del %r' % self
+
     def setRepo(self, repo):
         self.repo = repo
         self.fileview.setRepo(repo)
diff --git a/tortoisehg/hgqt/thgrepo.py b/tortoisehg/hgqt/thgrepo.py
--- a/tortoisehg/hgqt/thgrepo.py
+++ b/tortoisehg/hgqt/thgrepo.py
@@ -13,6 +13,7 @@ import sys
 import shutil
 import tempfile
 import re
+import weakref
 
 from PyQt4.QtCore import *
 
@@ -24,7 +25,7 @@ from mercurial.util import propertycache
 from tortoisehg.util import hglib, paths
 from tortoisehg.util.patchctx import patchctx
 
-_repocache = {}
+_repocache = weakref.WeakValueDictionary()
 _kbfregex = re.compile(r'^\.kbf/')
 _lfregex = re.compile(r'^\.hglf/')
 
@@ -94,6 +95,9 @@ class ThgRepoWrapper(QObject):
             self.watcher.fileChanged.connect(self.onFileChange)
             self.addMissingPaths()
 
+    def __del__(self):
+        print 'del %r' % self
+
     @pyqtSlot(QString)
     def onDirChange(self, directory):
         'Catch any writes to .hg/ folder, most importantly lock files'