Work around ModelStore binding loop

This commit is contained in:
miruka 2020-05-21 01:26:12 -04:00
parent b30ce33494
commit 5ae71cb7ce
3 changed files with 8 additions and 2 deletions

View File

@ -8,7 +8,6 @@
- fix: on startup, if a room's last event is a membership change,
it won't be visible in timeline no matter what the user config is
- fix: there are rooms without messages on first sync
- fix binding loops?
- update docstrings
- update flatpak nio required version

View File

@ -6,6 +6,11 @@ import "PythonBridge"
QtObject {
property QtObject privates: QtObject {
onEnsureModelExists:
py.callCoro("models.ensure_exists_from_qml", [modelId])
signal ensureModelExists(var modelId)
readonly property var store: ({})
readonly property PythonBridge py: PythonBridge {}
@ -39,7 +44,8 @@ QtObject {
if (modelId.length === 1) modelId = modelId[0]
if (! privates.store[modelId]) {
privates.py.callCoro("models.ensure_exists_from_qml", [modelId])
// Using a signal somehow avoids a binding loop
privates.ensureModelExists(modelId)
privates.store[modelId] =
privates.model.createObject(this, {modelId})

View File

@ -26,6 +26,7 @@ Python {
Globals.pendingCoroutines[uuid] = {future, onSuccess, onError}
Globals.pendingCoroutinesChanged()
// if (name === "models.ensure_exists_from_qml") { print("r"); return}
call("BRIDGE.call_backend_coro", [name, uuid, args], pyFuture => {
future.privates.pythonFuture = pyFuture