Skip to content

Commit

Permalink
Fix exit crash when built for GLES2 on Linux (#5118)
Browse files Browse the repository at this point in the history
  • Loading branch information
Icenowy authored Jun 26, 2024
1 parent 118cde2 commit 41a7b80
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 3 deletions.
7 changes: 7 additions & 0 deletions lib/irrlicht/source/Irrlicht/CIrrDeviceSDL.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
#include <stdlib.h>
#include "SIrrCreationParameters.h"
#include "COpenGLExtensionHandler.h"
#include "COGLES2Driver.h"

#include "guiengine/engine.hpp"
#include "ge_main.hpp"
Expand Down Expand Up @@ -240,6 +241,12 @@ CIrrDeviceSDL::~CIrrDeviceSDL()
irr::video::COpenGLExtensionHandler* h = dynamic_cast<irr::video::COpenGLExtensionHandler*>(VideoDriver);
if (h)
h->clearGLExtensions();
#endif
#ifdef _IRR_COMPILE_WITH_OGLES2_
irr::video::COGLES2Driver* es2 = dynamic_cast<irr::video::COGLES2Driver*>(VideoDriver);
if (es2) {
es2->cleanUp();
}
#endif
GE::GEVulkanDriver* gevk = dynamic_cast<GE::GEVulkanDriver*>(VideoDriver);
if (gevk)
Expand Down
4 changes: 1 addition & 3 deletions lib/irrlicht/source/Irrlicht/COGLES2Driver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,9 +122,7 @@ namespace video
//! destructor
COGLES2Driver::~COGLES2Driver()
{
deleteMaterialRenders();
delete MaterialRenderer2D;
deleteAllTextures();
cleanUp();

if (BridgeCalls)
delete BridgeCalls;
Expand Down
10 changes: 10 additions & 0 deletions lib/irrlicht/source/Irrlicht/COGLES2Driver.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ namespace irr
#include "EDriverFeatures.h"
#include "fast_atof.h"
#include "COGLES2ExtensionHandler.h"
#include "COGLES2Renderer2D.h"

class ContextManagerEGL;

Expand Down Expand Up @@ -397,6 +398,15 @@ namespace video
ContextManagerEGL* getEGLContext() {return EglContext;}
#endif

void cleanUp() {
deleteMaterialRenders();
if (MaterialRenderer2D) {
delete MaterialRenderer2D;
MaterialRenderer2D = NULL;
}
deleteAllTextures();
}

private:
// Bridge calls.
COGLES2CallBridge* BridgeCalls;
Expand Down

0 comments on commit 41a7b80

Please sign in to comment.