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 |
145635,2 | Android: handle image from assets | 5.6 | qt/qt3d | Status: MERGED | +2 | 0 |