Details
-
Bug
-
Resolution: Unresolved
-
P2: Important
-
6.9
-
None
Description
The following:
import QtQuick import QtQuick.Controls Window { id: root property int foo: 10 property bool onFooChanged: {} Component.onCompleted: { foo = 1000 } }
Will trigger in debug mode:
ASSERT: "methods.size() <= methodIndexCache.size()" in file /home/luca/Documents/current/qt5/qtdeclarative/src/qml/qml/qqmlpropertycache.cpp, line 991
Possibly due to `onFooChanged` being treated as a signal handler in some way without it being setup as such/treated as a signal handler by some parts of the system but not all.
This seems related to introducing an executable expression in the binding. More direct values will trigger an error, for example:
import QtQuick import QtQuick.Controls Window { id: root property int foo: 10 property bool onFooChanged: 10 Component.onCompleted: { foo = 1000 } }
Will produce:
file:///tmp/Maini.qml:9:19: Cannot assign a value to a signal (expecting a script to be run)
The type of the property, for known types, and the form of the callable expression is unrelated and is not being taken into consideration, so that:
property bool onFooChanged: {} property int onFooChanged: {} property var onFooChanged: () => {}
All behaves the same. Unknown types will instead error out, most probably due to producing a bail out before the culprit of the issue is reached:
import QtQuick import QtQuick.Controls Window { id: root property int foo: 10 property notatype onFooChanged: () => {} Component.onCompleted: { foo = 1000 } }
Produces:
file:///tmp/Main.qml:9:5: notatype is not a type
The assert is triggered when the object is created. The following is a trace leading to the assert:
#7 0x00007fffee2fe62d in qt_assert (assertion=0x7ffff47afbe0 "methods.size() <= methodIndexCache.size()", file=0x7ffff47aeb80 "/home/luca/Documents/current/qt5/qtdeclarative/src/qml/qml/qqmlpropertycache.cpp", line=991) at /home/luca/Documents/current/qt5/qtbase/src/corelib/global/qassert.cpp:106 #8 0x00007ffff3ea5ee5 in QQmlPropertyCache::toMetaObjectBuilder (this=0x512000060ac0, builder=...) at /home/luca/Documents/current/qt5/qtdeclarative/src/qml/qml/qqmlpropertycache.cpp:991 #9 0x00007ffff3e9e5f4 in QQmlPropertyCache::createMetaObject (this=0x512000060ac0) at /home/luca/Documents/current/qt5/qtdeclarative/src/qml/qml/qqmlpropertycache.cpp:327 #10 0x00007ffff4109c51 in QQmlInterceptorMetaObject::toDynamicMetaObject (this=0x50d000027c70, o=0x511000049d80) at /home/luca/Documents/current/qt5/qtdeclarative/src/qml/qml/qqmlvmemetaobject.cpp:416 #11 0x00007fffee6eabb9 in QObjectData::dynamicMetaObject (this=0x5190000c2680) at /home/luca/Documents/current/qt5/qtbase/src/corelib/kernel/qobject.cpp:158 #12 0x00007fffbf84453e in QQuickWindowQmlImpl::metaObject (this=0x511000049d80) at /home/luca/Documents/current/qtbuild/qtdeclarative/src/quick/Quick_autogen/include/moc_qquickwindowmodule_p.cpp:212 #13 0x00007ffff3dbebdc in QQmlNotifierEndpoint::connect (this=0x50600004e560, source=0x511000049d80, sourceSignal=47, engine=0x7fffe8f02880, doNotify=true) at /home/luca/Documents/current/qt5/qtdeclarative/src/qml/qml/qqmlnotifier.cpp:114 #14 0x00007ffff3b6a90d in QQmlBoundSignal::QQmlBoundSignal (this=0x50600004e560, target=0x511000049d80, signal=47, owner=0x511000049d80, engine=0x7fffe8f02880) at /home/luca/Documents/current/qt5/qtdeclarative/src/qml/qml/qqmlboundsignal.cpp:228 #15 0x00007ffff3dd0b75 in QQmlObjectCreator::setPropertyBinding (this=0x5120000457c0, bindingProperty=0x50700004d180, binding=0x7fffe79d04bc) at /home/luca/Documents/current/qt5/qtdeclarative/src/qml/qml/qqmlobjectcreator.cpp:1032 #16 0x00007ffff3dccde2 in QQmlObjectCreator::setupBindings (this=0x5120000457c0, mode=...) at /home/luca/Documents/current/qt5/qtdeclarative/src/qml/qml/qqmlobjectcreator.cpp:831 #17 0x00007ffff3ddd02e in QQmlObjectCreator::populateInstance (this=0x5120000457c0, index=-1, instance=0x0, bindingTarget=0x0, valueTypeProperty=0x0, binding=0x0) at /home/luca/Documents/current/qt5/qtdeclarative/src/qml/qml/qqmlobjectcreator.cpp:1831 #18 0x00007ffff3dd79fe in QQmlObjectCreator::createInstance (this=0x5120000457c0, index=0, parent=0x0, isContextObject=true) at /home/luca/Documents/current/qt5/qtdeclarative/src/qml/qml/qqmlobjectcreator.cpp:1486 #19 0x00007ffff3dc211f in QQmlObjectCreator::create (this=0x5120000457c0, subComponentIndex=-1, parent=0x0, interrupt=0x0, flags=1) at /home/luca/Documents/current/qt5/qtdeclarative/src/qml/qml/qqmlobjectcreator.cpp:205 #20 0x00007ffff3bab7e0 in QQmlComponentPrivate::beginCreate (this=0x5110000499c0, context=...) at /home/luca/Documents/current/qt5/qtdeclarative/src/qml/qml/qqmlcomponent.cpp:1123 #21 0x00007ffff3baa6b6 in QQmlComponent::beginCreate (this=0x5020000dca30, context=0x5020000db410) at /home/luca/Documents/current/qt5/qtdeclarative/src/qml/qml/qqmlcomponent.cpp:1040 #22 0x00007ffff3ba453e in QQmlComponentPrivate::doBeginCreate (this=0x5110000499c0, q=0x5020000dca30, context=0x5020000db410) at /home/luca/Documents/current/qt5/qtdeclarative/src/qml/qml/qqmlcomponent.cpp:343 #23 0x00007ffff3ba9f74 in QQmlComponentPrivate::createWithProperties (this=0x5110000499c0, parent=0x0, properties=..., context=0x0, behavior=QQmlComponentPrivate::CreateDefault, createFromQml=false) at /home/luca/Documents/current/qt5/qtdeclarative/src/qml/qml/qqmlcomponent.cpp:963 #24 0x00007ffff3ba9d5b in QQmlComponent::create (this=0x5020000dca30, context=0x0) at /home/luca/Documents/current/qt5/qtdeclarative/src/qml/qml/qqmlcomponent.cpp:929 #25 0x00007ffff3b1fa5a in QQmlApplicationEnginePrivate::finishLoad (this=0x518000044080, c=0x5020000dca30) at /home/luca/Documents/current/qt5/qtdeclarative/src/qml/qml/qqmlapplicationengine.cpp:158 #26 0x00007ffff3b200ab in QQmlApplicationEnginePrivate::ensureLoadingFinishes (this=0x518000044080, c=0x5020000dca30) at /home/luca/Documents/current/qt5/qtdeclarative/src/qml/qml/qqmlapplicationengine.cpp:185 #27 0x00007ffff3b1ec5c in QQmlApplicationEnginePrivate::startLoad (this=0x518000044080, url=..., data=..., dataFlag=false) at /home/luca/Documents/current/qt5/qtdeclarative/src/qml/qml/qqmlapplicationengine.cpp:112 #28 0x00007ffff3b21040 in QQmlApplicationEngine::load (this=0x7fffe8f02880, url=...) at /home/luca/Documents/current/qt5/qtdeclarative/src/qml/qml/qqmlapplicationengine.cpp:371 #29 0x0000555555581bb3 in main (argc=2, argv=0x7fffffffe768) at /home/luca/Documents/current/qt5/qtdeclarative/tools/qml/main.cpp:649
It is indeed not necessary to interact with possibly triggering the signal, so that the following will produce the issue just by the name being introduced:
import QtQuick import QtQuick.Controls Window { property int foo property int onFooChanged: () => {} }