mirror of
https://github.com/ankitects/anki.git
synced 2025-09-24 16:56:36 -04:00
delay setHtml() until previous page has fully loaded
based on 0241eb70dc
This commit is contained in:
parent
b0213b9fd7
commit
9c63714e80
1 changed files with 6 additions and 4 deletions
|
@ -76,6 +76,7 @@ class AnkiWebView(QWebEngineView):
|
||||||
self._page = AnkiWebPage(self._onBridgeCmd)
|
self._page = AnkiWebPage(self._onBridgeCmd)
|
||||||
|
|
||||||
self._domDone = True
|
self._domDone = True
|
||||||
|
self._pendingJS = []
|
||||||
self.setPage(self._page)
|
self.setPage(self._page)
|
||||||
|
|
||||||
self._page.profile().setHttpCacheType(QWebEngineProfile.NoCache)
|
self._page.profile().setHttpCacheType(QWebEngineProfile.NoCache)
|
||||||
|
@ -139,11 +140,12 @@ class AnkiWebView(QWebEngineView):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
def setHtml(self, html):
|
def setHtml(self, html):
|
||||||
if not self._domDone:
|
if not self._domDone or self._pendingJS:
|
||||||
|
# defer update until previous page has initialized
|
||||||
if devMode:
|
if devMode:
|
||||||
import traceback
|
print("deferring setHtml() until page is ready")
|
||||||
print("ignoring setHtml() called before DOM ready")
|
from aqt import mw
|
||||||
print("caller was", traceback.format_stack()[-3])
|
mw.progress.timer(25, lambda: self.setHtml(html), False)
|
||||||
return
|
return
|
||||||
app = QApplication.instance()
|
app = QApplication.instance()
|
||||||
oldFocus = app.focusWidget()
|
oldFocus = app.focusWidget()
|
||||||
|
|
Loading…
Reference in a new issue