comparison base/ById.cpp @ 1759:b679bae1627b by-id

Print object name as well (if a QObject)
author Chris Cannam
date Mon, 08 Jul 2019 10:07:55 +0100
parents 6d09d68165a4
children ee7fd2c01d87
comparison
equal deleted inserted replaced
1758:83178b4bb698 1759:b679bae1627b
48 } 48 }
49 if (!empty) { 49 if (!empty) {
50 SVCERR << "WARNING: ById map is not empty at close; some items have not been released" << endl; 50 SVCERR << "WARNING: ById map is not empty at close; some items have not been released" << endl;
51 SVCERR << " Unreleased items are:" << endl; 51 SVCERR << " Unreleased items are:" << endl;
52 for (const auto &p: m_items) { 52 for (const auto &p: m_items) {
53 if (p.second && p.second.use_count() > 0) { 53 auto ptr = p.second;
54 SVCERR << " - id #" << p.first 54 if (ptr && ptr.use_count() > 0) {
55 << ": type " << typeid(*p.second.get()).name() 55 QString message = QString("id #%1: type %2")
56 << ", use count " << p.second.use_count() << endl; 56 .arg(p.first).arg(typeid(*ptr.get()).name());
57 if (auto qobj = std::dynamic_pointer_cast<QObject>(ptr)) {
58 message += QString(", object name \"%1\"")
59 .arg(qobj->objectName());
60 }
61 message += QString(", use count %1").arg(ptr.use_count());
62 SVCERR << " - " << message << endl;
57 } 63 }
58 } 64 }
59 } 65 }
60 } 66 }
61 67