From 3f78a9de01ddc1aa845d845fffa60163da352e03 Mon Sep 17 00:00:00 2001 From: Kevin Matz Date: Mon, 28 Nov 2022 09:39:11 -0500 Subject: [PATCH] use Qt API, not STL, for map operation --- platform/qt/qsacnuniverse.cpp | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/platform/qt/qsacnuniverse.cpp b/platform/qt/qsacnuniverse.cpp index cea43ec..ec0a66e 100644 --- a/platform/qt/qsacnuniverse.cpp +++ b/platform/qt/qsacnuniverse.cpp @@ -238,27 +238,26 @@ void QSacnUniverse::setValue (const uint16_t addr, const uint16_t size, */ void QSacnUniverse::syncSources() { + // create a new list of sources QMap newSources; auto headers = universe_->sources(); for (const auto & metadata : headers) { - auto it = sources_.find(metadata); - if (it == sources_.end()) - { // not found + if (sources_.contains(metadata)) + // move the QSacnUniverse to the new list + newSources.insert(metadata, sources_.take(metadata)); + else + { // make a new QSacnUniverse to add to the new list auto universe = universe_->sourceUniverse(metadata); newSources.insert(metadata, new QSacnUniverse(this, universe)); } - else - { // found - auto universe = sources_.take(metadata); - newSources.insert(metadata, universe); - } } - // delete any remaining QSacnUniverse, ie. not moved to the new list + // delete any remaining sources, ie. not moved to the new list qDeleteAll(sources_); + // accept the new list sources_ = newSources; emit sourceListChanged(); }