1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 12:17:44 +00:00

LibGL: Prevent segfault due to texture destruction

Destruction of `GL::GLContext` resulted in the destruction of
`GPU::Driver` _before_ the destruction of the allocated textures, which
in turn point to `GPU::Image` objects. Since the destruction of
`GPU::Driver` unloads the shared library, we were trying to invoke
non-existing code.

Fix this by moving `m_driver` up in `GLContext` so that it's last in
line for destruction.
This commit is contained in:
Jelle Raaijmakers 2022-09-16 23:41:11 +02:00 committed by Brian Gianforcaro
parent 645f6e3c4a
commit f6dfd77268
2 changed files with 10 additions and 6 deletions

View file

@ -21,11 +21,11 @@ __attribute__((visibility("hidden"))) GL::GLContext* g_gl_context;
namespace GL {
GLContext::GLContext(RefPtr<GPU::Driver> driver, NonnullOwnPtr<GPU::Device> device, Gfx::Bitmap& frontbuffer)
: m_viewport { frontbuffer.rect() }
, m_frontbuffer { frontbuffer }
, m_driver { driver }
: m_driver { driver }
, m_rasterizer { move(device) }
, m_device_info { m_rasterizer->info() }
, m_viewport { frontbuffer.rect() }
, m_frontbuffer { frontbuffer }
{
m_texture_units.resize(m_device_info.num_texture_units);
m_active_texture_unit = &m_texture_units[0];