Details
-
Bug
-
Resolution: Fixed
-
P1: Critical
-
6.4.2, 6.5.3
-
Mac (M1), MacOS 13.6.3, Qt Creator 11.0.3
-
-
eb79815fb (dev), 8228f07a2 (6.7), 1586ea1f1 (6.6), 724971240 (tqtc/lts-6.5), dcc6b25cd (tqtc/lts-6.2)
Description
I have encountered a strange, and 100% reproducible bug, in QML.
The project is compiled in Qt Creator in Debug mode. When the project is Run, it always crashes at the same point, following a specific UI action. I have attached a redacted crash log.
When the project is started in the debugger, there is a particular breakpoint that gets hit multiple times before it allows the following line to be evaluated, which is truly strange. In debug mode, it doesn't crash. I have attached a video snippet of the debug session showing this fault.
I'm not clear what is causing it but I hazard a guess that there may be a timing issue or conflict in the engine around:
- a QML component being created: `OoSignInLayer`
- an external signal being connected to a function in the component
- that signal being emitted
Here are the relevant code snippets...
main.qml
import QtQuick import ... Window { id: root ... QtObject { id: sessionManager ... signal ooSignInNotification(int notificationType, string errorCode) ... function handleSigningOut() { modalLayer.showModal(C.ModalLayer.OoSignIn) ooSignInNotification(C.NotificationType.Info, qsTr("You have been signed out.")) } ... } ... Item { id: modalLayer property int activeModalLayer: C.ModalLayer.None ... Loader { id: modalLoader ... sourceComponent: { switch (modalLayer.activeModalLayer) { ... case C.ModalLayer.OoSignIn: return ooSignInModalLayerComponent ... } } } ... Component { id: ooSignInModalLayerComponent FocusScope { focus: true ... OoSignInLayer { id: ooSignInLayer ... Component.onCompleted: sessionManager.ooSignOutNotification.connect(showNotification) ... } } } ... function showModal(newModalLayer) { activeModalLayer = newModalLayer visible = true } } ... }
OoSignInLayer.qml
import QtQuick FocusScope { id: root ... QtObject { id: my property int notificationType: C.NotificationType.None ... } ... function showNotification(type: int, message: string) { my.notificationType = type // The debugger gets stuck here notificationMessage.text = message usernameField.forceActiveFocus() } ... }
On clicking a particular button in the UI, some actions are taken and sessionManager.handleSigningOut() gets called. This does 3 things:
1. Calls modalLayer.showModal(C.ModalLayer.OoSignIn) which causes modalLoader to load ooSignInModalLayerComponent and make it visible, which causes an instance of OoSignInLayer to be created.
2. In main.qml within the instance of OoSignInLayer, Component.onCompleted connects the signal sessionManager.ooSignOutNotification to OoSignInLayer.showNotification().
3. Back in sessionManager.handleSigningOut(), the signal sessionManager.ooSignOutNotification() is called/emitted.
Attachments
For Gerrit Dashboard: QTBUG-123395 | ||||||
---|---|---|---|---|---|---|
# | Subject | Branch | Project | Status | CR | V |
549302,3 | QmlCompiler: Do not use QQmlEngine from current QML context | dev | qt/qtdeclarative | Status: MERGED | +2 | 0 |
550172,2 | QmlCompiler: Do not use QQmlEngine from current QML context | 6.7 | qt/qtdeclarative | Status: MERGED | +2 | 0 |
550574,3 | QmlCompiler: Do not use QQmlEngine from current QML context | 6.6 | qt/qtdeclarative | Status: MERGED | +2 | 0 |
551493,3 | QmlCompiler: Do not use QQmlEngine from current QML context | tqtc/lts-6.5 | qt/tqtc-qtdeclarative | Status: MERGED | +2 | 0 |
551715,3 | QmlCompiler: Do not use QQmlEngine from current QML context | tqtc/lts-6.2 | qt/tqtc-qtdeclarative | Status: MERGED | +2 | 0 |