Uploaded image for project: 'Qt for MCUs'
  1. Qt for MCUs
  2. QTMCU-9

State names with spaces creates coruppted C++ code

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Done
    • Icon: P2: Important P2: Important
    • Qt for MCUs 1.5
    • Qt for MCUs 1.5
    • QML Engine
    • None
    • All
    • 1
    • UL Sprint 3.7

      If a state name contains a space the generated c++ source code is corrupted.

      Following Qml code:

       

      Rectangle {
          width: 480
          height: 272
      
          states: [
              State {
                  name: "Test 1"
              }
          ]
      }
      
      

      will ceate following c++ code:

       

      struct Test : Qul::Private::Items::Rectangle , public Qul::Private::Items::ItemBase ::ExtraStorage_itemExtraProperties<Qul::Private::Items::Rectangle  > {
          Test();
          void activateState_Test 1(Qul::Private::Items::Transition *, Qul::Private::Items::Transition::TransitionStatus);
          Qul::Property<Qul::Private::String> state;
          void activateDefaultState(Qul::Private::Items::Transition*, Qul::Private::Items::Transition::TransitionStatus);
          Qul::Private::State<Test> currentState;
          static Qul::Private::State<Test> stateFromName(Qul::Private::String name)
          {
              if (name == "") return &Test::activateDefaultState;
              if (name == Qul::Private::String(Qul::Private::Latin1String("Test 1", 6))) return &Test::activateState_Test 1;
              assert(!"Invalid state");
              return &Test::activateDefaultState;
          }
          struct StateChangeEvent {
              Test *self;
              StateChangeEvent(Test *self) : self(self) {}
              void operator()();
          };
          Qul::Private::ChangedEvent<StateChangeEvent, Qul::Private::String > onStateChanged;
      };
      
      

      This issue applies for all characters that are not c++ conform. These characters needs to be either replaced in the generated code or already forbidden in the QML Editor or the named needs to be marked as invalid name.

       

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

            jan-karasinski Jan Karasiński
            _joerg_ Jörg Hedrich
            Daniel Drozdz Daniel Drozdz
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

              Created:
              Updated:
              Resolved:

                There are no open Gerrit changes