From 5a1307ca6fd60737b494f2243482036f91050eac Mon Sep 17 00:00:00 2001 From: Kovid Goyal Date: Sun, 25 Mar 2012 01:43:45 +0530 Subject: [PATCH] E-book viewer: Fix regression that caused the ebook viewer to stop functioning if it is launched from the main calibre program and then the main calibre program is closed. Fixes #963960 (Reader crashes at end of chapter) --- src/calibre/gui2/viewer/main.py | 2 ++ src/calibre/ptempfile.py | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/src/calibre/gui2/viewer/main.py b/src/calibre/gui2/viewer/main.py index df4d146581..0122b42012 100644 --- a/src/calibre/gui2/viewer/main.py +++ b/src/calibre/gui2/viewer/main.py @@ -27,6 +27,7 @@ from calibre.ebooks.metadata import MetaInformation from calibre.customize.ui import available_input_formats from calibre.gui2.viewer.dictionary import Lookup from calibre import as_unicode, force_unicode, isbytestring +from calibre.ptempfile import reset_base_dir vprefs = JSONConfig('viewer') @@ -947,6 +948,7 @@ View an ebook. def main(args=sys.argv): # Ensure viewer can continue to function if GUI is closed os.environ.pop('CALIBRE_WORKER_TEMP_DIR', None) + reset_base_dir() parser = option_parser() opts, args = parser.parse_args(args) diff --git a/src/calibre/ptempfile.py b/src/calibre/ptempfile.py index 48974b0c6c..706a96b4b6 100644 --- a/src/calibre/ptempfile.py +++ b/src/calibre/ptempfile.py @@ -74,6 +74,11 @@ def base_dir(): return _base_dir +def reset_base_dir(): + global _base_dir + _base_dir = None + base_dir() + def force_unicode(x): # Cannot use the implementation in calibre.__init__ as it causes a circular # dependency