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

QQmlAbstractUrlInterceptor cannot intercept qmldir file import

    XMLWordPrintable

Details

    • All
    • 0b7e479235aec74f051af4d5ef95e74753b59c6d (qt/qtdeclarative/5.12)

    Description

      qml/qml/qqmlimport.cpp: QQmlImportsPrivate::addFileImport():

      ......
          QString importUri = uri;
          QString qmldirUrl = resolveLocalUrl(base, importUri + (importUri.endsWith(Slash)
                                                                 ? String_qmldir
                                                                 : Slash_qmldir));
          if (QQmlAbstractUrlInterceptor *interceptor = typeLoader->engine()->urlInterceptor()) {
              qmldirUrl = interceptor->intercept(QUrl(qmldirUrl),
                                                 QQmlAbstractUrlInterceptor::QmldirFile).toString();
          }
          QString qmldirIdentifier;
      
          if (QQmlFile::isLocalFile(qmldirUrl)) {
      
              QString localFileOrQrc = QQmlFile::urlToLocalFileOrQrc(qmldirUrl);
              Q_ASSERT(!localFileOrQrc.isEmpty());
      
              QString dir = QQmlFile::urlToLocalFileOrQrc(resolveLocalUrl(base, importUri));
              if (!typeLoader->directoryExists(dir)) {
                  if (!isImplicitImport) {
                      QQmlError error;
                      error.setDescription(QQmlImportDatabase::tr("\"%1\": no such directory").arg(uri));
                      error.setUrl(QUrl(qmldirUrl));
                      errors->prepend(error);
                  }
                  return false;
              }
      ......

      After qmldirUrl getting intercepted,

      if (!typeLoader->directoryExists(dir)) {
      

      it checks whether dir is existed on local driver,

      QString dir = QQmlFile::urlToLocalFileOrQrc(resolveLocalUrl(base, importUri));
      

      However, dir is composited from importUrl which is not intercepted, this will make intercepting local qmldir file import impossible.

      Attachments

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

        Activity

          People

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

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes