JsonFieldPage: Be more paranoid with the index of ComboBoxes

This avoids a combobox being shown without any selection. This has
the side-effect that QTCREATORBUG-14699 can no longer get triggered.

Task-number: QTCREATORBUG-14699
Change-Id: I98f5ae503d29370ad46c6620238bc2815c024747
Reviewed-by: Christian Stenger <christian.stenger@theqtcompany.com>
This commit is contained in:
Tobias Hunger
2015-07-08 13:51:32 +02:00
parent 554700e073
commit fc7ce7f0c8

View File

@@ -820,13 +820,15 @@ void JsonFieldPage::ComboBoxField::initializeData(MacroExpander *expander)
if (!tmpConditions.at(i)) { if (!tmpConditions.at(i)) {
tmpItems.removeAt(i); tmpItems.removeAt(i);
tmpData.removeAt(i); tmpData.removeAt(i);
if (i <= index) if (i < index && index > 0)
--index; --index;
} }
} }
if (index < 0 || index >= tmpData.count())
index = 0;
w->setItems(tmpItems, tmpData); w->setItems(tmpItems, tmpData);
w->setInsertPolicy(QComboBox::NoInsert); w->setInsertPolicy(QComboBox::NoInsert);
w->setCurrentIndex(index); w->setCurrentIndex(index);
} }