Commit 019be3e8 authored by Friedemann Kleint's avatar Friedemann Kleint

Debugger: Improve gdb binary settings handling.

- Remove non-executable entries  on reading (check only
  absolute paths since path search is too expensive).
- Make sure gdb binary settings are not written out unless the
  user really changes them.
Reviewed-by: default avataraep <arvid.picciani@nokia.com>
Acked-By: hjk
Reviewed-by: default avatarTim Jenssen <tim.jenssen@nokia.com>
parent 7a0e15b1
......@@ -41,6 +41,7 @@
#include <QtCore/QDebug>
#include <QtCore/QVariant>
#include <QtCore/QSettings>
#include <QtCore/QFileInfo>
#include <QtGui/QAction>
#include <QtGui/QAbstractButton>
......@@ -64,7 +65,7 @@ namespace Internal {
//////////////////////////////////////////////////////////////////////////
DebuggerSettings::DebuggerSettings(QObject *parent)
: QObject(parent)
: QObject(parent), m_gdbBinariesChanged(false)
{}
DebuggerSettings::~DebuggerSettings()
......@@ -72,6 +73,17 @@ DebuggerSettings::~DebuggerSettings()
qDeleteAll(m_items);
}
DebuggerSettings::GdbBinaryToolChainMap DebuggerSettings::gdbBinaryToolChainMap() const
{
return m_gdbBinaryToolChainMap;
}
void DebuggerSettings::setGdbBinaryToolChainMap(const GdbBinaryToolChainMap &map)
{
m_gdbBinaryToolChainMap = map;
m_gdbBinariesChanged = true;
}
void DebuggerSettings::insertItem(int code, SavedAction *item)
{
QTC_ASSERT(!m_items.contains(code),
......@@ -82,9 +94,22 @@ void DebuggerSettings::insertItem(int code, SavedAction *item)
}
void DebuggerSettings::readSettings(const QSettings *settings)
{
foreach (SavedAction *item, m_items)
item->readSettings(settings);
readGdbBinarySettings(settings);
}
void DebuggerSettings::writeSettings(QSettings *settings) const
{
foreach (SavedAction *item, m_items)
item->readSettings(settings);
item->writeSettings(settings);
if (m_gdbBinariesChanged)
writeGdbBinarySettings(settings);
}
void DebuggerSettings::readGdbBinarySettings(const QSettings *settings)
{
// Convert gdb binaries from flat settings list (see writeSettings)
// into map ("binary1=gdb,1,2", "binary2=symbian_gdb,3,4").
m_gdbBinaryToolChainMap.clear();
......@@ -100,6 +125,16 @@ void DebuggerSettings::readSettings(const QSettings *settings)
if (tokens.size() < 2)
break;
const QString binary = tokens.front();
// Skip non-existent absolute binaries allowing for upgrades by the installer.
// Force a rewrite of the settings file.
const QFileInfo binaryInfo(binary);
if (binaryInfo.isAbsolute() && !binaryInfo.isExecutable()) {
m_gdbBinariesChanged = true;
const QString msg = QString::fromLatin1("Warning: The gdb binary '%1' does not exist, skipping.\n").arg(binary);
qWarning("%s", qPrintable(msg));
continue;
}
// Create entries for all toolchains.
tokens.pop_front();
foreach(const QString &t, tokens) {
// Paranoia: Check if the there is already a binary configured for the toolchain.
......@@ -129,10 +164,8 @@ void DebuggerSettings::readSettings(const QSettings *settings)
#endif
}
void DebuggerSettings::writeSettings(QSettings *settings) const
void DebuggerSettings::writeGdbBinarySettings(QSettings *settings) const
{
foreach (SavedAction *item, m_items)
item->writeSettings(settings);
// Convert gdb binaries map into a flat settings list of
// ("binary1=gdb,1,2", "binary2=symbian_gdb,3,4"). It needs to be ASCII for installers
QString lastBinary;
......
......@@ -55,10 +55,8 @@ public:
explicit DebuggerSettings(QObject *parent = 0);
~DebuggerSettings();
GdbBinaryToolChainMap gdbBinaryToolChainMap() const
{ return m_gdbBinaryToolChainMap; }
void setGdbBinaryToolChainMap(const GdbBinaryToolChainMap &map)
{ m_gdbBinaryToolChainMap = map; }
GdbBinaryToolChainMap gdbBinaryToolChainMap() const;
void setGdbBinaryToolChainMap(const GdbBinaryToolChainMap &map);
void insertItem(int code, Utils::SavedAction *item);
Utils::SavedAction *item(int code) const;
......@@ -72,11 +70,14 @@ public slots:
void writeSettings(QSettings *settings) const;
private:
void readGdbBinarySettings(const QSettings *settings);
void writeGdbBinarySettings(QSettings *settings) const;
QHash<int, Utils::SavedAction *> m_items;
GdbBinaryToolChainMap m_gdbBinaryToolChainMap;
bool m_gdbBinariesChanged;
};
///////////////////////////////////////////////////////////
enum DebuggerActionCode
......
......@@ -276,7 +276,8 @@ GdbChooserWidget::GdbChooserWidget(QWidget *parent) :
m_treeView(new QTreeView),
m_model(new GdbBinaryModel),
m_addButton(new QToolButton),
m_deleteButton(new QToolButton)
m_deleteButton(new QToolButton),
m_dirty(false)
{
QHBoxLayout *mainHLayout = new QHBoxLayout;
......@@ -339,6 +340,7 @@ void GdbChooserWidget::slotAdd()
}
// Add binary + toolchain to model
m_model->append(path, binaryDialog.toolChains());
m_dirty = true;
}
void GdbChooserWidget::slotRemove()
......@@ -350,6 +352,7 @@ void GdbChooserWidget::slotRemove()
void GdbChooserWidget::removeItem(QStandardItem *item)
{
m_model->removeRow(item->row());
m_dirty = true;
}
void GdbChooserWidget::slotCurrentChanged(const QModelIndex &current, const QModelIndex &)
......@@ -382,6 +385,7 @@ void GdbChooserWidget::slotDoubleClicked(const QModelIndex &current)
GdbBinaryModel::setBinaryItem(m_model->item(row, binaryColumn), newBinary);
GdbBinaryModel::setToolChainItem(m_model->item(row, toolChainColumn), newToolChains);
m_dirty = true;
}
GdbChooserWidget::BinaryToolChainMap GdbChooserWidget::gdbBinaries() const
......@@ -394,6 +398,17 @@ void GdbChooserWidget::setGdbBinaries(const BinaryToolChainMap &m)
m_model->setGdbBinaries(m);
for (int c = 0; c < ColumnCount; c++)
m_treeView->resizeColumnToContents(c);
m_dirty = false;
}
bool GdbChooserWidget::isDirty() const
{
return m_dirty;
}
void GdbChooserWidget::clearDirty()
{
m_dirty = false;
}
// -------------- ToolChainSelectorWidget
......
......@@ -68,6 +68,11 @@ public:
BinaryToolChainMap gdbBinaries() const;
void setGdbBinaries(const BinaryToolChainMap &m);
bool isDirty() const;
public slots:
void clearDirty();
private slots:
void slotAdd();
void slotRemove();
......@@ -83,6 +88,7 @@ private:
GdbBinaryModel *m_model;
QToolButton *m_addButton;
QToolButton *m_deleteButton;
bool m_dirty;
};
// Present toolchains with checkboxes grouped in QGroupBox panes
......
......@@ -131,8 +131,12 @@ QWidget *GdbOptionsPage::createPage(QWidget *parent)
void GdbOptionsPage::apply()
{
m_group.apply(Core::ICore::instance()->settings());
DebuggerSettings::instance()
->setGdbBinaryToolChainMap(m_ui.gdbChooserWidget->gdbBinaries());
if (m_ui.gdbChooserWidget->isDirty()) {
DebuggerSettings::instance()
->setGdbBinaryToolChainMap(m_ui.gdbChooserWidget->gdbBinaries());
m_ui.gdbChooserWidget->clearDirty();
}
}
void GdbOptionsPage::finish()
......
Markdown is supported
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