Details
-
Bug
-
Resolution: Done
-
P1: Critical
-
5.11.0 Alpha
-
None
-
Qt 5.11 HEAD on 2nd March 18, Linux 64bit
-
3339bf866a68ba129e88fd7d27a2abbea0d1c6ba
Description
The lowenergyscanner example in QtBluetooth (https://doc-snapshots.qt.io/qt5-5.11/qtbluetooth-lowenergyscanner-example.html) uses a global context property:
Device d; QQuickView *view = new QQuickView; view->rootContext()->setContextProperty("device", &d);
During the execution of the example the QML engine returns a ReferenceError:
qrc:/assets/Services.qml:120: ReferenceError: device is not defined
The offending code line is triggered by the following code section:
MouseArea { anchors.fill: parent onClicked: { pageLoader.source = "Characteristics.qml"; //Line 1 device.connectToService(modelData.serviceUuid); //Line 2 } }
If Line1 and Line2 are swapped the reference error disappears. To reach this point of the example execution the following steps have to be taken:
- start lowenergyscanner
- click on "Search" (and wait until search complete)
- click on a BTLE device that you can connect to (and wait until service discovery is done)
- click on a service in the list
The last click triggers the above connectToService() call.
Attachments
Issue Links
- duplicates
-
QTBUG-66813 Changing Loader source breaks references on QML objects: 'ReferenceError: ... is not defined'
- Closed