From 1b3745b58beedfc11b545f80058d6f7a77a069c6 Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Sat, 23 Sep 2017 20:23:01 -0300 Subject: [PATCH] Fix a crash on quit if a non-default shader is active when quitting. --HG-- branch : minor --- src/modules/graphics/Graphics.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/modules/graphics/Graphics.cpp b/src/modules/graphics/Graphics.cpp index c32c53e40..8bf633209 100644 --- a/src/modules/graphics/Graphics.cpp +++ b/src/modules/graphics/Graphics.cpp @@ -128,10 +128,10 @@ Graphics::Graphics() Graphics::~Graphics() { - states.clear(); - - defaultFont.set(nullptr); - + // Clean up standard shaders before the active shader. If we do it after, + // the active shader may try to activate a standard shader when deactivating + // itself, which will cause problems since it calls Graphics methods in the + // Graphics destructor. for (int i = 0; i < Shader::STANDARD_MAX_ENUM; i++) { if (Shader::standardShaders[i]) @@ -141,6 +141,10 @@ Graphics::~Graphics() } } + states.clear(); + + defaultFont.set(nullptr); + delete streamBufferState.vb[0]; delete streamBufferState.vb[1]; delete streamBufferState.indexBuffer;