evas/wayland_egl: Skip makecurrent if re->win is NULL.
authorRafael Antognolli <rafael.antognolli@intel.com>
Tue, 13 Aug 2013 19:54:53 +0000 (16:54 -0300)
committerEduardo Lima (Etrunko) <eduardo.lima@intel.com>
Tue, 13 Aug 2013 20:50:28 +0000 (17:50 -0300)
This happens on wayland_egl because we free and set the re->win to NULL
on ecore_evas_hide(). It's a workaround since the proper fix would be to
not free the re->win on hide, but that will require a lot more changes.

src/modules/engines/wayland_egl/evas_engine.c

index c6be47e..cbe10e4 100644 (file)
@@ -2649,11 +2649,14 @@ eng_gl_surface_destroy(void *data, void *surface)
 
    if ((rsc = eina_tls_get(resource_key)) == EINA_FALSE) return 0;
 
-   ret = eglMakeCurrent(re->win->egl_disp, rsc->surface, rsc->surface, rsc->context);
-   if (!ret)
+   if (re->win)
      {
-        ERR("xxxMakeCurrent() failed!");
-        return 0;
+        ret = eglMakeCurrent(re->win->egl_disp, rsc->surface, rsc->surface, rsc->context);
+        if (!ret)
+          {
+             ERR("xxxMakeCurrent() failed!");
+             return 0;
+          }
      }
 
    // Delete FBO/RBO and Texture here
@@ -2666,12 +2669,15 @@ eng_gl_surface_destroy(void *data, void *surface)
    if (sfc->rb_stencil)
       glDeleteRenderbuffers(1, &sfc->rb_stencil);
 
-   ret = eglMakeCurrent(re->win->egl_disp, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
-   if (!ret)
+   if (re->win)
      {
-        ERR("xxxMakeCurrent() failed!");
-        free(sfc);
-        return 0;
+        ret = eglMakeCurrent(re->win->egl_disp, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
+        if (!ret)
+          {
+             ERR("xxxMakeCurrent() failed!");
+             free(sfc);
+             return 0;
+          }
      }
 
    free(sfc);
@@ -2747,12 +2753,15 @@ eng_gl_context_destroy(void *data, void *context)
    if ((rsc = eina_tls_get(resource_key)) == EINA_FALSE) return 0;
 
    // 1. Do a make current with the given context
-   ret = eglMakeCurrent(re->win->egl_disp, rsc->surface,
-                        rsc->surface, ctx->context);
-   if (!ret)
+   if (re->win)
      {
-        ERR("xxxMakeCurrent() failed!");
-        return 0;
+        ret = eglMakeCurrent(re->win->egl_disp, rsc->surface,
+                             rsc->surface, ctx->context);
+        if (!ret)
+          {
+             ERR("xxxMakeCurrent() failed!");
+             return 0;
+          }
      }
 
    // 2. Delete the FBO
@@ -2760,16 +2769,20 @@ eng_gl_context_destroy(void *data, void *context)
      glDeleteFramebuffers(1, &ctx->context_fbo);
 
    // 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;
 
-   ret = eglMakeCurrent(re->win->egl_disp, EGL_NO_SURFACE,
-                        EGL_NO_SURFACE, EGL_NO_CONTEXT);
-   if (!ret)
+   if (re->win)
      {
-        ERR("xxxMakeCurrent() failed!");
-        return 0;
+        ret = eglMakeCurrent(re->win->egl_disp, EGL_NO_SURFACE,
+                             EGL_NO_SURFACE, EGL_NO_CONTEXT);
+        if (!ret)
+          {
+             ERR("xxxMakeCurrent() failed!");
+             return 0;
+          }
      }
 
    if (current_evgl_ctx == ctx)
@@ -2851,15 +2864,25 @@ eng_gl_make_current(void *data __UNUSED__, void *surface, void *context)
                   eng_window_use(NULL);
 
                   // Do a make current
-                  ret = eglMakeCurrent(re->win->egl_disp, 
-                                       re->win->egl_surface[0], 
-                                       re->win->egl_surface[0],
-                                       ctx->context);
-
-                  if (!ret)
+                  // FIXME: Skip makecurrent if re->win is NULL. This happens
+                  // on wayland_egl because we free and set the re->win to NULL
+                  // on ecore_evas_hide(). It's a workaround since the proper
+                  // fix would be to not free the re->win on hide, but that
+                  // will require a lot more changes.
+                  if (!re->win)
+                    return ret = 1;
+                  else
                     {
-                       ERR("xxxMakeCurrent() failed!");
-                       return 0;
+                       ret = eglMakeCurrent(re->win->egl_disp, 
+                                            re->win->egl_surface[0], 
+                                            re->win->egl_surface[0],
+                                            ctx->context);
+
+                       if (!ret)
+                         {
+                            ERR("xxxMakeCurrent() failed!");
+                            return 0;
+                         }
                     }
                }
           }