From 7a7cacc9205da562eab21e8858ed09fcebd0e1c2 Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Tue, 5 Nov 2013 15:40:03 +0530 Subject: [PATCH] Close editors when files deleted --- src/calibre/gui2/tweak_book/boss.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/calibre/gui2/tweak_book/boss.py b/src/calibre/gui2/tweak_book/boss.py index 469691b141..162d21d9f5 100644 --- a/src/calibre/gui2/tweak_book/boss.py +++ b/src/calibre/gui2/tweak_book/boss.py @@ -123,6 +123,9 @@ class Boss(QObject): c.remove_item(name) self.gui.action_save.setEnabled(True) self.gui.file_list.delete_done(spine_items, other_items) + for name in list(spine_items) + list(other_items): + if name in self.editors: + self.close_editor(name) # TODO: Update other GUI elements def reorder_spine(self, items): @@ -288,7 +291,10 @@ class Boss(QObject): 'There are unsaved changes in %s. Are you sure you want to close' ' this editor?') % name): return - self.editors.pop(name) + self.close_editor(name) + + def close_editor(self, name): + editor = self.editors.pop(name) self.gui.central.close_editor(editor) editor.break_cycles()