diff --git a/src/graphics/shader_files_manager.hpp b/src/graphics/shader_files_manager.hpp index bd30e4342..449686a6f 100644 --- a/src/graphics/shader_files_manager.hpp +++ b/src/graphics/shader_files_manager.hpp @@ -54,16 +54,16 @@ public: // ------------------------------------------------------------------------ ~ShaderFilesManager() { - clearAllShaderFiles(); + removeAllShaderFiles(); } // ------------------------------------------------------------------------ - void clearAllShaderFiles() + void removeAllShaderFiles() { - clearUnusedShaderFiles(); + removeUnusedShaderFiles(); assert(m_shader_files_loaded.empty()); } // ------------------------------------------------------------------------ - void clearUnusedShaderFiles() + void removeUnusedShaderFiles() { for (auto it = m_shader_files_loaded.begin(); it != m_shader_files_loaded.end();) diff --git a/src/karts/kart_properties.cpp b/src/karts/kart_properties.cpp index 6239426f9..881890571 100644 --- a/src/karts/kart_properties.cpp +++ b/src/karts/kart_properties.cpp @@ -23,6 +23,7 @@ #include "config/player_manager.hpp" #include "graphics/central_settings.hpp" #include "graphics/material_manager.hpp" +#include "graphics/shader_files_manager.hpp" #include "graphics/stk_tex_manager.hpp" #include "graphics/sp/sp_shader_manager.hpp" #include "graphics/sp/sp_texture_manager.hpp" @@ -112,10 +113,11 @@ KartProperties::KartProperties(const std::string &filename) KartProperties::~KartProperties() { #ifndef SERVER_ONLY - m_kart_model = nullptr; - if (CVS->isGLSL()) + if (CVS->isGLSL() && m_kart_model.use_count() == 1) { + m_kart_model = nullptr; SP::SPShaderManager::get()->removeUnusedShaders(); + ShaderFilesManager::getInstance()->removeUnusedShaderFiles(); SP::SPTextureManager::get()->removeUnusedTextures(); } #endif diff --git a/src/utils/debug.cpp b/src/utils/debug.cpp index 9f2c63c1d..bf68128d4 100644 --- a/src/utils/debug.cpp +++ b/src/utils/debug.cpp @@ -251,7 +251,7 @@ bool handleContextMenuAction(s32 cmd_id) Log::info("Debug", "Reloading shaders..."); SP::SPShaderManager::get()->unloadAll(); ShaderBase::killShaders(); - ShaderFilesManager::getInstance()->clearAllShaderFiles(); + ShaderFilesManager::getInstance()->removeAllShaderFiles(); SP::SPShaderManager::get()->initAll(); #endif break;