From 35df3812f7797bff5fd4ce4290f768f9bb8ca4c3 Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Wed, 19 Apr 2023 08:23:17 +0200 Subject: [PATCH] Debugger: Improve detection for the need of Qml Debugger By default QC performs an educated guess whether to enable QML debugging or not. Improve this as the detection may fail and leave the user without a special hint depending on the project structure. Fixes: QTCREATORBUG-28627 Change-Id: Ibd461aff2bf9be7058bdf33c8740ef07a457c365 Reviewed-by: hjk --- .../debuggerrunconfigurationaspect.cpp | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/src/plugins/debugger/debuggerrunconfigurationaspect.cpp b/src/plugins/debugger/debuggerrunconfigurationaspect.cpp index d8ebd2e9b1d..729857e9b20 100644 --- a/src/plugins/debugger/debuggerrunconfigurationaspect.cpp +++ b/src/plugins/debugger/debuggerrunconfigurationaspect.cpp @@ -5,6 +5,8 @@ #include "debuggertr.h" +#include + #include #include #include @@ -251,12 +253,26 @@ bool DebuggerRunConfigurationAspect::useCppDebugger() const return m_cppAspect->m_value == EnabledLanguage; } +static bool projectHasQmlDefines(ProjectExplorer::Project *project) +{ + auto projectInfo = CppEditor::CppModelManager::instance()->projectInfo(project); + QTC_ASSERT(projectInfo, return false); + return Utils::anyOf(projectInfo->projectParts(), + [](const CppEditor::ProjectPart::ConstPtr &part){ + return Utils::anyOf(part->projectMacros, [](const Macro ¯o){ + return macro.key == "QT_DECLARATIVE_LIB" + || macro.key == "QT_QUICK_LIB" + || macro.key == "QT_QML_LIB"; + }); + }); +} + bool DebuggerRunConfigurationAspect::useQmlDebugger() const { if (m_qmlAspect->m_value == AutoEnabledLanguage) { const Core::Context languages = m_target->project()->projectLanguages(); if (!languages.contains(ProjectExplorer::Constants::QMLJS_LANGUAGE_ID)) - return false; + return projectHasQmlDefines(m_target->project()); // // Try to find a build configuration to check whether qml debugging is enabled there