From fcda17c7d39a981d64b844c002ea5b37c1683126 Mon Sep 17 00:00:00 2001 From: Yousef Khadadeh Date: Wed, 4 Feb 2026 19:15:58 +0300 Subject: [PATCH] Delete window cache surface on quit --- src/DrawingProgram/DrawingProgramCache.cpp | 10 +++++----- src/DrawingProgram/DrawingProgramCache.hpp | 2 +- src/main.cpp | 3 +++ 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/DrawingProgram/DrawingProgramCache.cpp b/src/DrawingProgram/DrawingProgramCache.cpp index d81375a..3a84882 100644 --- a/src/DrawingProgram/DrawingProgramCache.cpp +++ b/src/DrawingProgram/DrawingProgramCache.cpp @@ -110,7 +110,7 @@ void DrawingProgramCache::clear_own_cached_surfaces() { std::erase_if(nodeCacheMap, [&](auto& nodeCachePair) { return nodeCachePair.second.attachedDrawingProgramCache == this; }); - if(windowCache.attachedDrawingProgramCache == this) + if(windowCache.attachedDrawingProgramCache == this) // Don't delete the cache surface. We don't have to reallocate it if the window size didn't change windowCache.attachedDrawingProgramCache = nullptr; } @@ -338,10 +338,6 @@ void DrawingProgramCache::refresh_draw_cache(const std::shared_ptr>& drawBounds); void invalidate_cache_at_aabb(const SCollision::AABB& aabb); - void set_clear_window_cache(); + static void delete_window_cache_surface(); CanvasComponentContainer::ObjInfo* get_front_object_colliding_with_in_editing_layer(const SCollision::ColliderCollection& cC); ~DrawingProgramCache(); diff --git a/src/main.cpp b/src/main.cpp index 36cc4c5..ca1cc88 100755 --- a/src/main.cpp +++ b/src/main.cpp @@ -55,6 +55,7 @@ #include #include #include +#include "DrawingProgram/DrawingProgramCache.hpp" #include @@ -793,6 +794,8 @@ SDL_AppResult SDL_AppEvent(void *appstate, SDL_Event *event) { } void SDL_AppQuit(void *appstate, SDL_AppResult result) { + DrawingProgramCache::delete_window_cache_surface(); + MainStruct& mS = *((MainStruct*)appstate); try { mS.m->save_config();