# HG changeset patch # User Chris Cannam # Date 1561398148 -3600 # Node ID bffccc8de3c15a21c97fe0950566b75373ac2aa3 # Parent c3b5564cfb782561e029407df5b5a47f9269a549 Warn for already-existing id diff -r c3b5564cfb78 -r bffccc8de3c1 base/ById.h --- a/base/ById.h Mon Jun 24 14:28:17 2019 +0100 +++ b/base/ById.h Mon Jun 24 18:42:28 2019 +0100 @@ -15,6 +15,8 @@ #ifndef SV_BY_ID_H #define SV_BY_ID_H +#include "Debug.h" + #include #include #include @@ -80,17 +82,23 @@ QMutexLocker locker(&m_mutex); for (const auto &p: m_items) { if (p.second && p.second.use_count() > 0) { - std::cerr << "WARNING: ById map destroyed with use count of " - << p.second.use_count() << " for item with type " - << typeid(*p.second.get()).name() - << " and id " << p.first.id << std::endl; + SVCERR << "WARNING: ById map destroyed with use count of " + << p.second.use_count() << " for item with type " + << typeid(*p.second.get()).name() + << " and id " << p.first.id << endl; } } } void add(std::shared_ptr item) { QMutexLocker locker(&m_mutex); - m_items[item->getId()] = item; + auto id = item->getId(); + if (m_items.find(id) != m_items.end()) { + SVCERR << "WARNING: ById::add: item with id " << id + << " is already recorded, replacing it (item type is " + << typeid(*item.get()).name() << ")" << endl; + } + m_items[id] = item; } void