Fix duplicate items in the list of known measurements.

This commit is contained in:
Roman Telezhynskyi 2023-11-21 12:33:15 +02:00
parent 6041dd52b6
commit ddb921d468
3 changed files with 9 additions and 3 deletions

View File

@ -337,6 +337,9 @@ void TapePreferencesConfigurationPage::InitKnownMeasurements(QComboBox *combo)
VKnownMeasurementsDatabase *db = MApplication::VApp()->KnownMeasurementsDatabase(); VKnownMeasurementsDatabase *db = MApplication::VApp()->KnownMeasurementsDatabase();
QHash<QUuid, VKnownMeasurementsHeader> known = db->AllKnownMeasurements(); QHash<QUuid, VKnownMeasurementsHeader> known = db->AllKnownMeasurements();
combo->blockSignals(true);
combo->clear();
SCASSERT(combo != nullptr) SCASSERT(combo != nullptr)
combo->addItem(tr("None"), QUuid()); combo->addItem(tr("None"), QUuid());
@ -355,6 +358,8 @@ void TapePreferencesConfigurationPage::InitKnownMeasurements(QComboBox *combo)
combo->addItem(name, i.key()); combo->addItem(name, i.key());
++i; ++i;
} }
combo->blockSignals(false);
} }
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------

View File

@ -71,7 +71,7 @@ private:
void InitShortcuts(bool defaults = false); void InitShortcuts(bool defaults = false);
void UpdateShortcutsTable(); void UpdateShortcutsTable();
void RetranslateShortcutsTable(); void RetranslateShortcutsTable();
void InitKnownMeasurements(QComboBox *combo); static void InitKnownMeasurements(QComboBox *combo);
void InitKnownMeasurementsDescription(); void InitKnownMeasurementsDescription();
}; };

View File

@ -4796,9 +4796,10 @@ void TMainWindow::InitKnownMeasurements(QComboBox *combo)
SCASSERT(combo != nullptr) SCASSERT(combo != nullptr)
combo->addItem(tr("None"), QUuid()); combo->addItem(tr("None"), QUuid());
if (!known.contains(m_m->KnownMeasurements())) QUuid kmId = m_m->KnownMeasurements();
if (!kmId.isNull() && !known.contains(kmId))
{ {
combo->addItem(tr("Invalid link"), m_m->KnownMeasurements()); combo->addItem(tr("Invalid link"), kmId);
} }
int index = 1; int index = 1;