mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
E-book viewer: Fix an occassional hang on startup at "Loading section". Fixes #1950673 [Opening books using the book reader fails to load.](https://bugs.launchpad.net/calibre/+bug/1950673)
This commit is contained in:
parent
d8671c8e9e
commit
ce49820ffc
@ -153,12 +153,9 @@ class UrlSchemeHandler(QWebEngineUrlSchemeHandler):
|
||||
return self.fail_request(rq)
|
||||
if name.startswith('book/'):
|
||||
name = name.partition('/')[2]
|
||||
if name == '__index__':
|
||||
if name in ('__index__', '__popup__'):
|
||||
send_reply(rq, 'text/html', b'<div>\xa0</div>')
|
||||
return
|
||||
elif name == '__popup__':
|
||||
send_reply(rq, 'text/html', b'<div id="calibre-viewer-footnote-iframe">\xa0</div>')
|
||||
return
|
||||
try:
|
||||
data, mime_type = get_data(name)
|
||||
if data is None:
|
||||
@ -196,7 +193,7 @@ class UrlSchemeHandler(QWebEngineUrlSchemeHandler):
|
||||
if fail_code is None:
|
||||
fail_code = QWebEngineUrlRequestJob.Error.UrlNotFound
|
||||
rq.fail(fail_code)
|
||||
prints("Blocking FAKE_PROTOCOL request: {}".format(rq.requestUrl().toString()))
|
||||
prints("Blocking FAKE_PROTOCOL request: {} with code: {}".format(rq.requestUrl().toString(), fail_code))
|
||||
|
||||
# }}}
|
||||
|
||||
|
@ -55,7 +55,7 @@ class IframeWrapper:
|
||||
self.messenger = Messenger()
|
||||
self.iframe_id = ensure_id(iframe, 'content-iframe')
|
||||
if ':' in entry_point:
|
||||
self.needs_init = False
|
||||
self.needs_init = iframe.src is not entry_point
|
||||
self.srcdoc_created = True
|
||||
self.constructor_url = entry_point
|
||||
self.entry_point = None
|
||||
@ -115,6 +115,8 @@ class IframeWrapper:
|
||||
self.encrypted_communications = False
|
||||
|
||||
def _send_message(self, action, encrypted, data):
|
||||
if not self.ready:
|
||||
return
|
||||
data.action = action
|
||||
msg = {'data':data, 'encrypted': encrypted}
|
||||
if encrypted:
|
||||
|
@ -1006,4 +1006,5 @@ class IframeBoss:
|
||||
|
||||
|
||||
def main():
|
||||
if not main.boss:
|
||||
main.boss = IframeBoss()
|
||||
|
@ -885,12 +885,14 @@ class View:
|
||||
is_current_book = self.book and self.book.key == book.key
|
||||
self.book_load_started = True
|
||||
if not is_current_book:
|
||||
if self.book:
|
||||
self.iframe_wrapper.reset()
|
||||
self.content_popup_overlay.reset()
|
||||
self.loaded_resources = {}
|
||||
self.content_popup_overlay.loaded_resources = {}
|
||||
self.timers.start_book(book)
|
||||
self.search_overlay.clear_caches(book)
|
||||
self.iframe_wrapper.init()
|
||||
unkey = username_key(get_interface_data().username)
|
||||
self.book = current_book.book = book
|
||||
hl = None
|
||||
|
@ -442,8 +442,7 @@ if window is window.top:
|
||||
, 0) # We do this after event loop ticks over to avoid catching popstate events that some browsers send on page load
|
||||
else:
|
||||
# iframe
|
||||
div = document.getElementById('calibre-viewer-footnote-iframe')
|
||||
if div:
|
||||
footnotes_main()
|
||||
else:
|
||||
if document.location.pathname.endsWith('/__index__'):
|
||||
iframe_main()
|
||||
elif document.location.pathname.endsWith('/__popup__'):
|
||||
footnotes_main()
|
||||
|
Loading…
x
Reference in New Issue
Block a user