QML Property Changing Outside of Evaluation?
-
property var def_g_segment: ({min:0, max:0, color:"white", inBkg:false}) property QtObject g_seg_temp: graph_model.getGraphSeg(index, graph_delegaterect.segment) readonly property var g_segment: { console.log("g_segment eval") console.log("g_seg_temp", g_seg_temp) if(g_seg_temp){ return g_seg_temp } return def_g_segment } onG_segmentChanged: { if(1){ console.log("g_segment changed") console.log(index, graph_model.numGraphers()) console.log(typeof(g_segment)) console.log(g_segment) } }
output:
qml: g_segment changed qml: 0 6 qml: object qml: null qml: g_segment eval qml: g_seg_temp null qml: g_segment changed qml: 0 6 qml: object qml: [object Object] qml: g_segment changed qml: 0 6 qml: object qml: null qml: g_segment eval qml: g_seg_temp null qml: g_segment changed qml: 0 6 qml: object qml: [object Object] qml: g_segment changed qml: 0 6 qml: object qml: null qml: g_segment eval qml: g_seg_temp null qml: g_segment changed qml: 0 6 qml: object qml: [object Object]
graph_model.getGraphSeg can return null. So I am accounting for that in the evaluation of g_segment. However, I am seeing null come through under certain conditions. I want to detect null and use a dummy object instead. I am very confused as to how this is even possible. It seems like it is fighting itself somehow. I made it readonly on the property to ensure something else wasn't causing this. I also searched the code to find it, but just did not see anything. I need to try and mock this up in a test program.
Normally the text it prints is like this:
qml: g_segment eval qml: g_seg_temp GraphSegment(0xd1b3b0) qml: g_segment changed qml: 0 6 qml: object qml: GraphSegment(0xd1b3b0)
I have objects that are being updated affecting the index and segment values.
The graph_model is an old model that probably needs to be changed to a QAbstractListModel. That might be the real solution here. Just seems weird that the eval would be happening after a change signal. Unless the return value causes the signal to fire before the text is printed? I just don't know.