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

Android assets:/ protocol handling not working in all cases

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 5.14.0 RC1
    • 5.14.0 Beta3
    • Core: I/O
    • None
    • Linux Debian/stable x86_64
      Android NDK r20
      Android build SDK: android-28
    • Android
    • d027860201c55b686b9f8330c559f84799442d68

    Description

      The reworked handling of assets:/ seems to have quite some bugs that are hard to explain.

      Iterating over a list of 9 files named 1st.ext to 9th.ext in an assets subdirectory omits several entries:

      const QDir extDir(QStringLiteral("assets:/squish/"));
      qDebug() << "entryList(*.ext):" << extDir.entryList(QStringList() << QStringLiteral("*.ext") /*, QDir::Files*/);
      // Output:
      // D libqtandroid_assets_test_x86.so: entryList(*.ext): ("2nd.ext", "4th.ext", "5th.ext", "7th.ext", "9th.ext")
      

      Trying to load a QML file from an asset URL also fails:

      QQmlApplicationEngine engine;
      engine.load(QUrl(QStringLiteral("assets:/main.qml")));
      // Output:
      // W libqtandroid_assets_test_x86.so: QIODevice::read (QFile, "assets:/main.qml"): Called with maxSize < 0
      // W libqtandroid_assets_test_x86.so: QQmlApplicationEngine failed to load component
      // W libqtandroid_assets_test_x86.so: assets:/main.qml:1 Expected token `numeric literal'
      

      Tying to load the same qml file using QFile seems to succeed:

      QFile file(QStringLiteral("assets:/main.qml"));
      file.open(QIODevice::ReadOnly);
      const qint64 fileSize = file.size();
      const QByteArray contents = file.readAll();
      // fileSize and contents.size() are identical at this point, no warnings on console
      

      A complete qmake project with all of the above code as well as the asset files is attached.

      Attachments

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

        Activity

          People

            taipan BogDan Vatra
            stefan_froglogic Stefan Gehn (Inactive)
            Votes:
            7 Vote for this issue
            Watchers:
            7 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes