Commit 95fac2b0 authored by con's avatar con

Fix crash when pressing '+' twice in Qt version settings.

Bug was introduced when separating the version list into "Autodetected" and
"Manual" subtrees.
parent d384e1a4
......@@ -370,6 +370,21 @@ int QtOptionsPageWidget::indexForTreeItem(QTreeWidgetItem *item) const
return -1;
}
QTreeWidgetItem *QtOptionsPageWidget::treeItemForIndex(int index) const
{
int uniqueId = m_versions.at(index)->uniqueId();
for (int i = 0; i < m_ui->qtdirList->topLevelItemCount(); ++i) {
QTreeWidgetItem *toplevelItem = m_ui->qtdirList->topLevelItem(i);
for (int j = 0; j < toplevelItem->childCount(); ++j) {
QTreeWidgetItem *item = toplevelItem->child(j);
if (item->data(0, Qt::UserRole).toInt() == uniqueId) {
return item;
}
}
}
return 0;
}
void QtOptionsPageWidget::versionChanged(QTreeWidgetItem *item, QTreeWidgetItem *old)
{
if (old) {
......@@ -454,11 +469,11 @@ void QtOptionsPageWidget::fixQtVersionName(int index)
if (index < 0)
return;
int count = m_versions.count();
QString name = m_versions.at(index)->name();
for (int i = 0; i < count; ++i) {
if (i != index) {
if (m_versions.at(i)->name() == m_versions.at(index)->name()) {
// Same name, find new name
QString name = m_versions.at(index)->name();
QRegExp regexp("^(.*)\\((\\d)\\)$");
if (regexp.exactMatch(name)) {
// Alreay in Name (#) format
......@@ -468,7 +483,7 @@ void QtOptionsPageWidget::fixQtVersionName(int index)
}
// set new name
m_versions[index]->setName(name);
m_ui->qtdirList->topLevelItem(index)->setText(0, name);
treeItemForIndex(index)->setText(0, name);
m_ui->defaultCombo->setItemText(index, name);
// Now check again...
......
......@@ -61,6 +61,7 @@ private:
void fixQtVersionName(int index);
int indexForWidget(QWidget *debuggingHelperWidget) const;
int indexForTreeItem(QTreeWidgetItem *item) const;
QTreeWidgetItem *treeItemForIndex(int index) const;
Internal::Ui::QtVersionManager *m_ui;
QList<QtVersion *> m_versions;
......
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