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

Assertion in attempt to register a namespaced meta type

    XMLWordPrintable

Details

    • I90f4fa613bd13d5a581828ab13f620b40dfd3593

    Description

      In Qt add-ons, it is quite common to have declarations like

      QT_BEGIN_NAMESPACE
      Q_DECLARE_TYPEINFO(QT_PREPEND_NAMESPACE_A(AClass), Q_MOVABLE_TYPE);
      QT_END_NAMESPACE
      
      Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE_A(AClass))
      

      After some recent refactoring, an attempt to

      qRegisterMetaType<QT_PREPEND_NAMESPACE_A(AClass)>();
      qRegisterMetaType<QList<QT_PREPEND_NAMESPACE_A(AClass)> >();
      

      causes an assertion in qmetatype.h
      > ASSERT failure in qRegisterNormalizedMetaType: "qRegisterNormalizedMetaType was called with a not normalized type name, please call qRegisterMetaType instead.", file ..\include/QtCore/../../../qtbase/src/corelib/kernel/qmetatype.h, line 1579

      Debuggings shows two related issues:
      1) in Q_DECLARE_METATYPE(QT_PREPEND_NAMESPACE_A(AClass)), QT_PREPEND_NAMESPACE_A macro doesn't expand and the metatype name become "QT_PREPEND_NAMESPACE_A(AClass"
      2) due to missing right paren in 1), the normalized meta type name for "Container<QT_PREPEND_NAMESPACE_A(AClass)>" is "Container<", which indeed causes an assertion in qRegisterNormalizedMetaType()

      The debug output for the attached example is:

      QMetaObject::normalizedType:
      < QT_PREPEND_NAMESPACE_A(AClass)
      > QT_PREPEND_NAMESPACE_A(AClass)
      > QT_PREPEND_NAMESPACE_A(AClass
      QMetaObject::normalizedType:
      < QT_PREPEND_NAMESPACE_A(AClass
      > QT_PREPEND_NAMESPACE_A(AClass
      > QT_PREPEND_NAMESPACE_A(AClass
      QMetaObject::normalizedType:
      < QList<QT_PREPEND_NAMESPACE_A(AClass>
      > QList<QT_PREPEND_NAMESPACE_A(AClass>
      > QList<
      ASSERT failure in qRegisterNormalizedMetaType: "qRegisterNormalizedMetaType was called with a not normalized type name, please call qRegisterMetaType instead.",
      file ..\include/QtCore/../../../qtbase/src/corelib/kernel/qmetatype.h, line 1579

      Attachments

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

        Activity

          People

            nierob Nierob
            ritt.ks Konstantin Ritt
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes