fix: cannot load images under WSL2 network location
workaround resolve GH-7
This commit is contained in:
parent
761f5e064c
commit
9f67be61fb
|
@ -31,6 +31,17 @@ void GraphicsView::showFileFromUrl(const QUrl &url, bool doRequestGallery)
|
||||||
|
|
||||||
QString filePath(url.toLocalFile());
|
QString filePath(url.toLocalFile());
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
// TODO: remove this workaround when M$ change the "wsl$" hostname.
|
||||||
|
if (Q_UNLIKELY(url.scheme() == QStringLiteral("qtbug-86277"))) {
|
||||||
|
filePath = url.path();
|
||||||
|
// Qt's QUrl won't work with such hostname anyway so the urls will
|
||||||
|
// still be the wrong one when requesting gallery. So we just don't
|
||||||
|
// request gallery here...
|
||||||
|
doRequestGallery = false;
|
||||||
|
}
|
||||||
|
#endif // Q_OS_WIN
|
||||||
|
|
||||||
if (filePath.endsWith(".svg")) {
|
if (filePath.endsWith(".svg")) {
|
||||||
showSvg(filePath);
|
showSvg(filePath);
|
||||||
} else if (filePath.endsWith(".gif")) {
|
} else if (filePath.endsWith(".gif")) {
|
||||||
|
|
8
main.cpp
8
main.cpp
|
@ -37,6 +37,14 @@ int main(int argc, char *argv[])
|
||||||
QList<QUrl> urlList;
|
QList<QUrl> urlList;
|
||||||
for (const QString & str : urlStrList) {
|
for (const QString & str : urlStrList) {
|
||||||
QUrl url = QUrl::fromLocalFile(str);
|
QUrl url = QUrl::fromLocalFile(str);
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
// TODO: remove this workaround when M$ change the "wsl$" hostname.
|
||||||
|
if (Q_UNLIKELY(str.startsWith(R"(\\wsl$\)"))) {
|
||||||
|
url.clear();
|
||||||
|
url.setScheme(QStringLiteral("qtbug-86277"));
|
||||||
|
url.setPath(str);
|
||||||
|
}
|
||||||
|
#endif // Q_OS_WIN
|
||||||
if (url.isValid()) {
|
if (url.isValid()) {
|
||||||
urlList.append(url);
|
urlList.append(url);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user