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

qtdeclarative needs a reusable function to convert filenames and URLs appropriately

    XMLWordPrintable

Details

    • 9b2b06fd7bf07e1012b47798f38ba881e693436f

    Description

      https://codereview.qt-project.org/#/c/180233/ broke the QML runtime. If you run it like

      qml file.qml

      that gets turned into file://file.qml. Then there is this

      QQmlTypeData *QQmlTypeLoader::getType(const QUrl &url, Mode mode)
      {
          Q_ASSERT(!url.isRelative() &&
                  (QQmlFile::urlToLocalFileOrQrc(url).isEmpty() ||
                   !QDir::isRelativePath(QQmlFile::urlToLocalFileOrQrc(url))));
      

      which fails:

      1  raise                                                                  0x7ffff4ed204f 
      2  abort                                                                  0x7ffff4ed347a 
      3  qt_message_fatal                        qlogging.cpp              1688 0x7ffff601d047 
      4  QMessageLogger::fatal                   qlogging.cpp              796  0x7ffff6019460 
      5  qt_assert                               qglobal.cpp               3025 0x7ffff60119aa 
      6  QQmlTypeLoader::getType                 qqmltypeloader.cpp        1630 0x7ffff7aeb7fd 
      7  QQmlComponentPrivate::loadUrl           qqmlcomponent.cpp         662  0x7ffff7ac8efd 
      8  QQmlComponent::loadUrl                  qqmlcomponent.cpp         619  0x7ffff7ac8bf6 
      9  QQmlApplicationEnginePrivate::startLoad qqmlapplicationengine.cpp 113  0x7ffff7b56a63 
      10 QQmlApplicationEngine::load             qqmlapplicationengine.cpp 268  0x7ffff7b56fa8 
      11 main                                    main.cpp                  592  0x40720d       
      

      So, is the assert wrong?

      It has been suggested that we should use QUrl::fromUserInput more, but QUrl::fromUserInput("file.qml") turns into http://file.qml which is also not what we want.

      I'm not sure if QtQuick is the only user for such a function but it's clear that there is too much inconsistent filename->url conversion going on in qtdeclarative and it needs to be streamlined. qmlscene works fine after this change; qml doesn't. qml's main.cpp resorts to using a regular expression to detect whether the command-line argument contains a scheme or is just a path, and that IMO should also not be necessary. This conversion needs to be a one-liner in every situation where it's necessary.

      Attachments

        Issue Links

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

          Activity

            People

              srutledg Shawn Rutledge
              srutledg Shawn Rutledge
              Votes:
              0 Vote for this issue
              Watchers:
              6 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved:

                Gerrit Reviews

                  There are no open Gerrit changes