evas-gl_cocoa: fix crashes at engine startup
authorJean Guyomarc'h <jean.guyomarch@openwide.fr>
Mon, 22 Aug 2016 17:52:49 +0000 (19:52 +0200)
committerJean Guyomarc'h <jean@guyomarch.bzh>
Mon, 22 Aug 2016 17:56:08 +0000 (19:56 +0200)
Recently, the gl_cocoa engine started to crash at
startup. glGetIntegerv() in gl_common was called
without any gl context, and therefore segfaulted.

We now make sure it is called after a gl context
has been created and used.

Thanks jpeg for troubleshooting.

Fixes T4402

src/modules/evas/engines/gl_cocoa/evas_engine.c
src/modules/evas/engines/gl_cocoa/evas_engine.h
src/modules/evas/engines/gl_cocoa/evas_gl_cocoa_main.m

index 224a592..27b159a 100644 (file)
@@ -1304,12 +1304,6 @@ eng_image_load_error_get(void *data EINA_UNUSED, void *image)
    return im->im->cache_entry.load_error;
 }
 
-static void *
-_dlsym(const char *sym)
-{
-   return dlsym(RTLD_DEFAULT, sym);
-}
-
 static int
 module_open(Evas_Module *em)
 {
@@ -1396,7 +1390,6 @@ module_open(Evas_Module *em)
    glsym_##sym = dlsym(RTLD_DEFAULT, #sym);
 
    LINK2GENERIC(evas_gl_symbols);
-   glsym_evas_gl_symbols(_dlsym);
 
    /* now advertise out own api */
    em->functions = (void *)(&func);
index 473ed7d..07d0dc6 100644 (file)
@@ -10,6 +10,8 @@
 #include "evas_gl_common.h"
 #include "Evas_Engine_GL_Cocoa.h"
 
+extern Evas_Gl_Symbols glsym_evas_gl_symbols;
+
 extern int _evas_engine_gl_cocoa_log_dom;
 
 #ifdef ERR
index 7df919f..082de38 100644 (file)
@@ -1,4 +1,5 @@
 #include <Cocoa/Cocoa.h>
+#include <dlfcn.h>
 
 #include "evas_engine.h"
 
@@ -76,6 +77,12 @@ static NSOpenGLContext *_evas_gl_cocoa_shared_context = NULL;
 
 @end
 
+static void *
+_dlsym(const char *sym)
+{
+   return dlsym(RTLD_DEFAULT, sym);
+}
+
 
 Evas_GL_Cocoa_Window *
 eng_window_new(void *window,
@@ -92,6 +99,8 @@ eng_window_new(void *window,
    gw->view = [[EvasGLView alloc] initWithFrame:NSMakeRect(0,0,w,h)];
    NSOpenGLContext *ctx = [(NSOpenGLView*)gw->view openGLContext];
    [ctx makeCurrentContext];
+
+   glsym_evas_gl_symbols(_dlsym);
    gw->gl_context = evas_gl_common_context_new();
 
    if (!gw->gl_context)