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

Properties of `enum class` types has incorrect flags

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Reported
    • Priority: P3: Somewhat important
    • Resolution: Unresolved
    • Affects Version/s: 5.13.2
    • Fix Version/s: None
    • Component/s: Build tools: moc
    • Labels:
      None

      Description

      I have a class with property of type `enum class Foo`

      enum class Foo{A, B};
      
      class Bar: public QObject {
          Q_OBJECT
      
          Q_ENUM(Foo)
          Q_PROPERTY(Foo myCoolProperty READ myCoolProperty WRITE setMyCoolProperty)
      
          Foo _foo;
      
      public:
      
          Bar();
          Foo myCoolProperty() const;
          void setMyCoolProperty(Foo v);
      };
      

      As far, as I undertand, the problem is in the moc compiler. The flags of myCoolProperty property is not contain isEnumType bit.
      For example let's run next code:

      Bar *bar = new Bar();
      
      const QMetaObject *m = bar->metaObject();
      for(int i=0; i< m->propertyCount(); i++ ) {
          QMetaProperty mp = m->property(i);
          qDebug("name=%s, isEnumType=%d %d", mp.name(), mp.isEnumType(), mp.enumerator().isValid() );
      }
      

      this produce next output:

      name=myCoolProperty, isEnumType=0 0

      But `isEnumType` assert  =1. And `isValid()` method assert returns 1.

      This is because `enum class` types are almost same as `enum`.

       

       

        Attachments

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

          Activity

            People

            Assignee:
            Unassigned Unassigned
            Reporter:
            chabapok Alexander
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Dates

              Created:
              Updated:

                Gerrit Reviews

                There are no open Gerrit changes