cogl-winsys: Fix freeing a CoglOnscreen
All of the winsys backends didn't handle cleaning up the CoglOnscreen properly so that they would assert in cogl_onscreen_free because the winsys pointer is never freed. They also didn't cope if deinit is called before init (which will be the case if an onscreen is created and freed without being allocated).
This commit is contained in:
parent
6654533e40
commit
463603f1a0
@ -1267,6 +1267,10 @@ _cogl_winsys_onscreen_deinit (CoglOnscreen *onscreen)
|
||||
CoglRendererEGL *egl_renderer = context->display->renderer->winsys;
|
||||
CoglOnscreenEGL *egl_onscreen = onscreen->winsys;
|
||||
|
||||
/* If we never successfully allocated then there's nothing to do */
|
||||
if (egl_onscreen == NULL)
|
||||
return;
|
||||
|
||||
if (egl_onscreen->egl_surface != EGL_NO_SURFACE)
|
||||
{
|
||||
if (eglDestroySurface (egl_renderer->edpy, egl_onscreen->egl_surface)
|
||||
@ -1309,6 +1313,9 @@ _cogl_winsys_onscreen_deinit (CoglOnscreen *onscreen)
|
||||
egl_onscreen->wayland_surface = NULL;
|
||||
}
|
||||
#endif
|
||||
|
||||
g_slice_free (CoglOnscreenEGL, onscreen->winsys);
|
||||
onscreen->winsys = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -878,6 +878,10 @@ _cogl_winsys_onscreen_deinit (CoglOnscreen *onscreen)
|
||||
CoglOnscreenXlib *xlib_onscreen = onscreen->winsys;
|
||||
CoglOnscreenGLX *glx_onscreen = onscreen->winsys;
|
||||
|
||||
/* If we never successfully allocated then there's nothing to do */
|
||||
if (glx_onscreen == NULL)
|
||||
return;
|
||||
|
||||
_cogl_xlib_trap_errors (&old_state);
|
||||
|
||||
if (glx_onscreen->glxwin != None)
|
||||
@ -897,6 +901,9 @@ _cogl_winsys_onscreen_deinit (CoglOnscreen *onscreen)
|
||||
XSync (xlib_renderer->xdpy, False);
|
||||
|
||||
_cogl_xlib_untrap_errors (&old_state);
|
||||
|
||||
g_slice_free (CoglOnscreenGLX, onscreen->winsys);
|
||||
onscreen->winsys = NULL;
|
||||
}
|
||||
|
||||
static void
|
||||
|
@ -654,6 +654,10 @@ _cogl_winsys_onscreen_deinit (CoglOnscreen *onscreen)
|
||||
CoglOnscreenWin32 *win32_onscreen = onscreen->winsys;
|
||||
CoglOnscreenWgl *wgl_onscreen = onscreen->winsys;
|
||||
|
||||
/* If we never successfully allocated then there's nothing to do */
|
||||
if (wgl_onscreen == NULL)
|
||||
return;
|
||||
|
||||
if (wgl_onscreen->client_dc)
|
||||
{
|
||||
if (wgl_context->current_dc == wgl_onscreen->client_dc)
|
||||
@ -669,6 +673,9 @@ _cogl_winsys_onscreen_deinit (CoglOnscreen *onscreen)
|
||||
SetWindowLongPtrW (win32_onscreen->hwnd, 0, (LONG_PTR) 0);
|
||||
DestroyWindow (win32_onscreen->hwnd);
|
||||
}
|
||||
|
||||
g_slice_free (CoglOnscreenWgl, onscreen->winsys);
|
||||
onscreen->winsys = NULL;
|
||||
}
|
||||
|
||||
static gboolean
|
||||
|
Loading…
Reference in New Issue
Block a user