Skip to content
Snippets Groups Projects
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
No related branches found
No related tags found
No related merge requests found
...@@ -42,6 +42,7 @@ ...@@ -42,6 +42,7 @@
namespace Debugger { namespace Debugger {
class DebuggerItemManager;
namespace Internal { namespace Internal {
class DebuggerItemConfigWidget; class DebuggerItemConfigWidget;
class DebuggerItemModel; class DebuggerItemModel;
...@@ -63,7 +64,6 @@ public: ...@@ -63,7 +64,6 @@ public:
QString engineTypeName() const; QString engineTypeName() const;
QVariantMap toMap() const; QVariantMap toMap() const;
void reinitializeFromFile();
QVariant id() const { return m_id; } QVariant id() const { return m_id; }
...@@ -92,6 +92,7 @@ public: ...@@ -92,6 +92,7 @@ public:
private: private:
DebuggerItem(const QVariant &id); DebuggerItem(const QVariant &id);
void reinitializeFromFile();
QVariant m_id; QVariant m_id;
QString m_displayName; QString m_displayName;
...@@ -102,6 +103,7 @@ private: ...@@ -102,6 +103,7 @@ private:
friend class Internal::DebuggerItemConfigWidget; friend class Internal::DebuggerItemConfigWidget;
friend class Internal::DebuggerItemModel; friend class Internal::DebuggerItemModel;
friend class DebuggerItemManager;
}; };
} // namespace Debugger } // namespace Debugger
......
...@@ -433,10 +433,18 @@ void DebuggerItemManager::setItemData(const QVariant &id, const QString &display ...@@ -433,10 +433,18 @@ void DebuggerItemManager::setItemData(const QVariant &id, const QString &display
for (int i = 0, n = m_debuggers.size(); i != n; ++i) { for (int i = 0, n = m_debuggers.size(); i != n; ++i) {
DebuggerItem &item = m_debuggers[i]; DebuggerItem &item = m_debuggers[i];
if (item.id() == id) { if (item.id() == id) {
item.setDisplayName(displayName); bool changed = false;
item.setCommand(fileName); if (item.displayName() != displayName) {
item.reinitializeFromFile(); item.setDisplayName(displayName);
emit m_instance->debuggerUpdated(id); changed = true;
}
if (item.command() != fileName) {
item.setCommand(fileName);
item.reinitializeFromFile();
changed = true;
}
if (changed)
emit m_instance->debuggerUpdated(id);
break; break;
} }
} }
......
...@@ -39,6 +39,7 @@ ...@@ -39,6 +39,7 @@
#include <utils/qtcassert.h> #include <utils/qtcassert.h>
#include <utils/winutils.h> #include <utils/winutils.h>
#include <QFileInfo>
#include <QFormLayout> #include <QFormLayout>
#include <QHeaderView> #include <QHeaderView>
#include <QLabel> #include <QLabel>
...@@ -59,26 +60,6 @@ static const char debuggingToolsWikiLinkC[] = "http://qt-project.org/wiki/Qt_Cre ...@@ -59,26 +60,6 @@ static const char debuggingToolsWikiLinkC[] = "http://qt-project.org/wiki/Qt_Cre
// DebuggerItemConfigWidget // 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) : DebuggerItemConfigWidget::DebuggerItemConfigWidget(DebuggerItemModel *model) :
m_model(model) m_model(model)
{ {
...@@ -90,6 +71,7 @@ DebuggerItemConfigWidget::DebuggerItemConfigWidget(DebuggerItemModel *model) : ...@@ -90,6 +71,7 @@ DebuggerItemConfigWidget::DebuggerItemConfigWidget(DebuggerItemModel *model) :
m_binaryChooser->setExpectedKind(PathChooser::ExistingCommand); m_binaryChooser->setExpectedKind(PathChooser::ExistingCommand);
m_binaryChooser->setMinimumWidth(400); m_binaryChooser->setMinimumWidth(400);
m_binaryChooser->setHistoryCompleter(QLatin1String("DebuggerPaths")); m_binaryChooser->setHistoryCompleter(QLatin1String("DebuggerPaths"));
connect(m_binaryChooser, SIGNAL(changed(QString)), this, SLOT(commandWasChanged()));
m_cdbLabel = new QLabel(this); m_cdbLabel = new QLabel(this);
m_cdbLabel->setTextInteractionFlags(Qt::TextBrowserInteraction); m_cdbLabel->setTextInteractionFlags(Qt::TextBrowserInteraction);
...@@ -107,7 +89,7 @@ DebuggerItemConfigWidget::DebuggerItemConfigWidget(DebuggerItemModel *model) : ...@@ -107,7 +89,7 @@ DebuggerItemConfigWidget::DebuggerItemConfigWidget(DebuggerItemModel *model) :
formLayout->addRow(new QLabel(tr("ABIs:")), m_abis); formLayout->addRow(new QLabel(tr("ABIs:")), m_abis);
} }
DebuggerItem DebuggerItemConfigWidget::store() const DebuggerItem DebuggerItemConfigWidget::item() const
{ {
DebuggerItem item(m_id); DebuggerItem item(m_id);
if (m_id.isNull()) if (m_id.isNull())
...@@ -116,11 +98,28 @@ DebuggerItem DebuggerItemConfigWidget::store() const ...@@ -116,11 +98,28 @@ DebuggerItem DebuggerItemConfigWidget::store() const
item.setDisplayName(m_displayNameLineEdit->text()); item.setDisplayName(m_displayNameLineEdit->text());
item.setCommand(m_binaryChooser->fileName()); item.setCommand(m_binaryChooser->fileName());
item.setAutoDetected(m_autodetected); item.setAutoDetected(m_autodetected);
item.reinitializeFromFile(); QList<ProjectExplorer::Abi> abiList;
m_model->updateDebugger(item); 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; 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) void DebuggerItemConfigWidget::setItem(const DebuggerItem &item)
{ {
store(); // store away the (changed) settings for future use store(); // store away the (changed) settings for future use
...@@ -157,17 +156,34 @@ void DebuggerItemConfigWidget::setItem(const DebuggerItem &item) ...@@ -157,17 +156,34 @@ void DebuggerItemConfigWidget::setItem(const DebuggerItem &item)
m_cdbLabel->setVisible(!text.isEmpty()); m_cdbLabel->setVisible(!text.isEmpty());
m_binaryChooser->setCommandVersionArguments(QStringList(versionCommand)); m_binaryChooser->setCommandVersionArguments(QStringList(versionCommand));
m_abis->setText(item.abiNames().join(QLatin1String(", "))); setAbis(item.abiNames());
} }
void DebuggerItemConfigWidget::apply() void DebuggerItemConfigWidget::apply()
{ {
DebuggerItem item = m_model->currentDebugger(); DebuggerItem current = m_model->currentDebugger();
if (!item.isValid()) if (!current.isValid())
return; // Nothing was selected here. return; // Nothing was selected here.
item = store(); store();
setItem(item); 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 @@ ...@@ -30,15 +30,23 @@
#ifndef DEBUGGER_DEBUGGEROPTIONSPAGE_H #ifndef DEBUGGER_DEBUGGEROPTIONSPAGE_H
#define DEBUGGER_DEBUGGEROPTIONSPAGE_H #define DEBUGGER_DEBUGGEROPTIONSPAGE_H
#include "debuggeritem.h"
#include <coreplugin/dialogs/ioptionspage.h> #include <coreplugin/dialogs/ioptionspage.h>
#include <QWidget>
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE
class QLabel;
class QLineEdit;
class QPushButton; class QPushButton;
class QTreeView; class QTreeView;
class QWidget;
QT_END_NAMESPACE QT_END_NAMESPACE
namespace Utils { class DetailsWidget; } namespace Utils {
class DetailsWidget;
class PathChooser;
} // namespace Utils
namespace Debugger { namespace Debugger {
namespace Internal { namespace Internal {
...@@ -47,6 +55,36 @@ class DebuggerItemModel; ...@@ -47,6 +55,36 @@ class DebuggerItemModel;
class DebuggerItemConfigWidget; class DebuggerItemConfigWidget;
class DebuggerKitConfigWidget; 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 // DebuggerOptionsPage
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment