App stoped working after `QTP0004 = NEW`
-
I've upgraded from v6.5 to v6.8. Then I've got CMake warnings regarding QTP0004, and switched it on as required:
if(QT_KNOWN_POLICY_QTP0004) qt_policy(SET QTP0004 NEW) endif() qt_add_qml_module(${PROJECT_NAME} URI "myapp" QML_FILES ${QML_FILES} )
After that I have no any CMake warnings, but the app just stopped working (it exits without showing GUI). Logs:
... qt.qml.import: addImplicitImport: qrc:/qt/qml/myapp/UI/MainWindow.qml qt.qml.import: addFileImport: qrc:/qt/qml/myapp/UI/MainWindow.qml "." version "(latest)" as "" qt.qml.import: importExtension: qrc:/qt/qml/myapp/UI/MainWindow.qml loaded ":/qt/qml/myapp/UI/qmldir" qt.qml.diskcache: "qrc:/qt/qml/myapp/UI/MainWindow.qml: \"myapp\" is ambiguous. Found in qrc:/qt/qml/myapp/ and in qrc:/qt/qml/myapp/" QQmlApplicationEngine failed to load component qrc:/qt/qml/myapp/UI/MainWindow.qml: "myapp" is ambiguous. Found in qrc:/qt/qml/myapp/ and in qrc:/qt/qml/myapp/ The thread 'QQmlThread' (41572) has exited with code 0 (0x0). qt.qml.gc.statistics: Qml GC memory allocation statistics: qt.qml.gc.statistics: Total memory allocated: 0 ...
The strange error: "myapp" is ambiguous. Found in qrc:/qt/qml/myapp/ and in qrc:/qt/qml/myapp/
What does it mean, and how to fix it? -
Reverting to
SET QTP0004 OLD
fix the problem. But there is CMake warning... -
Hi, it's a bit hard to tell what is causing the issue without more information. Could you describe how the files stored in
${QML_FILES}
are structured? Do you have QML files which are part of your module and which explicitly import the module itself?But generally, this sounds like a bug (in Qt itself) – if only to improve the warning message – and I'd be interested in a bug report.
Lastly, as a workaround to avoid warnings, you could also set the "NO_GENERATE_EXTRA_QMLDIRS" option instead of setting the policy to old (if the Qt version is high enough).