From f17f6886a6be8caa26c3b70ab891f2ad8a759aca Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 15 Dec 2013 09:06:21 +0530 Subject: [PATCH] Edit book: Fix trying to import an html file/css file via the add new file button always resulting in a blank file --- src/calibre/gui2/tweak_book/file_list.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/src/calibre/gui2/tweak_book/file_list.py b/src/calibre/gui2/tweak_book/file_list.py index 3c574183f4..9e65f95747 100644 --- a/src/calibre/gui2/tweak_book/file_list.py +++ b/src/calibre/gui2/tweak_book/file_list.py @@ -667,12 +667,13 @@ class NewFileDialog(QDialog): # {{{ name, ext = name.rpartition('.')[0::2] name = (name + '.' + ext.lower()).replace('\\', '/') mt = guess_type(name) - if mt in OEB_DOCS: - self.file_data = template_for('html').encode('utf-8') - self.using_template = True - elif mt in OEB_STYLES: - self.file_data = template_for('css').encode('utf-8') - self.using_template = True + if not self.file_data: + if mt in OEB_DOCS: + self.file_data = template_for('html').encode('utf-8') + self.using_template = True + elif mt in OEB_STYLES: + self.file_data = template_for('css').encode('utf-8') + self.using_template = True self.file_name = name QDialog.accept(self) # }}}