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

Can't set enum values for attached properties

    XMLWordPrintable

Details

    Description

      If an attached object has an enum-type property, the enum values can't be referenced using the Class.EnumValue syntax; instead, it has to be referenced as a string.

      Attached is a modified version of the example under declarative/cppextensions/referenceexamples/attached.

      The BirthdayPartyAttached class now has the property

      Q_PROPERTY(SomeEnum someEnumValue READ someEnumValue WRITE setSomeEnumValue)
      

      and includes this enum:

          Q_ENUMS(SomeEnum)
      
          ...
      
          enum SomeEnum {
              SomeEnumValueA,
              SomeEnumValueB
          };
      

      For each Girl or Boy object in example.qml, this will work:

          Girl { 
              // the stored attached property can be found to be QVariant(int, 1) which is correct
              BirthdayParty.someEnumValue: "SomeEnumValueB"
          }
      

      but, this will not:

          Girl { 
              // the stored attached property can be found to be QVariant(int, 0) which is wrong
              BirthdayParty.someEnumValue: BirthdayParty.SomeEnumValueB
          }
      

      Additionally, if the BirthdayParty.someEnumValue value is not set for the second entry ("Jack Smith") the example crashes with the following backtrace:

      "Bob Jones" is having a birthday! 
      He is inviting: 
          "Leo Hodges" RSVP date: Mon Jul 6 2009 
      	 someEnumValue: QVariant(int, 1) 
          "Jack Smith" RSVP date: Hasn't RSVP'd 
      
      Program received signal EXC_BAD_ACCESS, Could not access memory.
      Reason: KERN_INVALID_ADDRESS at address: 0x0000000000000008
      0x00000001019bf468 in QScopedPointer<QObjectData, QScopedPointerDeleter<QObjectData> >::data (this=0x8) at qscopedpointer.h:135
      135	        return d;
      (gdb) bt
      #0  0x00000001019bf468 in QScopedPointer<QObjectData, QScopedPointerDeleter<QObjectData> >::data (this=0x8) at qscopedpointer.h:135
      #1  0x0000000101b44581 in qGetPtrHelper<QScopedPointer<QObjectData, QScopedPointerDeleter<QObjectData> > > (p=@0x8) at qglobal.h:2369
      #2  0x0000000101b4f34f in QObject::d_func (this=0x0) at qobject.h:116
      #3  0x0000000101b45fdd in QObject::property (this=0x0, name=0x10000b7f5 "someEnumValue") at kernel/qobject.cpp:3556
      #4  0x0000000100004eb2 in main (argc=1, argv=0x7fff5fbff5a8) at main.cpp:85
      

      Attachments

        Issue Links

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

          Activity

            People

              mvogt Matthew Vogt (closed Nokia identity) (Inactive)
              bealam Bea Lam (closed Nokia identity) (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes