Work around ModelStore binding loop
This commit is contained in:
parent
b30ce33494
commit
5ae71cb7ce
1
TODO.md
1
TODO.md
|
@ -8,7 +8,6 @@
|
||||||
- fix: on startup, if a room's last event is a membership change,
|
- 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
|
it won't be visible in timeline no matter what the user config is
|
||||||
- fix: there are rooms without messages on first sync
|
- fix: there are rooms without messages on first sync
|
||||||
- fix binding loops?
|
|
||||||
|
|
||||||
- update docstrings
|
- update docstrings
|
||||||
- update flatpak nio required version
|
- update flatpak nio required version
|
||||||
|
|
|
@ -6,6 +6,11 @@ import "PythonBridge"
|
||||||
|
|
||||||
QtObject {
|
QtObject {
|
||||||
property QtObject privates: QtObject {
|
property QtObject privates: QtObject {
|
||||||
|
onEnsureModelExists:
|
||||||
|
py.callCoro("models.ensure_exists_from_qml", [modelId])
|
||||||
|
|
||||||
|
signal ensureModelExists(var modelId)
|
||||||
|
|
||||||
readonly property var store: ({})
|
readonly property var store: ({})
|
||||||
|
|
||||||
readonly property PythonBridge py: PythonBridge {}
|
readonly property PythonBridge py: PythonBridge {}
|
||||||
|
@ -39,7 +44,8 @@ QtObject {
|
||||||
if (modelId.length === 1) modelId = modelId[0]
|
if (modelId.length === 1) modelId = modelId[0]
|
||||||
|
|
||||||
if (! privates.store[modelId]) {
|
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.store[modelId] =
|
||||||
privates.model.createObject(this, {modelId})
|
privates.model.createObject(this, {modelId})
|
||||||
|
|
|
@ -26,6 +26,7 @@ Python {
|
||||||
|
|
||||||
Globals.pendingCoroutines[uuid] = {future, onSuccess, onError}
|
Globals.pendingCoroutines[uuid] = {future, onSuccess, onError}
|
||||||
Globals.pendingCoroutinesChanged()
|
Globals.pendingCoroutinesChanged()
|
||||||
|
// if (name === "models.ensure_exists_from_qml") { print("r"); return}
|
||||||
|
|
||||||
call("BRIDGE.call_backend_coro", [name, uuid, args], pyFuture => {
|
call("BRIDGE.call_backend_coro", [name, uuid, args], pyFuture => {
|
||||||
future.privates.pythonFuture = pyFuture
|
future.privates.pythonFuture = pyFuture
|
||||||
|
|
Loading…
Reference in New Issue
Block a user