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

Extract correct signedness for flagged enum types

    XMLWordPrintable

Details

    Description

      Resulted from https://codereview.qt-project.org/c/qt/qtbase/+/583367

      Consider the enum definition with underlying type uint32:

          enum PositioningMethod {
              NoPositioningMethods = 0x00000000,
              SatellitePositioningMethods = 0x000000ff,
              NonSatellitePositioningMethods = 0xffffff00,
              AllPositioningMethods = 0xffffffff
          };
          Q_DECLARE_FLAGS(PositioningMethods, PositioningMethod) 

       

      // qml
      
      ...
      property int a: PositioningMethod.NonSatellitePositioningMethods
      property enumtype b: a
      
      
      console.log("bound to int",a); // Prints -256
      console.log("enum", PositionSource.NonSatellitePositioningMethods); // Prints -256
      console.log("bound to Enum", b); // Prints -256
      

       

      If https://codereview.qt-project.org/c/qt/qtbase/+/581748 is in, binding to enum type gets the correct assignment, which is :

      console.log("bound to Enum", b); // Prints 4294967040

       

      Since the enum originally defined as unsigned int, the expected values indeed shouldn't have been -256. Investigate why flag-type enums creates inconsistencies and changes data type in Qml world

      Attachments

        Issue Links

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

          Activity

            People

              qtqmlteam Qt Qml Team User
              semih.yavuz Semih Yavuz
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

                Created:
                Updated:

                Gerrit Reviews

                  There are no open Gerrit changes