# HG changeset patch # User Chris Cannam # Date 1561472985 -3600 # Node ID d9082ed16931ee1377651f3147e60e95832c3e4a # Parent d91ff235e69d30d175337af3d8ef5d0bc88b1a93# Parent bffccc8de3c15a21c97fe0950566b75373ac2aa3 Merge diff -r d91ff235e69d -r d9082ed16931 base/ById.h --- a/base/ById.h Tue Jun 25 15:29:34 2019 +0100 +++ b/base/ById.h Tue Jun 25 15:29:45 2019 +0100 @@ -15,6 +15,8 @@ #ifndef SV_BY_ID_H #define SV_BY_ID_H +#include "Debug.h" + #include #include #include @@ -98,17 +100,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