[Fix] (cache.cpp): Prevent glsl cache loading fragment from crashing when glsl cache file is broken.

Signed-off-by: BZLZHH <admin@bzlzhh.top>
This commit is contained in:
BZLZHH 2025-03-01 13:54:42 +08:00
parent b20668c6ff
commit 2823791458
2 changed files with 36 additions and 27 deletions

View File

@ -150,6 +150,7 @@ void Cache::maintainCacheSize() {
bool Cache::load() {
try {
ifstream file(GLSL_CACHE_FILE_PATH, ios::binary);
if (!file) return false;
@ -177,6 +178,14 @@ bool Cache::load() {
maintainCacheSize();
return true;
} catch (...) {
LOG_W_FORCE("Error while loading glsl cache file. Clearing it...")
cacheMap.clear();
cacheSize = 0;
cacheList.clear();
save();
return false;
}
}