// src/gui/dialogs/qwizard.cpp // Proposed fix indicated by "+" in front of proposed lines. void QWizardPrivate::_q_handleFieldObjectDestroyed(QObject *object) { + int destroyed_index = -1; QVector::iterator it = fields.begin(); while (it != fields.end()) { const QWizardField &field = *it; if (field.object == object) { + destroyed_index = fieldIndexMap.value(field.name, -1); fieldIndexMap.remove(field.name); it = fields.erase(it); } else { ++it; } } + if (destroyed_index != -1) { + QMap::iterator it2 = fieldIndexMap.begin(); + while (it2 != fieldIndexMap.end()) { + int index = it2.value(); + QString field_name = it2.key(); + if (index > destroyed_index) { + fieldIndexMap.insert(field_name, index-1); + } + ++it2; + } + } }