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)

This commit is contained in:
Kovid Goyal 2012-03-25 01:43:45 +05:30
parent 4b4ae70290
commit 5a1307ca6f
2 changed files with 7 additions and 0 deletions

View File

@ -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)

View File

@ -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