summaryrefslogtreecommitdiffstats
path: root/src/gui/text/qtextimagehandler.cpp
diff options
context:
space:
mode:
authorChristian Ehrlicher <ch.ehrlicher@gmx.de>2024-01-09 20:19:12 +0100
committerChristian Ehrlicher <ch.ehrlicher@gmx.de>2024-01-21 09:12:33 +0000
commit52a41bac775bea9057acbc4344a29bb7e63297e3 (patch)
tree76c922029a862ec4e319b61702d9afce35082b03 /src/gui/text/qtextimagehandler.cpp
parent747581e0bf491376e39d56f6ce3ce72f0bb9c434 (diff)
QTextImageHandler: Use QUrl::toLocalFile to convert to local file name
Simply stripping away the first six characters does not work on Windows. Amends 2d87c4d881b74619fef966ffb0d7a00cb4ccea50 Pick-to: 6.7 6.6 6.5 6.2 Fixes: QTBUG-120577 Change-Id: If48ba026785cab784f46109e34ac80e39a990b79 Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Diffstat (limited to 'src/gui/text/qtextimagehandler.cpp')
-rw-r--r--src/gui/text/qtextimagehandler.cpp14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/gui/text/qtextimagehandler.cpp b/src/gui/text/qtextimagehandler.cpp
index 70e8961467..5c56c30711 100644
--- a/src/gui/text/qtextimagehandler.cpp
+++ b/src/gui/text/qtextimagehandler.cpp
@@ -23,12 +23,14 @@ static inline QString findAtNxFileOrResource(const QString &baseFileName,
{
// qt_findAtNxFile expects a file name that can be tested with QFile::exists.
// so if the format.name() is a file:/ or qrc:/ URL, then we need to strip away the schema.
- QString localFile = baseFileName;
- if (localFile.startsWith("file:/"_L1))
- localFile = localFile.sliced(6);
- else if (localFile.startsWith("qrc:/"_L1))
- localFile = localFile.sliced(3);
-
+ QString localFile;
+ const QUrl url(baseFileName);
+ if (url.isLocalFile())
+ localFile = url.toLocalFile();
+ else if (baseFileName.startsWith("qrc:/"_L1))
+ localFile = baseFileName.sliced(3);
+ else
+ localFile = baseFileName;
extern QString qt_findAtNxFile(const QString &baseFileName, qreal targetDevicePixelRatio,
qreal *sourceDevicePixelRatio);
return qt_findAtNxFile(localFile, targetDevicePixelRatio, sourceDevicePixelRatio);