Commit 1d5bbb48 authored by Steve Borho's avatar Steve Borho
Browse files

htmldelegate: catch revlog error while collecting indexed data (closes #102)

(on to the next traceback caused by qpop/qref)
parent f1dd5c4dcf5c
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
from PyQt4.QtCore import * from PyQt4.QtCore import *
from PyQt4.QtGui import * from PyQt4.QtGui import *
from mercurial import error
from tortoisehg.hgqt import qtlib from tortoisehg.hgqt import qtlib
class HTMLDelegate(QStyledItemDelegate): class HTMLDelegate(QStyledItemDelegate):
...@@ -18,7 +19,11 @@ class HTMLDelegate(QStyledItemDelegate): ...@@ -18,7 +19,11 @@ class HTMLDelegate(QStyledItemDelegate):
def paint(self, painter, option, index): def paint(self, painter, option, index):
if self.cols and index.column() not in self.cols: if self.cols and index.column() not in self.cols:
return QStyledItemDelegate.paint(self, painter, option, index) return QStyledItemDelegate.paint(self, painter, option, index)
text = index.model().data(index, Qt.DisplayRole).toString() try:
text = index.model().data(index, Qt.DisplayRole).toString()
except error.RevlogError, e:
# this can happen if revlog is being truncated while we read it
text = _('?? Error: %s ??') % hglib.tounicode(str(e))
# draw selection # draw selection
option = QStyleOptionViewItemV4(option) option = QStyleOptionViewItemV4(option)
...@@ -47,7 +52,10 @@ class HTMLDelegate(QStyledItemDelegate): ...@@ -47,7 +52,10 @@ class HTMLDelegate(QStyledItemDelegate):
painter.restore() painter.restore()
def sizeHint(self, option, index): def sizeHint(self, option, index):
text = index.model().data(index, Qt.DisplayRole).toString() try:
text = index.model().data(index, Qt.DisplayRole).toString()
except error.RevlogError, e:
text = _('?? Error: %s ??') % hglib.tounicode(str(e))
doc = QTextDocument() doc = QTextDocument()
doc.setDefaultStyleSheet(qtlib.thgstylesheet) doc.setDefaultStyleSheet(qtlib.thgstylesheet)
doc.setDefaultFont(option.font) doc.setDefaultFont(option.font)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment