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

QML should emit warnings when doing invalid conversions

    XMLWordPrintable

Details

    Description

      If QML has to do an "implicit conversion" in order to set a property's value, it should really check that the result of the conversion is legitimate, otherwise it should emit a warning. Only warnings about assigning "undefined" seem to be emitted.

      Object {
         property color c: "foobar" // "foobar" is not a valid color; should warn
         property int i: NaN // not representable, should warn
         property int i2: Infinity // ditto
         property int i3: 3.14 // heck, I'd even claim that *this* should warn.
      }
      

      Here's a more complex example:

      Object {
         property int p: otherObject.doesNotExist + 1
         Object { id: otherObject }
      }
      

      This does not emit a warning (although it should) on accessing the non existant property because of QTBUG-85069.

      If one omits the +1, one gets a warning: "unable to assign undefined to int". Makes sense.

      But with the +1, undefined+number => NaN, and then the warning disappears. Instead, it should emit ANOTHER warning: you can't set NaN to an integer.

      Attachments

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

        Activity

          People

            qtqmlteam Qt Qml Team User
            peppe Giuseppe D'Angelo
            Votes:
            0 Vote for this issue
            Watchers:
            5 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes