[plasma/union/Plasma/6.7] src: Check path exists when loading StyleCache data

Arjen Hiemstra <[email protected]>
Newsgroups gmane.comp.kde.cvs
Message-ID <[email protected]>
Git commit 536a9f199b1dcd2affde2e12b1336199cbb92bbb by Arjen Hiemstra.
Committed on 17/07/2026 at 11:41.
Pushed by ahiemstra into branch 'Plasma/6.7'.

Check path exists when loading StyleCache data

The style or one of its files may have been removed, at which point the
paths in the cache are no longer valid. If that happens, drop the cache.

BUG: 523013


(cherry picked from commit 7c6e49d7a7a816262835d7cdd0ac0da23ef56dd8)

Co-authored-by: Arjen Hiemstra <[email protected]>

M  +6    -0    src/StyleCache.cpp

https://invent.kde.org/plasma/union/-/commit/536a9f199b1dcd2affde2e12b1336199cbb92bbb

diff --git a/src/StyleCache.cpp b/src/StyleCache.cpp
index e5967b99..6e4ed4ef 100644
--- a/src/StyleCache.cpp
+++ b/src/StyleCache.cpp
@@ -135,6 +135,12 @@ std::unique_ptr<StylePrivate> StyleCache::load(const StyleId &styleId) const
 
     for (int i = 0; i < result->cachePaths.size(); ++i) {
         auto path = result->cachePaths.at(i);
+
+        if (!fs::exists(path)) {
+            qCDebug(UNION_GENERAL) << "Ignoring cache file" << path.string() << "original file no longer exists";
+            return nullptr;
+        }
+
         auto cachedModificationTime = result->modificationTimes.at(i);
         auto currentModificationTime = fs::last_write_time(path);
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.