forked from qt-creator/qt-creator
CMakePM: Fix handling of qml debugging
Add a respective aspect to the build configuration for handling qml debugging from the build side similar to what we do with qmake and qbs. Qml debugging needs to get enabled on the build side before the settings on the run configuration page has an effect. Fixes: QTCREATORBUG-23541 Change-Id: I86267747601015760737d8b21978712896892a37 Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -47,6 +47,7 @@
|
||||
#include <projectexplorer/target.h>
|
||||
|
||||
#include <qtsupport/baseqtversion.h>
|
||||
#include <qtsupport/qtbuildaspects.h>
|
||||
#include <qtsupport/qtkitinformation.h>
|
||||
|
||||
#include <utils/algorithm.h>
|
||||
@@ -157,6 +158,12 @@ CMakeBuildConfiguration::CMakeBuildConfiguration(Target *target, Core::Id id)
|
||||
|
||||
setConfigurationForCMake(config);
|
||||
});
|
||||
|
||||
const auto qmlDebuggingAspect = addAspect<QtSupport::QmlDebuggingAspect>();
|
||||
qmlDebuggingAspect->setKit(target->kit());
|
||||
connect(qmlDebuggingAspect, &QtSupport::QmlDebuggingAspect::changed,
|
||||
this, &CMakeBuildConfiguration::configurationForCMakeChanged);
|
||||
|
||||
}
|
||||
|
||||
CMakeBuildConfiguration::~CMakeBuildConfiguration()
|
||||
@@ -381,6 +388,11 @@ void CMakeBuildConfiguration::setWarning(const QString &message)
|
||||
emit warningOccured(m_warning);
|
||||
}
|
||||
|
||||
bool CMakeBuildConfiguration::isQmlDebuggingEnabled() const
|
||||
{
|
||||
return aspect<QtSupport::QmlDebuggingAspect>()->setting() == TriState::Enabled;
|
||||
}
|
||||
|
||||
|
||||
QString CMakeBuildConfiguration::error() const
|
||||
{
|
||||
|
@@ -46,6 +46,11 @@ class CMakeBuildConfiguration final : public ProjectExplorer::BuildConfiguration
|
||||
{
|
||||
Q_OBJECT
|
||||
|
||||
// used in DebuggerRunConfigurationAspect
|
||||
Q_PROPERTY(bool linkQmlDebuggingLibrary
|
||||
READ isQmlDebuggingEnabled
|
||||
NOTIFY configurationForCMakeChanged)
|
||||
|
||||
friend class ProjectExplorer::BuildConfigurationFactory;
|
||||
CMakeBuildConfiguration(ProjectExplorer::Target *target, Core::Id id);
|
||||
~CMakeBuildConfiguration() final;
|
||||
@@ -93,6 +98,8 @@ private:
|
||||
void setError(const QString &message);
|
||||
void setWarning(const QString &message);
|
||||
|
||||
bool isQmlDebuggingEnabled() const;
|
||||
|
||||
CMakeConfig m_configurationForCMake;
|
||||
CMakeConfig m_initialConfiguration;
|
||||
QString m_error;
|
||||
|
@@ -37,6 +37,7 @@
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/projectexplorer.h>
|
||||
#include <projectexplorer/target.h>
|
||||
#include <qtsupport/qtbuildaspects.h>
|
||||
|
||||
#include <utils/categorysortfiltermodel.h>
|
||||
#include <utils/detailswidget.h>
|
||||
@@ -119,6 +120,15 @@ CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildConfiguration *bc)
|
||||
mainLayout->addWidget(new QLabel(tr("Build directory:")), row, 0);
|
||||
mainLayout->addWidget(buildDirChooser->lineEdit(), row, 1);
|
||||
mainLayout->addWidget(buildDirChooser->buttonAtIndex(0), row, 2);
|
||||
++row;
|
||||
|
||||
auto qmlDebugAspect = bc->aspect<QtSupport::QmlDebuggingAspect>();
|
||||
connect(qmlDebugAspect, &QtSupport::QmlDebuggingAspect::changed,
|
||||
this, [this]() { handleQmlDebugCxxFlags(); });
|
||||
auto widget = new QWidget;
|
||||
LayoutBuilder builder(widget);
|
||||
qmlDebugAspect->addToLayout(builder);
|
||||
mainLayout->addWidget(widget, row, 0, 1, 2);
|
||||
|
||||
++row;
|
||||
mainLayout->addItem(new QSpacerItem(20, 10), row, 0);
|
||||
@@ -255,6 +265,7 @@ CMakeBuildSettingsWidget::CMakeBuildSettingsWidget(CMakeBuildConfiguration *bc)
|
||||
stretcher->stretch();
|
||||
updateButtonState();
|
||||
buildDirChooser->triggerChanged(); // refresh valid state...
|
||||
handleQmlDebugCxxFlags();
|
||||
m_showProgressTimer.stop();
|
||||
m_progressIndicator->hide();
|
||||
});
|
||||
@@ -377,6 +388,45 @@ void CMakeBuildSettingsWidget::updateFromKit()
|
||||
m_configModel->setConfigurationFromKit(configHash);
|
||||
}
|
||||
|
||||
void CMakeBuildSettingsWidget::handleQmlDebugCxxFlags()
|
||||
{
|
||||
bool changed = false;
|
||||
const auto aspect = m_buildConfiguration->aspect<QtSupport::QmlDebuggingAspect>();
|
||||
const bool enable = aspect->setting() == TriState::Enabled;
|
||||
|
||||
CMakeConfig changedConfig = m_buildConfiguration->configurationForCMake();
|
||||
const CMakeConfig configList = m_buildConfiguration->configurationFromCMake();
|
||||
const QByteArrayList cxxFlags{"CMAKE_CXX_FLAGS", "CMAKE_CXX_FLAGS_DEBUG",
|
||||
"CMAKE_CXX_FLAGS_RELWITHDEBINFO"};
|
||||
const QByteArray qmlDebug("-DQT_QML_DEBUG");
|
||||
|
||||
for (CMakeConfigItem item : configList) {
|
||||
CMakeConfigItem it(item);
|
||||
|
||||
if (cxxFlags.contains(it.key)) {
|
||||
if (enable) {
|
||||
if (!it.value.contains(qmlDebug)) {
|
||||
it.value = it.value.append(' ').append(qmlDebug);
|
||||
changed = true;
|
||||
}
|
||||
} else {
|
||||
int index = it.value.indexOf(qmlDebug);
|
||||
if (index != -1) {
|
||||
it.value.remove(index, qmlDebug.length());
|
||||
changed = true;
|
||||
}
|
||||
}
|
||||
it.value = it.value.trimmed();
|
||||
changedConfig.append(it);
|
||||
}
|
||||
}
|
||||
|
||||
if (!changed)
|
||||
return;
|
||||
|
||||
m_buildConfiguration->setConfigurationForCMake(changedConfig);
|
||||
}
|
||||
|
||||
void CMakeBuildSettingsWidget::setConfigurationForCMake()
|
||||
{
|
||||
QHash<QString, QString> config;
|
||||
|
@@ -65,6 +65,7 @@ private:
|
||||
void updateButtonState();
|
||||
void updateAdvancedCheckBox();
|
||||
void updateFromKit();
|
||||
void handleQmlDebugCxxFlags();
|
||||
|
||||
void setConfigurationForCMake();
|
||||
void updateSelection(const QModelIndex ¤t, const QModelIndex &previous);
|
||||
|
@@ -35,6 +35,7 @@
|
||||
#include <coreplugin/progressmanager/progressmanager.h>
|
||||
#include <cpptools/cppprojectupdater.h>
|
||||
#include <cpptools/generatedcodemodelsupport.h>
|
||||
#include <projectexplorer/projectexplorerconstants.h>
|
||||
#include <projectexplorer/kitmanager.h>
|
||||
#include <projectexplorer/project.h>
|
||||
#include <projectexplorer/target.h>
|
||||
@@ -699,6 +700,8 @@ void CMakeBuildSystem::updateQmlJSCodeModel()
|
||||
foreach (const QString &cmakeImport, CMakeConfigItem::cmakeSplitValue(cmakeImports))
|
||||
projectInfo.importPaths.maybeInsert(FilePath::fromString(cmakeImport), QmlJS::Dialect::Qml);
|
||||
|
||||
project()->setProjectLanguage(ProjectExplorer::Constants::QMLJS_LANGUAGE_ID,
|
||||
!projectInfo.sourceFiles.isEmpty());
|
||||
modelManager->updateProjectInfo(projectInfo, p);
|
||||
}
|
||||
|
||||
|
@@ -38,10 +38,9 @@ public:
|
||||
QmlDebuggingAspect();
|
||||
|
||||
void setKit(const ProjectExplorer::Kit *kit) { m_kit = kit; }
|
||||
|
||||
private:
|
||||
void addToLayout(ProjectExplorer::LayoutBuilder &builder) override;
|
||||
|
||||
private:
|
||||
const ProjectExplorer::Kit *m_kit = nullptr;
|
||||
};
|
||||
|
||||
|
Reference in New Issue
Block a user