Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-84385

QMetaObject::invokeMethod to QHostInfoResult

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • P3: Somewhat important
    • None
    • 5.14.2, 5.15.0 RC2
    • Core: Other
    • 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

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            vhilshei Volker Hilsheimer
            misery André Klitzing
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes