Edit Book: Report failures to launch the worker process used for rendering the previews

This commit is contained in:
Kovid Goyal 2014-11-06 10:06:36 +05:30
parent e59b97d1bc
commit 50db38ed56

View File

@ -65,6 +65,7 @@ class ParseWorker(Thread):
self.requests = Queue()
self.request_count = 0
self.parse_items = {}
self.launch_error = None
def run(self):
mod, func = 'calibre.gui2.tweak_book.preview', 'parse_html'
@ -75,6 +76,7 @@ class ParseWorker(Thread):
except:
import traceback
traceback.print_exc()
self.launch_error = traceback.format_exc()
return
while True:
@ -530,10 +532,17 @@ class Preview(QWidget):
self.current_sync_request = None
self.view.page().go_to_sourceline_address(sourceline_address)
def report_worker_launch_error(self):
if parse_worker.launch_error is not None:
tb, parse_worker.launch_error = parse_worker.launch_error, None
error_dialog(self, _('Failed to launch worker'), _(
'Failed to launch the worker process used for rendering the preview'), det_msg=tb, show=True)
def show(self, name):
if name != self.current_name:
self.refresh_timer.stop()
self.current_name = name
self.report_worker_launch_error()
parse_worker.add_request(name)
self.view.setUrl(QUrl.fromLocalFile(current_container().name_to_abspath(name)))
return True
@ -543,6 +552,7 @@ class Preview(QWidget):
self.refresh_timer.stop()
# This will check if the current html has changed in its editor,
# and re-parse it if so
self.report_worker_launch_error()
parse_worker.add_request(self.current_name)
# Tell webkit to reload all html and associated resources
current_url = QUrl.fromLocalFile(current_container().name_to_abspath(self.current_name))