diff --git a/src/calibre/ebooks/lrf/output.py b/src/calibre/ebooks/lrf/output.py index 693bc3c172..f7f85b9c42 100644 --- a/src/calibre/ebooks/lrf/output.py +++ b/src/calibre/ebooks/lrf/output.py @@ -158,6 +158,13 @@ class LRFOutput(OutputFormatPlugin): book.renderLrf(open(opts.output, 'wb')) + def flatten_toc(self): + from calibre.ebooks.oeb.base import TOC + nroot = TOC() + for x in self.oeb.toc.iterdescendants(): + nroot.add(x.title, x.href) + self.oeb.toc = nroot + def convert(self, oeb, output_path, input_plugin, opts, log): self.log, self.opts, self.oeb = log, opts, oeb @@ -169,6 +176,8 @@ class LRFOutput(OutputFormatPlugin): getattr(opts, 'wide', False)) return + self.flatten_toc() + from calibre.ptempfile import TemporaryDirectory with TemporaryDirectory('_lrf_output') as tdir: from calibre.customize.ui import plugin_for_output_format diff --git a/src/calibre/gui2/add.py b/src/calibre/gui2/add.py index 6ccf33c5c8..b872b033d3 100644 --- a/src/calibre/gui2/add.py +++ b/src/calibre/gui2/add.py @@ -134,7 +134,6 @@ class Adder(QObject): mi.title = os.path.splitext(name)[0] mi.title = mi.title if isinstance(mi.title, unicode) else \ mi.title.decode(preferred_encoding, 'replace') - self.pd.set_msg(_('Added')+' '+mi.title) if self.db is not None: if cover: @@ -153,6 +152,9 @@ class Adder(QObject): 'cover':None, 'tags':mi.tags if mi.tags else []}) + self.pd.set_msg(_('Added')+' '+mi.title) + + def process_duplicates(self): if not self.duplicates: return diff --git a/src/calibre/utils/poppler/__init__.py b/src/calibre/utils/poppler/__init__.py index 388e4df905..c35216e081 100644 --- a/src/calibre/utils/poppler/__init__.py +++ b/src/calibre/utils/poppler/__init__.py @@ -54,6 +54,8 @@ def get_metadata(stream, cover=True): if cdata is not None: mi.cover_data = ('jpg', cdata) + del doc + del raw return mi