From cd3f56af7704240ef43fc6763dd327e8ad3a77bb Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Tue, 10 Oct 2023 17:21:10 +0200 Subject: [PATCH] Duplicate es_systems.xml command label entries are now ignored on application startup --- es-app/src/SystemData.cpp | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/es-app/src/SystemData.cpp b/es-app/src/SystemData.cpp index d733317da..ce5ac1093 100644 --- a/es-app/src/SystemData.cpp +++ b/es-app/src/SystemData.cpp @@ -682,8 +682,21 @@ bool SystemData::loadConfig() << name << "\""; break; } - commands.emplace_back( - std::make_pair(entry.text().get(), entry.attribute("label").as_string())); + // Skip any duplicate entries (i.e. those with identical labels). + bool duplicateLabel {false}; + for (auto& command : commands) { + if (command.second == entry.attribute("label").as_string()) { + LOG(LogError) + << "Duplicate command label \"" << entry.attribute("label").as_string() + << "\" defined for system \"" << name << "\", ignoring entry"; + duplicateLabel = true; + break; + } + } + if (!duplicateLabel) { + commands.emplace_back( + std::make_pair(entry.text().get(), entry.attribute("label").as_string())); + } } // Platform ID list