QML binding crash only on runtime - QSharedPointer crash
I would like to create a range age selector. To do this, a control to select a number is created:
SpinnerInt.qml
Code:
import QtQuick 2.0
ListView {
id: root
property alias maxString: textSize.text
property int shadowHeight
property int minValue: 0
onMinValueChanged: {
var lastValue = value
modelValues = maxValue - minValue + 1
if (lastValue > value) {
currentIndex = lastValue - minValue
}
}
property int maxValue: 0
onMaxValueChanged: {
modelValues = maxValue - minValue + 1
}
property int value: 0
function setValue(newValue) {
currentIndex = newValue - minValue
}
property int iniValue: 0
Text {
id: textSize
visible: false
font.pixelSize: 24
}
onCurrentIndexChanged: {
value = currentIndex + minValue
}
property int modelValues
highlightRangeMode: ListView.StrictlyEnforceRange
width: textSize.width
height: textSize.height + (2 * shadowHeight)
preferredHighlightBegin: shadowHeight
preferredHighlightEnd: height - shadowHeight
clip: true
model: modelValues
delegate: Text {
color: currentIndex == index ? "black" : "lightgray";
text: index + minValue
font.pixelSize: 24
anchors.horizontalCenter: parent.horizontalCenter
}
Component.onCompleted: {
var i = iniValue - minValue
if (i >= 0) {
currentIndex = i
}
}
}
The main.qml looks like this:
Code:
import QtQuick 2.5
import QtQuick.Controls 1.4
ApplicationWindow {
visible: true
width: 640
height: 480
Row {
spacing: 20
SpinnerInt {
id: ageMin
shadowHeight: 20
maxString: "MM"
minValue: 15
maxValue: 99
iniValue: 20
}
SpinnerInt {
id: ageMax
shadowHeight: 20
maxString: "MM"
minValue: ageMin.value
maxValue: 99
iniValue: 20
}
}
}
Note that the property minValue on ageMax is binding with ageMin.value.
If is tested with qmlscene, all works fine, but if runs the program, it crash in qsharedpointer.cpp.
Why is crashing only on runtime? How can I fix it?