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

QmlCompiler generates check for undefined where it should check for null

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • P1: Critical
    • 6.5
    • 6.5.0
    • QML: Compiler
    • None

    Description

      The following code is generated for the childobject.qml test case:

      // expression for objectName at line 12, column 5
      QVariant r2_1;
      QString r2_2;
      // generate_LoadQmlContextPropertyLookup
      {
      QObject * retrieved;
      while (!aotContext->loadScopeObjectPropertyLookup(0, &retrieved)) {
      aotContext->setInstructionPointer(2);
      aotContext->initLoadScopeObjectPropertyLookup(0, []() { static const auto t = QMetaType::fromName("ObjectWithMethod*"); return t; }());
      if (aotContext->engine->hasError())
          return QString();
      }
      r2_1 = QVariant::fromValue(retrieved);
      }
      // generate_GetLookup
      if (!r2_1.isValid()) {
          aotContext->setInstructionPointer(4);
          aotContext->engine->throwError(QJSValue::TypeError, QLatin1String("Cannot read property 'objectName' of undefined"));
          return QString();
      }
      while (!aotContext->getObjectLookup(1, *static_cast<QObject *const *>(r2_1.constData()), &r2_2)) {
      aotContext->setInstructionPointer(4);
      aotContext->initGetObjectLookup(1, *static_cast<QObject *const *>(r2_1.constData()), QMetaType::fromType<QString>());
      if (aotContext->engine->hasError())
          return QString();
      }
      // generate_Ret
      return r2_2;
      

      Clearly, the retrieved pointer can never be undefined, but it can be null!

      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
            ulherman Ulf Hermann
            Votes:
            0 Vote for this issue
            Watchers:
            1 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes