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 <hjk@qt.io>
This commit is contained in:
Christian Stenger
2023-04-19 08:23:17 +02:00
parent d41365610f
commit 35df3812f7

View File

@@ -5,6 +5,8 @@
#include "debuggertr.h" #include "debuggertr.h"
#include <cppeditor/cppmodelmanager.h>
#include <coreplugin/helpmanager.h> #include <coreplugin/helpmanager.h>
#include <coreplugin/icontext.h> #include <coreplugin/icontext.h>
#include <coreplugin/icore.h> #include <coreplugin/icore.h>
@@ -251,12 +253,26 @@ bool DebuggerRunConfigurationAspect::useCppDebugger() const
return m_cppAspect->m_value == EnabledLanguage; 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 &macro){
return macro.key == "QT_DECLARATIVE_LIB"
|| macro.key == "QT_QUICK_LIB"
|| macro.key == "QT_QML_LIB";
});
});
}
bool DebuggerRunConfigurationAspect::useQmlDebugger() const bool DebuggerRunConfigurationAspect::useQmlDebugger() const
{ {
if (m_qmlAspect->m_value == AutoEnabledLanguage) { if (m_qmlAspect->m_value == AutoEnabledLanguage) {
const Core::Context languages = m_target->project()->projectLanguages(); const Core::Context languages = m_target->project()->projectLanguages();
if (!languages.contains(ProjectExplorer::Constants::QMLJS_LANGUAGE_ID)) 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 // Try to find a build configuration to check whether qml debugging is enabled there