From b5bb65cf9bcfb350f53ddeb89bed13b7303bd950 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Mon, 17 Feb 2014 12:58:17 +0530 Subject: [PATCH] Edit book: Workaround bug in Qt causing crash on deleting bottom most file in the Files Browser on linux --- src/calibre/gui2/tweak_book/file_list.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/tweak_book/file_list.py b/src/calibre/gui2/tweak_book/file_list.py index 6ec6f1eef6..54c57ff510 100644 --- a/src/calibre/gui2/tweak_book/file_list.py +++ b/src/calibre/gui2/tweak_book/file_list.py @@ -549,7 +549,15 @@ class FileList(QTreeWidget): # The sorting by index is necessary otherwise Qt crashes with recursive # repaint detected message 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): text = self.categories['text']