mirror of https://github.com/qt/qtdoc.git
Dice: Ignore accelerometer reading until it's ready
The documentation for reading refers to QSensor::reading and it states that readings are not available immediately after start() is called. Instead, one should wait for the readingChanged signal. Until then, reading is documented to be null, so just check for that. This fixes 'Cannot read property x of null' warnings. Fixes: QTBUG-140395 Fixes: QTBUG-140385 Pick-to: 6.10 Change-Id: Ibb36e1d8387628eea333cb6d0537dea25f3980b6 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
This commit is contained in:
parent
ad14f02eb2
commit
d19a1e9b51
|
@ -19,6 +19,8 @@ ApplicationWindow {
|
|||
dataRate: 25
|
||||
active: true
|
||||
readonly property vector3d force: {
|
||||
if (!reading)
|
||||
return Qt.vector3d(0, 0, 0)
|
||||
let r = reading as AccelerometerReading
|
||||
return Qt.vector3d(r.x, r.y, r.z)
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue