Commit 6ab4adab authored by hjk's avatar hjk Committed by Tobias Hunger
Browse files

Debugger: Prevent overwriting of pre-defined Abi values



Todo: Add a button to rescan ABIs to UI after UI freeze.
Currently you have to change the debugger command and then
change it back when replacing a debugger with a debugger for
something else in place.

Task-number: QTCREATORBUG-10755
Change-Id: Id3cf1da3f198b60e6c538e5478b11f1d6d379ff9
Reviewed-by: default avatarhjk <hjk121@nokiamail.com>
Reviewed-by: default avatarTobias Hunger <tobias.hunger@digia.com>
parent 634519a5
......@@ -42,6 +42,7 @@
namespace Debugger {
class DebuggerItemManager;
namespace Internal {
class DebuggerItemConfigWidget;
class DebuggerItemModel;
......@@ -63,7 +64,6 @@ public:
QString engineTypeName() const;
QVariantMap toMap() const;
void reinitializeFromFile();
QVariant id() const { return m_id; }
......@@ -92,6 +92,7 @@ public:
private:
DebuggerItem(const QVariant &id);
void reinitializeFromFile();
QVariant m_id;
QString m_displayName;
......@@ -102,6 +103,7 @@ private:
friend class Internal::DebuggerItemConfigWidget;
friend class Internal::DebuggerItemModel;
friend class DebuggerItemManager;
};
} // namespace Debugger
......
......@@ -433,10 +433,18 @@ void DebuggerItemManager::setItemData(const QVariant &id, const QString &display
for (int i = 0, n = m_debuggers.size(); i != n; ++i) {
DebuggerItem &item = m_debuggers[i];
if (item.id() == id) {
item.setDisplayName(displayName);
item.setCommand(fileName);
item.reinitializeFromFile();
emit m_instance->debuggerUpdated(id);
bool changed = false;
if (item.displayName() != displayName) {
item.setDisplayName(displayName);
changed = true;
}
if (item.command() != fileName) {
item.setCommand(fileName);
item.reinitializeFromFile();
changed = true;
}
if (changed)
emit m_instance->debuggerUpdated(id);
break;
}
}
......
......@@ -39,6 +39,7 @@
#include <utils/qtcassert.h>
#include <utils/winutils.h>
#include <QFileInfo>
#include <QFormLayout>
#include <QHeaderView>
#include <QLabel>
......@@ -59,26 +60,6 @@ static const char debuggingToolsWikiLinkC[] = "http://qt-project.org/wiki/Qt_Cre
// DebuggerItemConfigWidget
// -----------------------------------------------------------------------
class DebuggerItemConfigWidget : public QWidget
{
Q_DECLARE_TR_FUNCTIONS(Debugger::Internal::DebuggerItemConfigWidget)
public:
explicit DebuggerItemConfigWidget(DebuggerItemModel *model);
DebuggerItem store() const;
void setItem(const DebuggerItem &item);
void apply();
private:
QLineEdit *m_displayNameLineEdit;
QLabel *m_cdbLabel;
PathChooser *m_binaryChooser;
QLineEdit *m_abis;
DebuggerItemModel *m_model;
bool m_autodetected;
QVariant m_id;
};
DebuggerItemConfigWidget::DebuggerItemConfigWidget(DebuggerItemModel *model) :
m_model(model)
{
......@@ -90,6 +71,7 @@ DebuggerItemConfigWidget::DebuggerItemConfigWidget(DebuggerItemModel *model) :
m_binaryChooser->setExpectedKind(PathChooser::ExistingCommand);
m_binaryChooser->setMinimumWidth(400);
m_binaryChooser->setHistoryCompleter(QLatin1String("DebuggerPaths"));
connect(m_binaryChooser, SIGNAL(changed(QString)), this, SLOT(commandWasChanged()));
m_cdbLabel = new QLabel(this);
m_cdbLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
......@@ -107,7 +89,7 @@ DebuggerItemConfigWidget::DebuggerItemConfigWidget(DebuggerItemModel *model) :
formLayout->addRow(new QLabel(tr("ABIs:")), m_abis);
}
DebuggerItem DebuggerItemConfigWidget::store() const
DebuggerItem DebuggerItemConfigWidget::item() const
{
DebuggerItem item(m_id);
if (m_id.isNull())
......@@ -116,11 +98,28 @@ DebuggerItem DebuggerItemConfigWidget::store() const
item.setDisplayName(m_displayNameLineEdit->text());
item.setCommand(m_binaryChooser->fileName());
item.setAutoDetected(m_autodetected);
item.reinitializeFromFile();
m_model->updateDebugger(item);
QList<ProjectExplorer::Abi> abiList;
foreach (const QString &a, m_abis->text().split(QRegExp(QLatin1String("[^A-Za-z0-9-_]+")))) {
ProjectExplorer::Abi abi(a);
if (a.isNull())
continue;
abiList << a;
}
item.setAbis(abiList);
return item;
}
void DebuggerItemConfigWidget::store() const
{
m_model->updateDebugger(item());
}
void DebuggerItemConfigWidget::setAbis(const QStringList &abiNames)
{
m_abis->setText(abiNames.join(QLatin1String(", ")));
}
void DebuggerItemConfigWidget::setItem(const DebuggerItem &item)
{
store(); // store away the (changed) settings for future use
......@@ -157,17 +156,34 @@ void DebuggerItemConfigWidget::setItem(const DebuggerItem &item)
m_cdbLabel->setVisible(!text.isEmpty());
m_binaryChooser->setCommandVersionArguments(QStringList(versionCommand));
m_abis->setText(item.abiNames().join(QLatin1String(", ")));
setAbis(item.abiNames());
}
void DebuggerItemConfigWidget::apply()
{
DebuggerItem item = m_model->currentDebugger();
if (!item.isValid())
DebuggerItem current = m_model->currentDebugger();
if (!current.isValid())
return; // Nothing was selected here.
item = store();
setItem(item);
store();
setItem(item());
}
void DebuggerItemConfigWidget::commandWasChanged()
{
// Use DebuggerItemManager as a cache:
const DebuggerItem *existing
= DebuggerItemManager::findByCommand(m_binaryChooser->fileName());
if (existing) {
setAbis(existing->abiNames());
} else {
QFileInfo fi = QFileInfo(m_binaryChooser->path());
if (fi.isExecutable()) {
DebuggerItem tmp = item();
tmp.reinitializeFromFile();
setAbis(tmp.abiNames());
}
}
}
// --------------------------------------------------------------------------
......
......@@ -30,15 +30,23 @@
#ifndef DEBUGGER_DEBUGGEROPTIONSPAGE_H
#define DEBUGGER_DEBUGGEROPTIONSPAGE_H
#include "debuggeritem.h"
#include <coreplugin/dialogs/ioptionspage.h>
#include <QWidget>
QT_BEGIN_NAMESPACE
class QLabel;
class QLineEdit;
class QPushButton;
class QTreeView;
class QWidget;
QT_END_NAMESPACE
namespace Utils { class DetailsWidget; }
namespace Utils {
class DetailsWidget;
class PathChooser;
} // namespace Utils
namespace Debugger {
namespace Internal {
......@@ -47,6 +55,36 @@ class DebuggerItemModel;
class DebuggerItemConfigWidget;
class DebuggerKitConfigWidget;
// -----------------------------------------------------------------------
// DebuggerItemConfigWidget
// -----------------------------------------------------------------------
class DebuggerItemConfigWidget : public QWidget
{
Q_OBJECT
public:
explicit DebuggerItemConfigWidget(DebuggerItemModel *model);
void setItem(const DebuggerItem &item);
void apply();
private slots:
void commandWasChanged();
private:
DebuggerItem item() const;
void store() const;
void setAbis(const QStringList &abiNames);
QLineEdit *m_displayNameLineEdit;
QLabel *m_cdbLabel;
Utils::PathChooser *m_binaryChooser;
QLineEdit *m_abis;
DebuggerItemModel *m_model;
bool m_autodetected;
QVariant m_id;
};
// --------------------------------------------------------------------------
// DebuggerOptionsPage
// --------------------------------------------------------------------------
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment