Details
-
Bug
-
Resolution: Fixed
-
Not Evaluated
-
None
-
Qt Creator 15.0.0
-
None
-
Windows 10 22H2, official MinGW kits (Qt 5.15.18 and 6.8.1)
-
bfdadbac4 (dev)
Description
This problem was quite difficult to track down because:
- It doesn't always trigger reliably - sometimes it works, sometimes it doesn't. So it's not 100% clear which actions are related to the problem and which actions are red herrings.
- It possibly involves Qt Creator's "global" memory of breakpoints, which persists even after a project is closed and after Qt Creator is restarted.
Hopefully the steps below make it easy to reproduce.
I'm not sure if the problem is the QML Debugger itself, or in Qt Creator, or both.
Code
main.cpp
#include <QGuiApplication> #include <QQmlApplicationEngine> int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QQmlApplicationEngine engine(QUrl("qrc:main.qml")); return app.exec(); }
main.qml
import QtQuick 2.15 import QtQuick.Window 2.15 Window { width: 640 height: 480 visible: true Component.onCompleted: console.log("Hi") // Put breakpoint here }
Steps to reproduce
Part 1: Start with a clean slate
- Delete all breakpoints (especially QML ones) from Qt Creator: https://doc.qt.io/qtcreator/creator-how-to-manage-breakpoints.html#delete-breakpoints
- Restart Qt Creator
Part 2: Sensitize the debugging infrastructure using the HelloCube Example
- Load the Qt Quick 3D - HelloCube Example: https://doc.qt.io/qt-6/qtquick3d-hellocube-example.html
- Open main.qml and set a breakpoint on MouseArea.onClicked (Line #135 as of Qt 6.8.1: https://github.com/qt/qtquick3d/blob/v6.8.1/examples/quick3d/hellocube/main.qml#L135 )
- Select "Debug" > "Start Debugging of Startup Project"
- Click on the "Click me!" text to trigger the breakpoint
- Select "Debug" > "Stop Debugger" to terminate the session
- Close the HelloCube project
Part 3: Trigger the problem with the attached project (QmlDebuggerStudy)
- Load the attached QmlDebuggerStudy project
- Open main.qml and set a breakpoint on Componend.onCompleted (Line #9)
- Select "Debug" > "Start Debugging of Startup Project"
- Check if the breakpoint gets triggered at startup (If it fails to trigger, then you've reproduced the issue; If it triggers, try restarting Qt Creator and repeating Part 3)
Outcomes
- (Part 2.4) The breakpoint should trigger (Expected)
- (Part 3.3) The breakpoint might fail to trigger (Not Expected)
Detailed investigations
In Part 2 (when the breakpoint triggers fine), Qt Creator's Debugger Log under QML for "hellocube" shows:
d[QML] TAKING OWNERSHIP OF BREAKPOINT 1 <v8request {"arguments":{"enabled":true,"ignoreCount":0,"line":134,"target":"main.qml","type":"scriptRegExp"},"command":"setbreakpoint","seq":0,"type":"request"} ... >v8message {"body":{"breakpoints":[1],"invocationText":"expression for onClicked","script":{"name":"qrc:/main.qml"},"sourceLine":134},"event":"break","seq":2,"type":"event"}
In Part 3 (when the breakpoint fails to trigger), Qt Creator's Debugger Log under QML for "QmlDebuggerStudy" shows:
[QML] TAKING OWNERSHIP OF BREAKPOINT 1 <v8request {"arguments":{"enabled":true,"ignoreCount":0,"line":134,"target":"main.qml","type":"scriptRegExp"},"command":"setbreakpoint","seq":0,"type":"request"} d[QML] TAKING OWNERSHIP OF BREAKPOINT 2 <v8request {"arguments":{"enabled":true,"ignoreCount":0,"line":8,"target":"qrc:/main.qml","type":"scriptRegExp"},"command":"setbreakpoint","seq":1,"type":"request"} ... >v8message {"body":{"breakpoints":[],"invocationText":"expression for onCompleted","script":{"name":"qrc:main.qml"},"sourceLine":8},"event":"break","seq":3,"type":"event"}
Things to note:
- BREAKPOINT 1 is from Part 2 (HelloCube Example) while BREAKPOINT 2 is from Part 3 (QmlDebuggerStudy)
- For BREAKPOINT 2, the source URL is "qrc:/main.qml" when setting the breakpoint but "qrc:main.qml" when triggering the breakpoint. This mismatch might be related to why it fails to pause execution.
Now, sometimes (when the stars align?) Part 3 works fine and the breakpoint triggers. In this scenario, the source URL is different:
d[QML] TAKING OWNERSHIP OF BREAKPOINT 1 <v8request {"arguments":{"enabled":true,"ignoreCount":0,"line":134,"target":"main.qml","type":"scriptRegExp"},"command":"setbreakpoint","seq":0,"type":"request"} d[QML] TAKING OWNERSHIP OF BREAKPOINT 2 <v8request {"arguments":{"enabled":true,"ignoreCount":0,"line":8,"target":"main.qml","type":"scriptRegExp"},"command":"setbreakpoint","seq":1,"type":"request"} ... >v8message {"body":{"breakpoints":[2],"invocationText":"expression for onCompleted","script":{"name":"qrc:main.qml"},"sourceLine":8},"event":"break","seq":3,"type":"event"}
Notice that the source URL is now "main.qml" (not "qrc:/main.qml"). This seems to map fine to "qrc:main.qml"
Workaround
In QmlDebuggerStudy's main.cpp, change the URL from "qrc:main.qml" to "qrc:/main.qml" or "qrc:///main.qml" - these seem to always work fine.
Attachments
Issue Links
- mentioned in
-
Page Loading...