Details
-
Bug
-
Resolution: Unresolved
-
P3: Somewhat important
-
None
-
5.8.0
-
None
-
Linux 64-bit
Description
Run the following test app. It throws TypeError: Cannot read property of null. If the app is run with QML debugging enabled, you get TypeError: Cannot read property 'activeFocus' of null instead. Interestingly, if you use 'parent' instead of 'myItem' in the binding, you get ReferenceError: parent is not defined instead.
There is something fishy going on - it only happens when 'activeFocus' of an ancestor is bound to a grouped property. 'activeFocus' is a special property that is recursively cleared in children during the destruction. When the error occurs, the grand parent has just started its destruction and is clearing its parent & focus, but the target item in the binding is fully alive and its QML context seems valid too, so I'm not sure why it fails to evaluate the expression like that.
import QtQuick 2.6 import QtQuick.Window 2.2 Window { id: window width: 360 height: 360 visible: true Component { id: emptyItem Item { } } Component { id: testItem Item { id: myItem Item { layer.enabled: myItem.activeFocus // <== any grouped property bound to ancestor's activeFocus } } } Component.onCompleted: { // 2 levels of parents, intentionally, to make sure that the potential fix // does not rely on something in the immediate parent. the problematic focus // clearing can originate from one of the grand parents. in this example, the // warning is thrown during the destruction of _grandparent_. var grandparent = emptyItem.createObject(window.contentItem, {objectName: "grandparent"}) var parent = emptyItem.createObject(grandparent, {objectName: "parent"}) var child = testItem.createObject(parent, {objectName: "child"}) child.forceActiveFocus() grandparent.destroy(0) } }
This results from QTBUG-57650 - strange warnings in Qt Quick Controls 2 auto tests.
Attachments
Issue Links
- resulted from
-
QTBUG-57650 "SignalSpy.qml:253: TypeError: Cannot read property of null" when running Controls 2 auto tests
-
- Closed
-