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

Behavior on value types doesn't work for all combinations

    XMLWordPrintable

Details

    • f18b66ac6cfc734d217ec9d44876774f25e5d900

    Description

      Issue 1: In the following example, the Behavior is never created (CREATE_SIMPLE and STORE_VALUE_INTERCEPTOR instructions are not generated for the Behavior)

      import QtQuick 2.0
      
      Rectangle {
          width: 400
          height: 400
          color.r: 0
          color.g: 1
          color.b: 0
      
          Behavior on color { ColorAnimation { duration: 500; } }
      }
      

      Issue 2: In the following example, the error "Property has already been assigned a value" is produced:

      import QtQuick 2.0
      
      Rectangle {
          width: 400
          height: 400
          color: "green"
      
          Behavior on color.r { ColorAnimation { duration: 500; } }
      }
      

      The following patch gets rid of the error for issue 2, but still doesn't not allow the two color-related assignments to play well with each other:

      diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp
      index fb98a8c..900ffd3 100644
      --- a/src/declarative/qml/qdeclarativecompiler.cpp
      +++ b/src/declarative/qml/qdeclarativecompiler.cpp
      @@ -1997,10 +1997,15 @@ bool QDeclarativeCompiler::buildGroupedProperty(QDeclarativeScript::Property *pr
               if (prop->type >= 0 && enginePrivate->valueTypes[prop->type]) {
       
                   if (!prop->values.isEmpty()) {
      -                if (prop->values.first()->location < prop->value->location) {
      -                    COMPILE_EXCEPTION(prop->value, tr( "Property has already been assigned a value"));
      -                } else {
      -                    COMPILE_EXCEPTION(prop->values.first(), tr( "Property has already been assigned a value"));
      +                //only error if we are assigning values, and not e.g. a property interceptor
      +                for (Property *dotProp = prop->value->properties.first(); dotProp; dotProp = prop->value->properties.next(dotProp)) {
      +                    if (!dotProp->values.isEmpty()) {
      +                        if (prop->values.first()->location < prop->value->location) {
      +                            COMPILE_EXCEPTION(prop->value, tr( "Property has already been assigned a value"));
      +                        } else {
      +                            COMPILE_EXCEPTION(prop->values.first(), tr( "Property has already been assigned a value"));
      +                        }
      +                    }
                       }
                   }
      

      The issue is caused at the compiler level where the two assignments appear to be mutually exclusive, e.g. either buildGroupedProperty or buildPropertyAssignment will be called, but not both.

      Attachments

        Issue Links

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

          Activity

            People

              glwatson Glenn Watson
              brasser Michael Brasser (closed Nokia identity) (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              2 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes