Fix #9028: [OpenGL] Clear cursor cache on destroying the OpenGL backend.

This commit is contained in:
Michael Lutz 2021-04-12 21:44:32 +02:00
parent 468b1c6c5d
commit 433602b072
2 changed files with 17 additions and 7 deletions

View File

@ -510,7 +510,7 @@ OpenGLBackend::~OpenGLBackend()
_glDeleteBuffers(1, &this->anim_pbo); _glDeleteBuffers(1, &this->anim_pbo);
} }
if (_glDeleteTextures != nullptr) { if (_glDeleteTextures != nullptr) {
ClearCursorCache(); this->InternalClearCursorCache();
OpenGLSprite::Destroy(); OpenGLSprite::Destroy();
_glDeleteTextures(1, &this->vid_texture); _glDeleteTextures(1, &this->vid_texture);
@ -1082,12 +1082,7 @@ void OpenGLBackend::PopulateCursorCache()
this->clear_cursor_cache = false; this->clear_cursor_cache = false;
this->last_sprite_pal = (PaletteID)-1; this->last_sprite_pal = (PaletteID)-1;
Sprite *sp; this->InternalClearCursorCache();
while ((sp = this->cursor_cache.Pop()) != nullptr) {
OpenGLSprite *sprite = (OpenGLSprite *)sp->data;
sprite->~OpenGLSprite();
free(sp);
}
} }
this->cursor_pos = _cursor.pos; this->cursor_pos = _cursor.pos;
@ -1113,6 +1108,19 @@ void OpenGLBackend::PopulateCursorCache()
/** /**
* Clear all cached cursor sprites. * Clear all cached cursor sprites.
*/ */
void OpenGLBackend::InternalClearCursorCache()
{
Sprite *sp;
while ((sp = this->cursor_cache.Pop()) != nullptr) {
OpenGLSprite *sprite = (OpenGLSprite *)sp->data;
sprite->~OpenGLSprite();
free(sp);
}
}
/**
* Queue a request for cursor cache clear.
*/
void OpenGLBackend::ClearCursorCache() void OpenGLBackend::ClearCursorCache()
{ {
/* If the game loop is threaded, this function might be called /* If the game loop is threaded, this function might be called

View File

@ -77,6 +77,8 @@ private:
const char *Init(); const char *Init();
bool InitShaders(); bool InitShaders();
void InternalClearCursorCache();
void RenderOglSprite(OpenGLSprite *gl_sprite, PaletteID pal, int x, int y, ZoomLevel zoom); void RenderOglSprite(OpenGLSprite *gl_sprite, PaletteID pal, int x, int y, ZoomLevel zoom);
public: public: