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

Qt3D Texture cannot be loaded from assets on Android

    XMLWordPrintable

Details

    • Bug
    • Resolution: Done
    • P1: Critical
    • 5.6.0 RC
    • 5.7.0
    • Qt3D
    • None
    • Android 5.5 RC
    • Android

    Description

      Textures cannot be loaded on Android from the assets directory, only loading from qrc is working.

      The reason is this statement in qr3d/src/render/frontend/qtextureimage.cpp:

          if (m_url.isLocalFile() || m_url.scheme() == QStringLiteral("qrc")) {
                  QString source = QUrlHelper::urlToLocalFileOrQrc(m_url);
                  QImage img;
                  if (img.load(source)) {
                      dataPtr.reset(new TexImageData());
                      dataPtr->setImage(img);
                  } else {
                      qWarning() << "Failed to load image : " << source;
                  }
              } else {
                  qWarning() << "implement loading from remote URLs";
              }
      

      QUrl::isLocalFile() returns false for the assets scheme (it only returns true for the file scheme), and thus the else-branch is entered for remote URL although it is acutally a local file.

      So there are 2 ways to fix this:
      1.) Change QUrl::setScheme() to also set the IsLocalFile flag to true when the scheme is assets (on Android).
      2.) Change the if-statement in QTextureImage.cpp to:
      if (m_url.isLocalFile() || m_url.scheme() == QStringLiteral("qrc") || m_url.scheme() == QStringLiteral("assets"))

      Would be cool if this minor bug fix makes it into 5.5.

      Attachments

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

        Activity

          People

            taipan BogDan Vatra
            chrisvplay Christian Feldbacher
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes