[frameworks/kirigami] src/primitives: Icon: use QUrl::toLocalFile() for file: URL sources
Méven Car <[email protected]>
| Newsgroups | gmane.comp.kde.cvs |
|---|---|
| Message-ID | <[email protected]> |
Git commit 942651d1e1e0c79bf90dbdf749ba86909ee7f663 by Méven Car.
Committed on 21/07/2026 at 10:28.
Pushed by meven into branch 'master'.
Icon: use QUrl::toLocalFile() for file: URL sources
findIcon() stripped the file: scheme with QUrl::path(), which on Windows
returns a leading slash before the drive letter (/C:/...) that cannot be
loaded, leaving the icon in the Error state. toLocalFile() returns a valid
local path on every platform and matches the previous behavior on Unix.
test_portrait_aspect_ratio is the first test to load an image from a file
URL, so it was the first to hit this on Windows CI.
M +1 -1 src/primitives/icon.cpp
https://invent.kde.org/frameworks/kirigami/-/commit/942651d1e1e0c79bf90dbdf749ba86909ee7f663
diff --git a/src/primitives/icon.cpp b/src/primitives/icon.cpp
index 9a2821878..8ad726e68 100644
--- a/src/primitives/icon.cpp
+++ b/src/primitives/icon.cpp
@@ -480,7 +480,7 @@ QImage Icon::findIcon(const QSize &size)
if (iconSource.startsWith(QLatin1String("qrc:/"))) {
iconSource = iconSource.mid(3);
} else if (iconSource.startsWith(QLatin1String("file:/"))) {
- iconSource = QUrl(iconSource).path();
+ iconSource = QUrl(iconSource).toLocalFile();
}
const QIcon icon = loadFromTheme(iconSource);