Debugger: No soft-asserts when clicking on "Manual" or "Auto-detected"

Change-Id: I09720054c4fbec842d2d04571fd2213a67f46095
Reviewed-by: hjk <hjk121@nokiamail.com>
This commit is contained in:
Tobias Hunger
2014-04-07 17:59:30 +02:00
committed by hjk
parent b3110de645
commit f05efd3707
2 changed files with 38 additions and 23 deletions

View File

@@ -71,7 +71,6 @@ 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);
@@ -87,6 +86,8 @@ DebuggerItemConfigWidget::DebuggerItemConfigWidget(DebuggerItemModel *model) :
formLayout->addRow(m_cdbLabel); formLayout->addRow(m_cdbLabel);
formLayout->addRow(new QLabel(tr("Path:")), m_binaryChooser); formLayout->addRow(new QLabel(tr("Path:")), m_binaryChooser);
formLayout->addRow(new QLabel(tr("ABIs:")), m_abis); formLayout->addRow(new QLabel(tr("ABIs:")), m_abis);
connect(m_binaryChooser, SIGNAL(changed(QString)), this, SLOT(binaryPathHasChanged()));
} }
DebuggerItem DebuggerItemConfigWidget::item() const DebuggerItem DebuggerItemConfigWidget::item() const
@@ -123,12 +124,37 @@ void DebuggerItemConfigWidget::setAbis(const QStringList &abiNames)
m_abis->setText(abiNames.join(QLatin1String(", "))); m_abis->setText(abiNames.join(QLatin1String(", ")));
} }
void DebuggerItemConfigWidget::handleCommandChange()
{
// Use DebuggerItemManager as a cache:
const DebuggerItem *existing
= DebuggerItemManager::findByCommand(m_binaryChooser->fileName());
if (existing) {
setAbis(existing->abiNames());
m_engineType = existing->engineType();
} else {
QFileInfo fi = QFileInfo(m_binaryChooser->path());
if (fi.isExecutable()) {
DebuggerItem tmp = item();
tmp.reinitializeFromFile();
setAbis(tmp.abiNames());
m_engineType = tmp.engineType();
} else {
setAbis(QStringList());
m_engineType = NoEngineType;
}
}
m_model->updateDebugger(item());
}
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
m_id = QVariant(); // reset Id to avoid intermediate signal handling
// Set values:
m_autodetected = item.isAutoDetected(); m_autodetected = item.isAutoDetected();
m_id = item.id();
m_displayNameLineEdit->setEnabled(!item.isAutoDetected()); m_displayNameLineEdit->setEnabled(!item.isAutoDetected());
m_displayNameLineEdit->setText(item.displayName()); m_displayNameLineEdit->setText(item.displayName());
@@ -157,6 +183,7 @@ void DebuggerItemConfigWidget::setItem(const DebuggerItem &item)
setAbis(item.abiNames()); setAbis(item.abiNames());
m_engineType = item.engineType(); m_engineType = item.engineType();
m_id = item.id();
} }
void DebuggerItemConfigWidget::apply() void DebuggerItemConfigWidget::apply()
@@ -169,27 +196,13 @@ void DebuggerItemConfigWidget::apply()
setItem(item()); setItem(item());
} }
void DebuggerItemConfigWidget::commandWasChanged() void DebuggerItemConfigWidget::binaryPathHasChanged()
{ {
// Use DebuggerItemManager as a cache: // Ignore change if this is no valid DebuggerItem
const DebuggerItem *existing if (!m_id.isValid())
= DebuggerItemManager::findByCommand(m_binaryChooser->fileName()); return;
if (existing) {
setAbis(existing->abiNames()); handleCommandChange();
m_engineType = existing->engineType();
} else {
QFileInfo fi = QFileInfo(m_binaryChooser->path());
if (fi.isExecutable()) {
DebuggerItem tmp = item();
tmp.reinitializeFromFile();
setAbis(tmp.abiNames());
m_engineType = tmp.engineType();
} else {
setAbis(QStringList());
m_engineType = NoEngineType;
}
}
m_model->updateDebugger(item());
} }
// -------------------------------------------------------------------------- // --------------------------------------------------------------------------

View File

@@ -70,13 +70,15 @@ public:
void apply(); void apply();
private slots: private slots:
void commandWasChanged(); void binaryPathHasChanged();
private: private:
DebuggerItem item() const; DebuggerItem item() const;
void store() const; void store() const;
void setAbis(const QStringList &abiNames); void setAbis(const QStringList &abiNames);
void handleCommandChange();
QLineEdit *m_displayNameLineEdit; QLineEdit *m_displayNameLineEdit;
QLabel *m_cdbLabel; QLabel *m_cdbLabel;
Utils::PathChooser *m_binaryChooser; Utils::PathChooser *m_binaryChooser;