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

setData for QQmlComponent handles uncorrectly "import" path

    XMLWordPrintable

Details

    Description

      Hello,
      This is my first bug submit, sorry if something is wrong or incomplete.

      Trying to load a component using the setData call for QQmlComponent fails, when the data contains an include to a further directory. (Even if not used)

          QtQuick2ApplicationViewer viewer;
          viewer.setMainQmlFile(QStringLiteral("qml/main.qml"));
          viewer.showExpanded();
      
          QQmlContext *context = new QQmlContext(viewer.rootContext());
          QQmlComponent component(viewer.engine());
          component.setData( "import QtQuick 2.0;import \"Boxes\";Rectangle { width: 100; height: 62;}",QUrl("qml/"));
      

      This generates an ASSERT

      ASSERT: "!url.isRelative() && (QQmlFile::urlToLocalFileOrQrc(url).isEmpty() || !QDir::isRelativePath(QQmlFile::urlToLocalFileOrQrc(url)))" 
      

      in file qml\qqmltypeloader.cpp, line 1665

      Url value before the assert in getQmlDir is "://qml/Boxes/qmldir"

      Am I doing something wrong? Is it normal that the "qmldir" string gets added to the url from QQmlTypeLoader::Blob::addImport?
      I tried various QUrl, without success.

      Thanks and regards,
      Christophe

      Attachments

        For Gerrit Dashboard: QTBUG-41037
        # Subject Branch Project Status CR V

        Activity

          People

            qtqmlteam Qt Qml Team User
            da3 Christophe Conil
            Votes:
            1 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There is 1 open Gerrit change