Details
Description
A loader loads a component containing a list (myListModel) and a property (test) that gets the index of the matching element. When the component is destroyed the application crashes with the error "pure virtual method called".
The example below demonstrates this bug. The error happens after clicking into the window when the destruction of the list model happens.
import QtQuick 2.6 import QtQuick.Window 2.2 Window { visible: true width: 640 height: 480 title: qsTr("Hello World") Loader { id: loader anchors { fill: parent margins: 100 } sourceComponent: red } Component { id: red Rectangle { color: "red" ListModel { id: myListModel ListElement { itemData: "hello" index: 0 itemType: 1 itemEnabled: true } ListElement { itemData: "world" index: 1 itemType: 1 itemEnabled: true } } function getIndexByData(model, name) { for( var i = 0; i < model.count; i++ ) { if( model.get( i ).itemData === name ) { return model.get( i ).index } } return 0; } property int test: getIndexByData(myListModel, "world") } } Component { id: green Rectangle { color: "green" } } MouseArea { anchors.fill: parent onClicked: loader.sourceComponent = green } }
Stack trace:
1 __GI_raise raise.c 54 0x7ffff6521428 2 __GI_abort abort.c 89 0x7ffff652302a 3 __gnu_cxx::__verbose_terminate_handler() 0x7ffff6b5a84d 4 ?? 0x7ffff6b586b6 5 std::terminate() 0x7ffff6b58701 6 __cxa_pure_virtual 0x7ffff6b5923f 7 QQmlJavaScriptExpressionGuard_callback qqmljavascriptexpression.cpp 484 0x7ffff77142d5 8 QQmlNotifier::emitNotify qqmlnotifier.cpp 106 0x7ffff76e9ca0 9 QQmlData::signalEmitted qqmlengine.cpp 839 0x7ffff768177c 10 QMetaObject::activate qobject.cpp 3644 0x7ffff7106a47 11 QMetaObject::activate qobject.cpp 3628 0x7ffff7107375 12 QMetaObject::activate qobject.cpp 3815 0x7ffff71073bf 13 QQmlOpenMetaObject::setValue qqmlopenmetaobject.cpp 356 0x7ffff76762fa 14 ModelNodeMetaObject::setValue qqmllistmodel_p_p.h 153 0x7ffff7771ca9 15 ModelNodeMetaObject::updateValues qqmllistmodel.cpp 1287 0x7ffff7771ca9 16 ModelNodeMetaObject::initialize qqmllistmodel.cpp 1248 0x7ffff77763e4 17 ModelNodeMetaObject::toDynamicMetaObject qqmllistmodel.cpp 1260 0x7ffff7776435 18 QObjectData::dynamicMetaObject qobject.cpp 203 0x7ffff7103be5 19 QObject::metaObject moc_qobject.cpp 167 0x7ffff7103c0e 20 QQmlNotifierEndpoint::disconnect qqmlnotifier_p.h 208 0x7ffff7713e92 ... <More>