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

qmlsc generates bad code for CallPropertyLookup

    XMLWordPrintable

Details

    • 045b2c85a5 (qt/tqtc-qmlcompilerplus/6.2) 045b2c85a5 (qt/tqtc-qmlcompilerplus/6.2.3)

    Description

      Can be seen in Qt Creator's ButtonsBar.qml:

      color: Theme.color(Theme.PanelStatusBarBackgroundColor)
      

      First, it fails to find the type for the parameter to color(). That can be fixed by qualifying it and fixing qqmljsscope.cpp to use the last "::" rather than the first as delimiter between inner and outer type. Then, however, it generates this:

      int r2_1;
      QObject *r2;
      QJSPrimitiveValue r2_2;
      int r10;
      QObject *r7;
      // color: Theme.color(Theme.PanelStatusBarBackgroundColor)
      // generate_LoadQmlContextPropertyLookup
      // generate_LoadQmlContextPropertyLookup
      while (!aotContext->loadSingletonLookup(8, &r2)) {
      aotContext->setInstructionPointer(2);
      aotContext->initLoadSingletonLookup(8, QQmlPrivate::AOTCompiledContext::InvalidStringId);
      if (aotContext->engine->hasError())
          return QJSPrimitiveValue(QJSPrimitiveUndefined()).toVariant();
      }
      {
      }
      // generate_StoreReg
      r7 = r2;
      {
      }
      // generate_LoadQmlContextPropertyLookup
      // // generate_LoadQmlContextPropertyLookup
      // while (!aotContext->loadSingletonLookup(9, &r2)) {
      // aotContext->setInstructionPointer(6);
      // aotContext->initLoadSingletonLookup(9, QQmlPrivate::AOTCompiledContext::InvalidStringId);
      // if (aotContext->engine->hasError())
      //     return QJSPrimitiveValue(QJSPrimitiveUndefined()).toVariant();
      // }
      {
      }
      // generate_GetLookup
      while (!aotContext->getEnumLookup(10, &r2_1)) {
      aotContext->setInstructionPointer(8);
      aotContext->initGetEnumLookup(10, QMetaType::fromName("Utils::Theme *").metaObject(), "Color", "PanelStatusBarBackgroundColor");
      if (aotContext->engine->hasError())
          return QJSPrimitiveValue(QJSPrimitiveUndefined()).toVariant();
      }
      {
      }
      // generate_StoreReg
      r10 = r2_1;
      {
      }
      // generate_CallPropertyLookup
      {
      void *args[] = { nullptr, &r10 };
      const QMetaType types[] = { QMetaType(), QMetaType::fromType<int>() };
      while (!aotContext->callObjectPropertyLookup(11, r7, args, types, 1)) {
      aotContext->setInstructionPointer(15);
      aotContext->initCallObjectPropertyLookup(11);
      if (aotContext->engine->hasError())
          return QJSPrimitiveValue(QJSPrimitiveUndefined()).toVariant();
      }
      r2_2 = {};
      }
      {
      }
      // generate_StoreReg
      // r6 = r2_2;
      {
      }
      // generate_Ret
      if (r2_2.type() == QJSPrimitiveValue::Undefined)
          aotContext->setReturnValueUndefined();
      return r2_2.toVariant();
      

      So, it does not actually save the result of the call to color(), but instead always returns undefined.

      Attachments

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

        Activity

          People

            ulherman Ulf Hermann
            ulherman Ulf Hermann
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews