Only try to clean stuff if kart model is unique

This commit is contained in:
Benau 2018-01-22 00:13:27 +08:00
parent f8c6de316a
commit c85425c473
3 changed files with 9 additions and 7 deletions

View File

@ -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();)

View File

@ -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

View File

@ -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;