Edit book: Workaround bug in Qt causing crash on deleting bottom most file in the Files Browser on linux

This commit is contained in:
Kovid Goyal 2014-02-17 12:58:17 +05:30
parent 60b80868e4
commit b5bb65cf9b

View File

@ -549,7 +549,15 @@ class FileList(QTreeWidget):
# The sorting by index is necessary otherwise Qt crashes with recursive # The sorting by index is necessary otherwise Qt crashes with recursive
# repaint detected message # repaint detected message
for c in sorted(removals, key=lambda x:x.parent().indexOfChild(x), reverse=True): for c in sorted(removals, key=lambda x:x.parent().indexOfChild(x), reverse=True):
c.parent().removeChild(c) sip.delete(c)
# A bug in the raster paint engine on linux causes a crash if the scrollbar
# is at the bottom and the delete happens to cause the scrollbar to
# update
b = self.verticalScrollBar()
if b.value() == b.maximum():
b.setValue(b.minimum())
QTimer.singleShot(0, lambda : b.setValue(b.maximum()))
def dropEvent(self, event): def dropEvent(self, event):
text = self.categories['text'] text = self.categories['text']