Skip to content

Commit

Permalink
webengine: rename forceSync parameter to wait
Browse files Browse the repository at this point in the history
  • Loading branch information
minorua committed Nov 17, 2023
1 parent f00eec3 commit 5dfad16
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 16 deletions.
4 changes: 2 additions & 2 deletions proppages.py
Original file line number Diff line number Diff line change
Expand Up @@ -1052,8 +1052,8 @@ def __init__(self, parent, layer):
self.setProperties(layer.properties)

wnd = self.parent().parent()
loaded = wnd.runScript("app.scene.mapLayers[{}].loadedPointCount()".format(layer.jsLayerId), forceSync=True)
visible = wnd.runScript("app.scene.mapLayers[{}].pcg.children[0].numVisiblePoints".format(layer.jsLayerId), forceSync=True)
loaded = wnd.runScript("app.scene.mapLayers[{}].loadedPointCount()".format(layer.jsLayerId), wait=True)
visible = wnd.runScript("app.scene.mapLayers[{}].pcg.children[0].numVisiblePoints".format(layer.jsLayerId), wait=True)

total = bbox = None

Expand Down
10 changes: 5 additions & 5 deletions q3dwebengineview.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,18 +46,18 @@ def reload(self):

self.setUrl(self.myUrl)

def runScript(self, string, data=None, message="", sourceID="q3dview.py", callback=None, forceSync=False):
"""forceSync: whether to run script synchronously"""
Q3DWebPageCommon.runScript(self, string, data, message, sourceID, callback, forceSync)
def runScript(self, string, data=None, message="", sourceID="q3dview.py", callback=None, wait=False):
"""wait: whether to wait until script execution has completed"""
Q3DWebPageCommon.runScript(self, string, data, message, sourceID, callback, wait)

if data is not None:
assert callback is None, "cannot callback when data is set"
assert not forceSync, "synchronous script execution with data not supported"
assert not wait, "synchronous script execution with data not supported"

self.bridge.sendScriptData.emit(string, data)
return

if not forceSync:
if not wait:
if callback:
self.runJavaScript(string, callback)

Expand Down
4 changes: 2 additions & 2 deletions q3dwebkitview.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ def reload(self):

self.mainFrame().setUrl(self.myUrl)

def runScript(self, string, data=None, message="", sourceID="q3dview.py", callback=None, forceSync=False):
Q3DWebPageCommon.runScript(self, string, data, message, sourceID, callback, forceSync)
def runScript(self, string, data=None, message="", sourceID="q3dview.py", callback=None, wait=False):
Q3DWebPageCommon.runScript(self, string, data, message, sourceID, callback, wait)

if data is not None:
self.bridge.setData(data)
Expand Down
10 changes: 5 additions & 5 deletions q3dwebviewcommon.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ def initialized(self):

self.wnd.showStatusMessage("")

def runScript(self, string, data=None, message="", sourceID="q3dview.py", callback=None, forceSync=False):
def runScript(self, string, data=None, message="", sourceID="q3dview.py", callback=None, wait=False):
if not DEBUG_MODE or message is None:
return

Expand Down Expand Up @@ -112,7 +112,7 @@ def loadScriptFiles(self, ids, force=False):
self.loadScriptFile(id, force)

def cameraState(self, flat=False):
return self.runScript("cameraState({})".format(1 if flat else 0), forceSync=True)
return self.runScript("cameraState({})".format(1 if flat else 0), wait=True)

def setCameraState(self, state):
"""set camera position and camera target"""
Expand Down Expand Up @@ -220,11 +220,11 @@ def dropEvent(self, event):
def sendData(self, data):
self._page.sendData(data)

def runScript(self, string, data=None, message="", sourceID="q3dview.py", callback=None, forceSync=False):
return self._page.runScript(string, data, message, sourceID, callback, forceSync)
def runScript(self, string, data=None, message="", sourceID="q3dview.py", callback=None, wait=False):
return self._page.runScript(string, data, message, sourceID, callback, wait)

def showJSInfo(self):
info = self.runScript("app.renderer.info", forceSync=True)
info = self.runScript("app.renderer.info", wait=True)
QMessageBox.information(self, "three.js Renderer Info", str(info))


Expand Down
4 changes: 2 additions & 2 deletions q3dwindow.py
Original file line number Diff line number Diff line change
Expand Up @@ -296,8 +296,8 @@ def changeEvent(self, event):
else:
self.runScript("app.resume()")

def runScript(self, string, data=None, message="", sourceID="Q3DWindow.py", callback=None, forceSync=False):
return self.webPage.runScript(string, data, message, sourceID, callback, forceSync)
def runScript(self, string, data=None, message="", sourceID="Q3DWindow.py", callback=None, wait=False):
return self.webPage.runScript(string, data, message, sourceID, callback, wait)

def showMessageBar(self, msg, duration=0, warning=False):
self.runScript("showMessageBar(pyData(), {}, {})".format(duration, js_bool(warning)), msg)
Expand Down

0 comments on commit 5dfad16

Please sign in to comment.