Debugger: Only enable C++ language if project says so

Fix a regression from 2.7: A new .qmlproject did also have C++ enabled
as a debugger language by default. Instead of reviving the old, hacky
logic from 2.7 that directly manipulated the aspect object,
the aspect now checks for the actual project language, along the logic
of the QML language check.

Change-Id: I77c9323fd59079c42874dadf4dc54b9991204d9d
Reviewed-by: hjk <hjk121@nokiamail.com>
Reviewed-by: Aurindam Jana <aurindam.jana@digia.com>
This commit is contained in:
Kai Koehne
2013-06-07 09:20:48 +02:00
parent c64ae55799
commit d5b48c0c92
2 changed files with 34 additions and 22 deletions

View File

@@ -47,6 +47,7 @@
#include <QLabel> #include <QLabel>
static const char USE_CPP_DEBUGGER_KEY[] = "RunConfiguration.UseCppDebugger"; static const char USE_CPP_DEBUGGER_KEY[] = "RunConfiguration.UseCppDebugger";
static const char USE_CPP_DEBUGGER_AUTO_KEY[] = "RunConfiguration.UseCppDebuggerAuto";
static const char USE_QML_DEBUGGER_KEY[] = "RunConfiguration.UseQmlDebugger"; static const char USE_QML_DEBUGGER_KEY[] = "RunConfiguration.UseQmlDebugger";
static const char USE_QML_DEBUGGER_AUTO_KEY[] = "RunConfiguration.UseQmlDebuggerAuto"; static const char USE_QML_DEBUGGER_AUTO_KEY[] = "RunConfiguration.UseQmlDebuggerAuto";
static const char QML_DEBUG_SERVER_PORT_KEY[] = "RunConfiguration.QmlDebugServerPort"; static const char QML_DEBUG_SERVER_PORT_KEY[] = "RunConfiguration.QmlDebugServerPort";
@@ -161,7 +162,9 @@ void DebuggerRunConfigWidget::qmlDebugServerPortChanged(int port)
void DebuggerRunConfigWidget::useCppDebuggerToggled(bool on) void DebuggerRunConfigWidget::useCppDebuggerToggled(bool on)
{ {
m_aspect->m_useCppDebugger = on; m_aspect->m_useCppDebugger = on
? DebuggerRunConfigurationAspect::EnabledLanguage
: DebuggerRunConfigurationAspect::DisabledLanguage;
if (!on && !m_useQmlDebugger->isChecked()) if (!on && !m_useQmlDebugger->isChecked())
m_useQmlDebugger->setChecked(true); m_useQmlDebugger->setChecked(true);
} }
@@ -172,8 +175,8 @@ void DebuggerRunConfigWidget::useQmlDebuggerToggled(bool on)
m_debugServerPortLabel->setEnabled(on); m_debugServerPortLabel->setEnabled(on);
m_aspect->m_useQmlDebugger = on m_aspect->m_useQmlDebugger = on
? DebuggerRunConfigurationAspect::EnableQmlDebugger ? DebuggerRunConfigurationAspect::EnabledLanguage
: DebuggerRunConfigurationAspect::DisableQmlDebugger; : DebuggerRunConfigurationAspect::DisabledLanguage;
if (!on && !m_useCppDebugger->isChecked()) if (!on && !m_useCppDebugger->isChecked())
m_useCppDebugger->setChecked(true); m_useCppDebugger->setChecked(true);
} }
@@ -192,8 +195,8 @@ void DebuggerRunConfigWidget::useMultiProcessToggled(bool on)
DebuggerRunConfigurationAspect::DebuggerRunConfigurationAspect( DebuggerRunConfigurationAspect::DebuggerRunConfigurationAspect(
ProjectExplorer::RunConfiguration *rc) : ProjectExplorer::RunConfiguration *rc) :
m_runConfiguration(rc), m_runConfiguration(rc),
m_useCppDebugger(true), m_useCppDebugger(AutoEnabledLanguage),
m_useQmlDebugger(AutoEnableQmlDebugger), m_useQmlDebugger(AutoEnabledLanguage),
m_qmlDebugServerPort(Constants::QML_DEFAULT_DEBUG_SERVER_PORT), m_qmlDebugServerPort(Constants::QML_DEFAULT_DEBUG_SERVER_PORT),
m_useMultiProcess(false) m_useMultiProcess(false)
{ {
@@ -219,27 +222,30 @@ ProjectExplorer::RunConfiguration *DebuggerRunConfigurationAspect::runConfigurat
void DebuggerRunConfigurationAspect::setUseQmlDebugger(bool value) void DebuggerRunConfigurationAspect::setUseQmlDebugger(bool value)
{ {
m_useQmlDebugger = value ? EnableQmlDebugger : DisableQmlDebugger; m_useQmlDebugger = value ? EnabledLanguage : DisabledLanguage;
emit debuggersChanged(); emit debuggersChanged();
} }
void DebuggerRunConfigurationAspect::setUseCppDebugger(bool value) void DebuggerRunConfigurationAspect::setUseCppDebugger(bool value)
{ {
m_useCppDebugger = value; m_useCppDebugger = value ? EnabledLanguage : DisabledLanguage;
emit debuggersChanged(); emit debuggersChanged();
} }
bool DebuggerRunConfigurationAspect::useCppDebugger() const bool DebuggerRunConfigurationAspect::useCppDebugger() const
{ {
return m_useCppDebugger; if (m_useCppDebugger == DebuggerRunConfigurationAspect::AutoEnabledLanguage)
return m_runConfiguration->target()->project()->projectLanguages().contains(
ProjectExplorer::Constants::LANG_CXX);
return m_useCppDebugger == DebuggerRunConfigurationAspect::EnabledLanguage;
} }
bool DebuggerRunConfigurationAspect::useQmlDebugger() const bool DebuggerRunConfigurationAspect::useQmlDebugger() const
{ {
if (m_useQmlDebugger == DebuggerRunConfigurationAspect::AutoEnableQmlDebugger) if (m_useQmlDebugger == DebuggerRunConfigurationAspect::AutoEnabledLanguage)
return m_runConfiguration->target()->project()->projectLanguages().contains( return m_runConfiguration->target()->project()->projectLanguages().contains(
ProjectExplorer::Constants::LANG_QMLJS); ProjectExplorer::Constants::LANG_QMLJS);
return m_useQmlDebugger == DebuggerRunConfigurationAspect::EnableQmlDebugger; return m_useQmlDebugger == DebuggerRunConfigurationAspect::EnabledLanguage;
} }
uint DebuggerRunConfigurationAspect::qmlDebugServerPort() const uint DebuggerRunConfigurationAspect::qmlDebugServerPort() const
@@ -279,9 +285,10 @@ QString DebuggerRunConfigurationAspect::displayName() const
QVariantMap DebuggerRunConfigurationAspect::toMap() const QVariantMap DebuggerRunConfigurationAspect::toMap() const
{ {
QVariantMap map; QVariantMap map;
map.insert(QLatin1String(USE_CPP_DEBUGGER_KEY), m_useCppDebugger); map.insert(QLatin1String(USE_CPP_DEBUGGER_KEY), m_useCppDebugger == EnabledLanguage);
map.insert(QLatin1String(USE_QML_DEBUGGER_KEY), m_useQmlDebugger == EnableQmlDebugger); map.insert(QLatin1String(USE_CPP_DEBUGGER_AUTO_KEY), m_useCppDebugger == AutoEnabledLanguage);
map.insert(QLatin1String(USE_QML_DEBUGGER_AUTO_KEY), m_useQmlDebugger == AutoEnableQmlDebugger); map.insert(QLatin1String(USE_QML_DEBUGGER_KEY), m_useQmlDebugger == EnabledLanguage);
map.insert(QLatin1String(USE_QML_DEBUGGER_AUTO_KEY), m_useQmlDebugger == AutoEnabledLanguage);
map.insert(QLatin1String(QML_DEBUG_SERVER_PORT_KEY), m_qmlDebugServerPort); map.insert(QLatin1String(QML_DEBUG_SERVER_PORT_KEY), m_qmlDebugServerPort);
map.insert(QLatin1String(USE_MULTIPROCESS_KEY), m_useMultiProcess); map.insert(QLatin1String(USE_MULTIPROCESS_KEY), m_useMultiProcess);
return map; return map;
@@ -289,12 +296,17 @@ QVariantMap DebuggerRunConfigurationAspect::toMap() const
void DebuggerRunConfigurationAspect::fromMap(const QVariantMap &map) void DebuggerRunConfigurationAspect::fromMap(const QVariantMap &map)
{ {
m_useCppDebugger = map.value(QLatin1String(USE_CPP_DEBUGGER_KEY), true).toBool(); if (map.value(QLatin1String(USE_CPP_DEBUGGER_AUTO_KEY), false).toBool()) {
m_useCppDebugger = AutoEnabledLanguage;
} else {
bool useCpp = map.value(QLatin1String(USE_CPP_DEBUGGER_KEY), false).toBool();
m_useCppDebugger = useCpp ? EnabledLanguage : DisabledLanguage;
}
if (map.value(QLatin1String(USE_QML_DEBUGGER_AUTO_KEY), false).toBool()) { if (map.value(QLatin1String(USE_QML_DEBUGGER_AUTO_KEY), false).toBool()) {
m_useQmlDebugger = AutoEnableQmlDebugger; m_useQmlDebugger = AutoEnabledLanguage;
} else { } else {
bool useQml = map.value(QLatin1String(USE_QML_DEBUGGER_KEY), false).toBool(); bool useQml = map.value(QLatin1String(USE_QML_DEBUGGER_KEY), false).toBool();
m_useQmlDebugger = useQml ? EnableQmlDebugger : DisableQmlDebugger; m_useQmlDebugger = useQml ? EnabledLanguage : DisabledLanguage;
} }
m_useMultiProcess = map.value(QLatin1String(USE_MULTIPROCESS_KEY), false).toBool(); m_useMultiProcess = map.value(QLatin1String(USE_MULTIPROCESS_KEY), false).toBool();
} }

View File

@@ -48,10 +48,10 @@ public:
DebuggerRunConfigurationAspect(ProjectExplorer::RunConfiguration *runConfiguration, DebuggerRunConfigurationAspect(ProjectExplorer::RunConfiguration *runConfiguration,
const DebuggerRunConfigurationAspect *other); const DebuggerRunConfigurationAspect *other);
enum QmlDebuggerStatus { enum DebuggerLanguageStatus {
DisableQmlDebugger = 0, DisabledLanguage = 0,
EnableQmlDebugger, EnabledLanguage,
AutoEnableQmlDebugger AutoEnabledLanguage
}; };
QVariantMap toMap() const; QVariantMap toMap() const;
@@ -80,8 +80,8 @@ private:
void ctor(); void ctor();
ProjectExplorer::RunConfiguration *m_runConfiguration; ProjectExplorer::RunConfiguration *m_runConfiguration;
bool m_useCppDebugger; DebuggerLanguageStatus m_useCppDebugger;
QmlDebuggerStatus m_useQmlDebugger; DebuggerLanguageStatus m_useQmlDebugger;
uint m_qmlDebugServerPort; uint m_qmlDebugServerPort;
bool m_useMultiProcess; bool m_useMultiProcess;