From f9ed3306ce215d288cceffa5ce570e1e22bf16d0 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Fri, 20 Dec 2013 23:46:47 +0530 Subject: [PATCH] Edit book: Fix crash that happens sometimes when deleting multiple files. Fixes #1263179 [Editor quits while deleting files with "delte" key](https://bugs.launchpad.net/calibre/+bug/1263179) --- src/calibre/gui2/tweak_book/file_list.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/tweak_book/file_list.py b/src/calibre/gui2/tweak_book/file_list.py index 7d24bdb4fb..5ee296390d 100644 --- a/src/calibre/gui2/tweak_book/file_list.py +++ b/src/calibre/gui2/tweak_book/file_list.py @@ -519,7 +519,9 @@ class FileList(QTreeWidget): if unicode(child.data(0, NAME_ROLE).toString()) in other_removals: removals.append(child) - for c in removals: + # 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) def dropEvent(self, event):