1
0
Fork 0

use Qt API, not STL, for map operation

This commit is contained in:
Kevin Matz 2022-11-28 09:39:11 -05:00
parent 01c569ffa4
commit 3f78a9de01
1 changed files with 8 additions and 9 deletions

View File

@ -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<sACN::DATA::data_header, QSacnUniverse*> 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();
}