Uploaded image for project: 'Qt Design Studio'
  1. Qt Design Studio
  2. QDS-13954

Ensure that components from the qmldir actually exist

    XMLWordPrintable

Details

    • User Story
    • Resolution: Done
    • Not Evaluated
    • None
    • None
    • Project Storage
    • None
    • QDS Berlin - 2024 Week 43/44
    • f13a1c682 (qds/dev), 811c8db63 (qds/dev)

    Description

      Ensure that components from the qmldir actually exist.

      ProjectStorageUpdater::Components createComponents(
      const QMultiHash<QString, QmlDirParser::Component> &qmlDirParserComponents,
      ModuleId moduleId,
      ModuleId pathModuleId,
      FileSystemInterface &fileSystem,
      const Utils::PathString &directory)
      {
      qDebug() << Q_FUNC_INFO << directory.toQString();
      ProjectStorageUpdater::Components components;

      auto qmlFileNames = fileSystem.qmlFileNames(QString

      {directory}

      );

      qDebug() << Q_FUNC_INFO << "qmlFileNames" << qmlFileNames;

      components.reserve(static_cast<std::size_t>(qmlDirParserComponents.size() + qmlFileNames.size()));

      for (const QString &qmlFileName : qmlFileNames) {
      Utils::PathString fileName

      {qmlFileName}

      ;
      Utils::PathString typeName

      {fileName.begin(), std::find(fileName.begin(), fileName.end(), '.')}

      ;
      components.push_back(
      ProjectStorageUpdater::Component

      {fileName, typeName, pathModuleId, -1, -1}

      );
      }

      for (const QmlDirParser::Component &qmlDirParserComponent : qmlDirParserComponents) {
      if (qmlDirParserComponent.fileName.contains('/'))
      continue;
      qDebug() << Q_FUNC_INFO << "qmldir" << qmlDirParserComponent.fileName << qmlDirParserComponent.typeName;
      components.push_back(ProjectStorageUpdater::Component

      {qmlDirParserComponent.fileName, qmlDirParserComponent.typeName, moduleId, qmlDirParserComponent.majorVersion, qmlDirParserComponent.minorVersion}

      );
      }

      return components;
      }

      On Windows for some reason the qmldir even includes the module name as a component.
      In any case we should check if a file (qmlDirParserComponent.fileName), does actually exist before pushing it.

      A missing file should trigger a warning.

      Pushing the component here, if it does not exist, will trigger an unhandled exception down the road. This should be handled here.

      Attachments

        For Gerrit Dashboard: QDS-13954
        # Subject Branch Project Status CR V

        Activity

          People

            bubke Marco Bubke
            bubke Marco Bubke
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes