Mercurial > hg > svcore
changeset 1736:d9082ed16931 by-id
Merge
author | Chris Cannam |
---|---|
date | Tue, 25 Jun 2019 15:29:45 +0100 |
parents | d91ff235e69d (current diff) bffccc8de3c1 (diff) |
children | 5d631f6129fe |
files | base/ById.h |
diffstat | 1 files changed, 13 insertions(+), 5 deletions(-) [+] |
line wrap: on
line diff
--- 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 <memory> #include <map> #include <typeinfo> @@ -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> 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