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

QMetaObjectBuilder does not properly carry property flags

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P2: Important
    • Resolution: Unresolved
    • Affects Version/s: 6.4
    • Fix Version/s: None
    • Component/s: Core: Object Model
    • Labels:
      None

      Description

      Consider

      class TestTest : public QObject
      {
          Q_OBJECT
          Q_ENUMS(MyEnum)
          Q_FLAGS(MyEnumFlag)
          Q_PROPERTY(MyEnumFlag fprop READ fprop)
      public:
          enum MyEnum { A = 0x01, B = 0x02 };
          Q_DECLARE_FLAGS(MyEnumFlag, MyEnum);
          MyEnumFlag fprop() const { return A; }
      };
      Q_DECLARE_OPERATORS_FOR_FLAGS(TestTest::MyEnumFlag)
      

      Now if one clones its metaobject via something like

              QMetaObjectBuilder builder(&TestTest::staticMetaObject);
              QMetaObject *meta = builder.toMetaObject();
      

      then the staticMetaObject and the new one have different property flags for the MyEnumFlag property.

                  auto i = m->indexOfProperty("fprop");
                  QMetaProperty p = m->property(i);
                  qDebug() << i << p.name() << p.typeName() << p.isEnumType() << p.isFlagType();
      

      on the true metaobject and on the clone says:

      1 fprop QFlags<TestTest::MyEnum> true true
      1 fprop QFlags<TestTest::MyEnum> false false
      

      It seems it boils down to the QMetaEnum inside QMetaProperty not being initialized correctly in the second case, but I have no idea how to go in there.

        Attachments

          Issue Links

          For Gerrit Dashboard: QTBUG-101426
          # Subject Branch Project Status CR V

            Activity

              People

              Assignee:
              fabiankosmale Fabian Kosmale
              Reporter:
              peppe Giuseppe D'Angelo
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Dates

                Created:
                Updated:

                  Gerrit Reviews

                  There is 1 open Gerrit change