Fix QFileSelector::select if called with QUrl and scheme "assets"
QFileSelector::select(QUrl) will use ":" for scheme "qrc" to call QFileSelector::select(QString). Scheme "assets" needs to remain "assets:" for select(QString), otherwise it won't recognize the file in "assets". Following failed because it was passed as ":/qml/example.qml" to select(QString): select(QUrl("assets:/qml/example.qml")); This will call select(QString) to: select("assets:/qml/example.qml"); Change-Id: I6bdeed6bb67992498ae3b8e1273c20e70049381a Task-number: QTBUG-50435 Reviewed-by: BogDan Vatra <bogdan@kdab.com>
This commit is contained in:
parent
434302eae1
commit
5ef14c52d0
@ -248,9 +248,16 @@ QUrl QFileSelector::select(const QUrl &filePath) const
|
||||
return filePath;
|
||||
QUrl ret(filePath);
|
||||
if (isLocalScheme(filePath.scheme())) {
|
||||
QString equivalentPath = QLatin1Char(':') + filePath.path();
|
||||
QLatin1String scheme(":");
|
||||
#ifdef Q_OS_ANDROID
|
||||
// use other scheme because ":" means "qrc" here
|
||||
if (filePath.scheme() == QLatin1String("assets"))
|
||||
scheme = QLatin1String("assets:");
|
||||
#endif
|
||||
|
||||
QString equivalentPath = scheme + filePath.path();
|
||||
QString selectedPath = d->select(equivalentPath);
|
||||
ret.setPath(selectedPath.remove(0, 1));
|
||||
ret.setPath(selectedPath.remove(0, scheme.size()));
|
||||
} else {
|
||||
ret = QUrl::fromLocalFile(d->select(ret.toLocalFile()));
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user