Reputation: 31
I have been trying to track down some binding loops in a Qt 4.8.4 (QtQuick 1.1) application at work. I did some experimentation and found the following basic example results in a binding loop detected by the QML Analyzer in QtCreator 3.5.1:
import QtQuick 1.1
Rectangle {
Repeater {
model: 1000
Text { text: "I'm item " + index }
}
}
If I move the Repeater element out to another qml file called Multiple.qml which contains:
import QtQuick 1.1
Repeater {
model: 1000
Text { text: "I'm item " + index }
}
and change my main.qml to the following, the binding loop goes away:
import QtQuick 1.1
Rectangle {
Multiple {}
}
The 1000 iterations is not a realistic example. I used it to scale up some of the time deltas in the QML Profiler. The issue occurs with any number of iterations >= 1.
The Analyzer events output also claims that "create" has been called for the top main.qml 1001 times (number of Repeater iterations + 1), however analysis with massif seems to indicate that memory usage does not increase when the binding loop is detected. It does appear to be eating up additional time according to the Analyzer output. On my machine, the main.qml create is 71 ms vs 124 ms.
I did some further experimentation. If I put the Repeater element into another QML file and instantiate it using Qt.creatComponent("MyComp.qml" and <component>.createObject()
from the main qml file, I also get a binding loop. If MyComp.qml uses Multiple {} instead, the binding loop goes away.
I have also tried a more recent version of Qt 5.5.0 - same issue.
Is this expected behaviour? Could it be a bug in QtCreator itself? I had a search through the QtCreator Jira and couldn't find any related issues.
Upvotes: 3
Views: 485
Reputation: 51
I can't see any reason for a binding loop being created by the simple code you have shown. If the binding loop is just reported by the Analyzer, and not in actual console output by the application, I suspect it is a bug in the Analyzer in the way it determines binding loops, rather than in the code itself.
Upvotes: 1