evas/wayland_egl: Check re->win before calling glMakeCurrent.

This pointer could be NULL if the window was hidden before calling
glMakeCurrent, which would make the program crash. In fact, at least
elm_win hides the window before actually deleting it (thus calling this
function).

SVN revision: 79017
This commit is contained in:
Rafael Antognolli 2012-11-09 11:13:26 +00:00
parent 156671674b
commit 9a673b2d4c
1 changed files with 38 additions and 24 deletions

View File

@ -2679,11 +2679,14 @@ eng_gl_surface_destroy(void *data, void *surface)
if ((rsc = eina_tls_get(resource_key)) == EINA_FALSE) return 0; if ((rsc = eina_tls_get(resource_key)) == EINA_FALSE) return 0;
ret = eglMakeCurrent(re->win->egl_disp, rsc->surface, rsc->surface, rsc->context); if (re->win)
if (!ret)
{ {
ERR("xxxMakeCurrent() failed!"); ret = eglMakeCurrent(re->win->egl_disp, rsc->surface, rsc->surface, rsc->context);
return 0; if (!ret)
{
ERR("xxxMakeCurrent() failed!");
return 0;
}
} }
// Delete FBO/RBO and Texture here // Delete FBO/RBO and Texture here
@ -2696,12 +2699,15 @@ eng_gl_surface_destroy(void *data, void *surface)
if (sfc->rb_stencil) if (sfc->rb_stencil)
glDeleteRenderbuffers(1, &sfc->rb_stencil); glDeleteRenderbuffers(1, &sfc->rb_stencil);
ret = eglMakeCurrent(re->win->egl_disp, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT); if (re->win)
if (!ret)
{ {
ERR("xxxMakeCurrent() failed!"); ret = eglMakeCurrent(re->win->egl_disp, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
free(sfc); if (!ret)
return 0; {
ERR("xxxMakeCurrent() failed!");
free(sfc);
return 0;
}
} }
free(sfc); free(sfc);
@ -2777,12 +2783,15 @@ eng_gl_context_destroy(void *data, void *context)
if ((rsc = eina_tls_get(resource_key)) == EINA_FALSE) return 0; if ((rsc = eina_tls_get(resource_key)) == EINA_FALSE) return 0;
// 1. Do a make current with the given context // 1. Do a make current with the given context
ret = eglMakeCurrent(re->win->egl_disp, rsc->surface, if (re->win)
rsc->surface, ctx->context);
if (!ret)
{ {
ERR("xxxMakeCurrent() failed!"); ret = eglMakeCurrent(re->win->egl_disp, rsc->surface,
return 0; rsc->surface, ctx->context);
if (!ret)
{
ERR("xxxMakeCurrent() failed!");
return 0;
}
} }
// 2. Delete the FBO // 2. Delete the FBO
@ -2790,16 +2799,20 @@ eng_gl_context_destroy(void *data, void *context)
glDeleteFramebuffers(1, &ctx->context_fbo); glDeleteFramebuffers(1, &ctx->context_fbo);
// 3. Destroy the Context // 3. Destroy the Context
eglDestroyContext(re->win->egl_disp, ctx->context); if (re->win)
eglDestroyContext(re->win->egl_disp, ctx->context);
ctx->context = EGL_NO_CONTEXT; ctx->context = EGL_NO_CONTEXT;
ret = eglMakeCurrent(re->win->egl_disp, EGL_NO_SURFACE, if (re->win)
EGL_NO_SURFACE, EGL_NO_CONTEXT);
if (!ret)
{ {
ERR("xxxMakeCurrent() failed!"); ret = eglMakeCurrent(re->win->egl_disp, EGL_NO_SURFACE,
return 0; EGL_NO_SURFACE, EGL_NO_CONTEXT);
if (!ret)
{
ERR("xxxMakeCurrent() failed!");
return 0;
}
} }
if (current_evgl_ctx == ctx) if (current_evgl_ctx == ctx)
@ -2881,10 +2894,11 @@ eng_gl_make_current(void *data EINA_UNUSED, void *surface, void *context)
eng_window_use(NULL); eng_window_use(NULL);
// Do a make current // Do a make current
ret = eglMakeCurrent(re->win->egl_disp, if (re->win)
re->win->egl_surface[0], ret = eglMakeCurrent(re->win->egl_disp,
re->win->egl_surface[0], re->win->egl_surface[0],
ctx->context); re->win->egl_surface[0],
ctx->context);
if (!ret) if (!ret)
{ {