Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-16478 QtScript API changes for Qt 5
  3. QTBUG-11226

QscriptValueIterator::next should return a value

    XMLWordPrintable

Details

    • Sub-task
    • Resolution: Invalid
    • P3: Somewhat important
    • 5.0.0
    • Qt Script
    • None

    Description

      Right now the next() function returns void. The issue lead to inefficient code, for example to iterate over all an object properties we have to write code like that below

      QScriptValue object;
      ...
      QScriptValueIterator it(object);
      while (it.hasNext())

      { it.next(); qDebug() << it.name() << ": " << it.value().toString(); }

      assuming that the next() function returns boolean value, it could be replaced:

      QScriptValue object;
      ...
      QScriptValueIterator it(object);
      while (it.next())

      { qDebug() << it.name() << ": " << it.value().toString(); }

      That is one function call per iteration less.

      According to QScriptValueIterator's documentation "The QScriptValueIterator class provides a Java-style iterator for QScriptValue." which is not true as the Java iterator returns an object reference or null on next() call. Another, Java like approach to the problem would be looking like that:

      class QScriptProperty;

      QScriptValue object;
      ...
      QScriptValueIterator it(object);
      while (QScriptProperty property = it.next())

      { qDebug() << property.name() << ": " << property.value().toString(); }

      Attachments

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

        Activity

          People

            kenthans Kent Hansen (Inactive)
            nierob Nierob
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes