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

QMetaObjectBuilder does not properly carry property flags

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 6.4
    • Core: Object Model
    • 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

              fabiankosmale Fabian Kosmale
              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