forked from qt-creator/qt-creator
ProjectExplorer: Fix crash when triggering Kit name changes
Amends 7d3091a7b9.
Change-Id: Ibb18ffef49f8b9739121dcbfa29639d5e3f6a71b
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
This commit is contained in:
@@ -548,23 +548,25 @@ void GenericListWidget::displayNameChanged()
|
|||||||
if (currentItem())
|
if (currentItem())
|
||||||
activeObject = currentItem()->data(Qt::UserRole).value<QObject *>();
|
activeObject = currentItem()->data(Qt::UserRole).value<QObject *>();
|
||||||
|
|
||||||
auto *pc = qobject_cast<ProjectConfiguration *>(sender());
|
QObject *obj = sender();
|
||||||
int index = -1;
|
int index = -1;
|
||||||
int i = 0;
|
int i = 0;
|
||||||
for (; i < count(); ++i) {
|
for (; i < count(); ++i) {
|
||||||
QListWidgetItem *lwi = item(i);
|
QListWidgetItem *lwi = item(i);
|
||||||
if (lwi->data(Qt::UserRole).value<ProjectConfiguration *>() == pc) {
|
if (lwi->data(Qt::UserRole).value<QObject *>() == obj) {
|
||||||
index = i;
|
index = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (index == -1)
|
if (index == -1)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
const QString displayName = displayNameFor(obj);
|
||||||
QListWidgetItem *lwi = takeItem(i);
|
QListWidgetItem *lwi = takeItem(i);
|
||||||
lwi->setText(pc->displayName());
|
lwi->setText(displayName);
|
||||||
int pos = count();
|
int pos = count();
|
||||||
for (int i = 0; i < count(); ++i) {
|
for (int i = 0; i < count(); ++i) {
|
||||||
if (caseFriendlyCompare(displayNameFor(pc), displayNameFor(objectAt(i))) < 0) {
|
if (caseFriendlyCompare(displayName, displayNameFor(objectAt(i))) < 0) {
|
||||||
pos = i;
|
pos = i;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -585,10 +587,11 @@ void GenericListWidget::displayNameChanged()
|
|||||||
|
|
||||||
void GenericListWidget::toolTipChanged()
|
void GenericListWidget::toolTipChanged()
|
||||||
{
|
{
|
||||||
auto *pc = qobject_cast<ProjectConfiguration *>(sender());
|
QObject *obj = sender();
|
||||||
if (QListWidgetItem *lwi = itemForProjectConfiguration(pc)) {
|
if (QListWidgetItem *lwi = itemForProjectConfiguration(obj)) {
|
||||||
lwi->setData(Qt::ToolTipRole, pc->toolTip());
|
const QString toolTip = toolTipFor(obj);
|
||||||
lwi->setData(Qt::UserRole + 1, pc->toolTip());
|
lwi->setData(Qt::ToolTipRole, toolTip);
|
||||||
|
lwi->setData(Qt::UserRole + 1, toolTip);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user