Clear image cache when tabbing out of canvas

This commit is contained in:
Yousef Khadadeh 2026-02-19 22:29:24 +03:00
parent c7024578af
commit 1f80107005
9 changed files with 32 additions and 0 deletions

View file

@ -287,6 +287,20 @@ ResourceDisplay::Type ImageResourceDisplay::get_type() const {
return ResourceDisplay::Type::IMAGE;
}
void ImageResourceDisplay::clear_cache() {
if(loadThread) {
shutdownLoadThread = true;
loadThread->join();
loadThread = nullptr;
}
for(auto& frame : frames) {
for(auto& mipmap : frame.mipmapLevels)
mipmap = nullptr;
}
for(auto& mipmapStatus : mipmapLevelsStatus)
mipmapStatus = MipmapLevelStatus::UNALLOCATED;
}
ImageResourceDisplay::~ImageResourceDisplay() {
if(loadThread) {
shutdownLoadThread = true;