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

QML/Javascript switch statement doesn't execute multiple lines within a case.

    XMLWordPrintable

Details

    • Bug
    • Resolution: Out of scope
    • P3: Somewhat important
    • None
    • 4.7.4
    • None
    • Windows7, QtCreator 2.4.1, Qt 4.7.4.

    Description

      If a switch() statement is used at the end of a block of javascript code, and it has case: clauses with multiple lines, it will only execute the first line of code for the chosen branch. However, if another line of executable code is added AFTER the switch statement, the multiple lines inside the case will now execute.

      The following code demonstrates this bug. Simply uncomment the last console statement to see proper execution.

      import QtQuick 1.1
      Rectangle {
          width: 100
          height: 62
          Component.onCompleted: {
              switch (height) {
              case 62:
                  console.log("height starts as " + height);
                  height = 55;
                  console.log("height ends as " + height);
                  break;
              default:
                  console.log("default case");
                  break;
              }
              //console.log("if this line is uncommented, it causes all statements in the switch() to run.");
          }
      }
      

      Attachments

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

        Activity

          People

            Unassigned Unassigned
            spazvt Jeremy Hannon
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes