Details
-
Bug
-
Resolution: Invalid
-
P3: Somewhat important
-
None
-
5.14.2, 5.15.0 RC2
-
None
Description
Hi,
we like to use qtHookData[QHooks::AddQObject] to add some "introspection" for debugging purposes in our application. It works good but if we want to add more stuff we hit a little annoying Q_ASSERT.
ASSERT: "slotObj" in file kernel/qhostinfo.cpp, line 185
It would be helpful if the QHostInfoResult::postResultsReady could use a more explicit call to provide the data instead of generic QEvent::MetaCall.
bool QHostInfoResult::event(QEvent *event)
{
if (event->type() == QEvent::MetaCall) {
Q_ASSERT(slotObj);
We just introduced a sample QMetaObject::invokeMethod here to call a lambda. But since it is a QEvent::MetaCall it will trigger that assert in bool QHostInfoResult::event(QEvent *event) because it shouldn't be called like this.
extern "C" Q_DECL_EXPORT void internal_addObject(QObject* pObj) { const std::lock_guard locker(cMutex); cAllQObjects.push_back(pObj); if (cPrintAdd) { QMetaObject::invokeMethod(pObj, [pObj] { QtHooks::print(pObj); }, Qt::QueuedConnection); } }
Mechanism was introduced by https://code.qt.io/cgit/qt/qtbase.git/commit/?id=739b3bfb2fa