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

Using Flags with MEMBER property fails

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P2: Important
    • None
    • 5.8.0, 5.12.4, 5.13.0
    • Build tools: moc
    • None
    • * Manjaro Linux 4.10.4
      * Qt 5.8.0

    Description

      The following code fails to compile:

      class TestObject : public QObject
      {
      	Q_OBJECT
      
      	// this provokes the error
      	Q_PROPERTY(TestFlags flags2 MEMBER flags)
      
      public:
      	enum TestFlag {
      		Flag1 = 0x01,
      		Flag2 = 0x02,
      		Flag4 = 0x04
      	};
      	Q_DECLARE_FLAGS(TestFlags, TestFlag)
      	Q_FLAG(TestFlags)
      
      	explicit TestObject(QObject *parent = 0);
      
      	TestFlags flags;
      };
      

      It's an error in moc, the error is in the following function:

      void TestObject::qt_static_metacall(QObject *_o, QMetaObject::Call _c, int _id, void **_a)
      {
          //...
          case 0: *reinterpret_cast<int*>(_v) = QFlag(_t->()); break;
      }
      

      As far as I can see, moc assumes a read accessor, and ignores the MEMBER accessor. It happens for writing the property, too.

      The error message gcc gives is:

      moc_testobject.cpp: In statischer Elementfunktion »static void TestObject::qt_static_metacall(QObject*, QMetaObject::Call, int, void**)«:
      moc_testobject.cpp:86:52: Fehler: expected primary-expression before »(« token
               case 0: *reinterpret_cast<int*>(_v) = QFlag(_t->()); break;
                                                          ^
      

      Attachments

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

        Activity

          People

            Unassigned Unassigned
            SkyCoder Felix Barz
            Votes:
            1 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes