From 5ae71cb7ce2e5c63365000cb887e71d2a11fc6bf Mon Sep 17 00:00:00 2001 From: miruka Date: Thu, 21 May 2020 01:26:12 -0400 Subject: [PATCH] Work around ModelStore binding loop --- TODO.md | 1 - src/gui/ModelStore.qml | 8 +++++++- src/gui/PythonBridge/PythonBridge.qml | 1 + 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/TODO.md b/TODO.md index 251f1c91..20bda35d 100644 --- a/TODO.md +++ b/TODO.md @@ -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 diff --git a/src/gui/ModelStore.qml b/src/gui/ModelStore.qml index d9fe1c34..14884197 100644 --- a/src/gui/ModelStore.qml +++ b/src/gui/ModelStore.qml @@ -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}) diff --git a/src/gui/PythonBridge/PythonBridge.qml b/src/gui/PythonBridge/PythonBridge.qml index c2a51d42..9a09fd4a 100644 --- a/src/gui/PythonBridge/PythonBridge.qml +++ b/src/gui/PythonBridge/PythonBridge.qml @@ -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