From 6e53477ce0cff309a304902848c2d6661160e8d4 Mon Sep 17 00:00:00 2001 From: caro Date: Sat, 31 Oct 2009 15:05:23 +0000 Subject: [PATCH] * add shutdown function to properly shut down the graphic system * fix seg fault with the xcb (soft and render) engines Notes: * install fontconfig >= 2.7: it frees correctly its mem * strangely, the xrender xlib and gl xlib engines are segfaulting when XCloseDisplay is called (in the shutdown function). It does not with soft xlib. I absolutely don't know why. git-svn-id: svn+ssh://svn.enlightenment.org/var/svn/e/trunk/expedite@43373 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33 --- src/bin/engine_direct3d.cpp | 10 +++- src/bin/engine_direct3d.h | 1 + src/bin/engine_directfb.c | 11 +++++ src/bin/engine_directfb.h | 1 + src/bin/engine_fb.c | 6 +++ src/bin/engine_fb.h | 1 + src/bin/engine_gl_glew.h | 1 + src/bin/engine_gl_x11.c | 21 ++++++++- src/bin/engine_gl_x11.h | 1 + src/bin/engine_quartz.h | 1 + src/bin/engine_quartz.m | 6 +++ src/bin/engine_software_16_ddraw.cpp | 12 ++++- src/bin/engine_software_16_ddraw.h | 1 + src/bin/engine_software_16_wince.c | 45 +++++++++--------- src/bin/engine_software_16_wince.h | 1 + src/bin/engine_software_16_x11.c | 21 ++++++++- src/bin/engine_software_16_x11.h | 1 + src/bin/engine_software_ddraw.cpp | 10 +++- src/bin/engine_software_ddraw.h | 1 + src/bin/engine_software_gdi.c | 10 +++- src/bin/engine_software_gdi.h | 1 + src/bin/engine_software_sdl.c | 5 ++ src/bin/engine_software_sdl.h | 1 + src/bin/engine_software_xcb.c | 28 +++++++++--- src/bin/engine_software_xcb.h | 1 + src/bin/engine_software_xlib.c | 21 ++++++++- src/bin/engine_software_xlib.h | 1 + src/bin/engine_xrender_x11.c | 20 +++++++- src/bin/engine_xrender_x11.h | 1 + src/bin/engine_xrender_xcb.c | 28 +++++++++--- src/bin/engine_xrender_xcb.h | 1 + src/bin/main.c | 88 +++++++++++++++++++++++++++++------- 32 files changed, 294 insertions(+), 64 deletions(-) diff --git a/src/bin/engine_direct3d.cpp b/src/bin/engine_direct3d.cpp index 039ea52..d27aeb5 100644 --- a/src/bin/engine_direct3d.cpp +++ b/src/bin/engine_direct3d.cpp @@ -5,6 +5,7 @@ static HWND window; +static HINSTANCE instance; static LRESULT CALLBACK @@ -175,7 +176,6 @@ engine_direct3d_args(int argc, char **argv) { WNDCLASS wc; RECT rect; - HINSTANCE instance; HDC dc; MSG msg; Evas_Engine_Info_Direct3D *einfo; @@ -289,3 +289,11 @@ engine_direct3d_loop(void) goto again; } + +void +engine_direct3d_shutdown(void) +{ + DestroyWindow(window); + UnregisterClass("Evas_Direct3D_Test", instance); + FreeLibrary(instance); +} diff --git a/src/bin/engine_direct3d.h b/src/bin/engine_direct3d.h index 86bec74..307f49a 100644 --- a/src/bin/engine_direct3d.h +++ b/src/bin/engine_direct3d.h @@ -9,6 +9,7 @@ extern "C" { int engine_direct3d_args(int argc, char **argv); void engine_direct3d_loop(void); +void engine_direct3d_shutdown(void); #ifdef __cplusplus diff --git a/src/bin/engine_directfb.c b/src/bin/engine_directfb.c index b87342a..e116c76 100644 --- a/src/bin/engine_directfb.c +++ b/src/bin/engine_directfb.c @@ -275,3 +275,14 @@ engine_directfb_loop(void) } } } + +void +engine_directfb_shutdown(void) +{ + DFBCHECK(_input_event->Release(_input_event)); + DFBCHECK(_window_event->Release(_window_event)); + DFBCHECK(_dfb_surface->Release(_dfb_surface)); + DFBCHECK(_dfb_window->Release(_dfb_window)); + DFBCHECK(_layer->Release(_layer)); + DFBCHECK(_dfb->Release(_dfb)); +} diff --git a/src/bin/engine_directfb.h b/src/bin/engine_directfb.h index 867c2e3..af2e448 100644 --- a/src/bin/engine_directfb.h +++ b/src/bin/engine_directfb.h @@ -3,5 +3,6 @@ int engine_directfb_args(int argc, char **argv); void engine_directfb_loop(void); +void engine_directfb_shutdown(void); #endif diff --git a/src/bin/engine_fb.c b/src/bin/engine_fb.c index 4a889a8..e755a49 100644 --- a/src/bin/engine_fb.c +++ b/src/bin/engine_fb.c @@ -46,3 +46,9 @@ engine_fb_loop(void) { return; } + +void +engine_fb_shutdown(void) +{ + return; +} diff --git a/src/bin/engine_fb.h b/src/bin/engine_fb.h index ca4cb39..ce0b3c9 100644 --- a/src/bin/engine_fb.h +++ b/src/bin/engine_fb.h @@ -3,5 +3,6 @@ int engine_fb_args(int argc, char **argv); void engine_fb_loop(void); +void engine_fb_shutdown(void); #endif diff --git a/src/bin/engine_gl_glew.h b/src/bin/engine_gl_glew.h index 8ba61f4..b9e29c9 100644 --- a/src/bin/engine_gl_glew.h +++ b/src/bin/engine_gl_glew.h @@ -4,6 +4,7 @@ int engine_gl_glew_args(int argc, char **argv); void engine_gl_glew_loop(void); +void engine_gl_glew_shutdown(void); #endif /* __ENGINE_GL_GLEW_H__ */ diff --git a/src/bin/engine_gl_x11.c b/src/bin/engine_gl_x11.c index 2a0f393..26feab7 100644 --- a/src/bin/engine_gl_x11.c +++ b/src/bin/engine_gl_x11.c @@ -36,7 +36,7 @@ engine_gl_x11_args(int argc, char **argv) if (!einfo) { printf("Evas does not support the OpenGL X11 Engine\n"); - return 0; + goto close_display; } einfo->info.display = disp; @@ -60,11 +60,14 @@ engine_gl_x11_args(int argc, char **argv) CWBackPixmap | CWBorderPixel | CWBitGravity | CWEventMask, &attr); + if (!win) + goto close_display; + einfo->info.drawable = win; if (!evas_engine_info_set(evas, (Evas_Engine_Info *) einfo)) { printf("Evas can not setup the informations of the OpenGL X11 Engine\n"); - return 0; + goto destroy_window; } XStoreName(disp, win, "Expedite - Evas Test Suite"); @@ -80,6 +83,13 @@ engine_gl_x11_args(int argc, char **argv) while (!first_expose) engine_gl_x11_loop(); return 1; + + destroy_window: + XDestroyWindow(disp, win); + close_display: + XCloseDisplay(disp); + + return 0; } void @@ -204,3 +214,10 @@ engine_gl_x11_loop(void) } goto again; } + +void +engine_gl_x11_shutdown(void) +{ + XDestroyWindow(disp, win); + XCloseDisplay(disp); +} diff --git a/src/bin/engine_gl_x11.h b/src/bin/engine_gl_x11.h index 917b28e..ee9e4f6 100644 --- a/src/bin/engine_gl_x11.h +++ b/src/bin/engine_gl_x11.h @@ -3,5 +3,6 @@ int engine_gl_x11_args(int argc, char **argv); void engine_gl_x11_loop(void); +void engine_gl_x11_shutdown(void); #endif diff --git a/src/bin/engine_quartz.h b/src/bin/engine_quartz.h index efb32f6..d7cebf1 100644 --- a/src/bin/engine_quartz.h +++ b/src/bin/engine_quartz.h @@ -3,5 +3,6 @@ int engine_quartz_args(int argc, char **argv); void engine_quartz_loop(void); +void engine_quartz_shutdown(void); #endif diff --git a/src/bin/engine_quartz.m b/src/bin/engine_quartz.m index 6f4d7e3..ba22ba4 100644 --- a/src/bin/engine_quartz.m +++ b/src/bin/engine_quartz.m @@ -257,3 +257,9 @@ engine_quartz_loop(void) [event release]; [NSAutoreleasePool release]; } + +void +engine_quartz_shutdown(void) +{ + /* If someone knows what to do here... */ +} diff --git a/src/bin/engine_software_16_ddraw.cpp b/src/bin/engine_software_16_ddraw.cpp index 3b6d1e7..ba941b5 100644 --- a/src/bin/engine_software_16_ddraw.cpp +++ b/src/bin/engine_software_16_ddraw.cpp @@ -5,6 +5,7 @@ static HWND window; +static HINSTANCE instance; static int @@ -267,7 +268,6 @@ engine_software_16_ddraw_args(int argc, char **argv) { WNDCLASS wc; RECT rect; - HINSTANCE instance; LPDIRECTDRAW object; LPDIRECTDRAWSURFACE surface_primary; LPDIRECTDRAWSURFACE surface_back; @@ -337,7 +337,7 @@ engine_software_16_ddraw_args(int argc, char **argv) &surface_back, &surface_source, &depth)) - goto destroy_window; + goto destroy_window; evas_output_method_set(evas, evas_render_method_lookup("software_16_ddraw")); einfo = (Evas_Engine_Info_Software_16_DDraw *)evas_engine_info_get(evas); @@ -393,3 +393,11 @@ engine_software_16_ddraw_loop(void) goto again; } + +void +engine_software_16_ddraw_shutdown(void) +{ + DestroyWindow(window); + UnregisterClass("Evas_Software_16_DDraw_Test", instance); + FreeLibrary(instance); +} diff --git a/src/bin/engine_software_16_ddraw.h b/src/bin/engine_software_16_ddraw.h index e733a29..b54f9e7 100644 --- a/src/bin/engine_software_16_ddraw.h +++ b/src/bin/engine_software_16_ddraw.h @@ -9,6 +9,7 @@ extern "C" { int engine_software_16_ddraw_args(int argc, char **argv); void engine_software_16_ddraw_loop(void); +void engine_software_16_ddraw_shutdown(void); #ifdef __cplusplus diff --git a/src/bin/engine_software_16_wince.c b/src/bin/engine_software_16_wince.c index 4692ef6..8839128 100644 --- a/src/bin/engine_software_16_wince.c +++ b/src/bin/engine_software_16_wince.c @@ -215,10 +215,7 @@ engine_software_16_wince_args(int argc, char **argv) wc.lpszClassName = L"Evas_Software_16_WinCE_Test"; if(!RegisterClass(&wc)) - { - FreeLibrary(instance); - return 0; - } + goto free_library; SetRect(&rect, 0, 0, GetSystemMetrics(SM_CXSCREEN), @@ -233,11 +230,7 @@ engine_software_16_wince_args(int argc, char **argv) rect.bottom - rect.top, NULL, NULL, instance, NULL); if (!window) - { - UnregisterClass(L"Evas_Software_16_WinCE_Test", instance); - FreeLibrary(instance); - return 0; - } + goto unregister_class; /* hide top level windows (Task bar, SIP and SIP button */ task_bar = FindWindow(L"HHTaskBar", NULL); @@ -251,12 +244,7 @@ engine_software_16_wince_args(int argc, char **argv) EnableWindow(sip_icon, FALSE); if (!_wince_hardware_keys_register(window)) - { - DestroyWindow(window); - UnregisterClass(L"Evas_Software_16_WinCE_Test", instance); - FreeLibrary(instance); - return 0; - } + goto destroy_window; evas_output_method_set(evas, evas_render_method_lookup("software_16_wince")); @@ -264,10 +252,7 @@ engine_software_16_wince_args(int argc, char **argv) if (!einfo) { printf("Evas does not support the 16bit Software WinCE Engine\n"); - DestroyWindow(window); - UnregisterClass(L"Evas_Software_16_WinCE_Test", instance); - FreeLibrary(instance); - return 0; + goto destroy_window; } einfo->info.window = window; @@ -278,10 +263,7 @@ engine_software_16_wince_args(int argc, char **argv) if (!evas_engine_info_set(evas, (Evas_Engine_Info *) einfo)) { printf("Evas can not setup the informations of the 16 bits Software WinCE Engine\n"); - DestroyWindow(window); - UnregisterClass(L"Evas_Software_16_WinCE_Test", instance); - FreeLibrary(instance); - return 0; + goto destroy_window; } _suspend = einfo->func.suspend; @@ -292,6 +274,15 @@ engine_software_16_wince_args(int argc, char **argv) UpdateWindow(window); return 1; + + destroy_window: + DestroyWindow(window); + unregister_class: + UnregisterClass(L"Evas_Software_16_WinCE_Test", instance); + free_library: + FreeLibrary(instance); + + return 0; } void @@ -310,3 +301,11 @@ engine_software_16_wince_loop(void) goto again; } + +void +engine_software_16_wince_shutdown(void) +{ + DestroyWindow(window); + UnregisterClass(L"Evas_Software_16_WinCE_Test", instance); + FreeLibrary(instance); +} diff --git a/src/bin/engine_software_16_wince.h b/src/bin/engine_software_16_wince.h index f78e0a2..157076c 100644 --- a/src/bin/engine_software_16_wince.h +++ b/src/bin/engine_software_16_wince.h @@ -4,6 +4,7 @@ int engine_software_16_wince_args(int argc, char **argv); void engine_software_16_wince_loop(void); +void engine_software_16_wince_shutdown(void); #endif /* __ENGINE_SOFTWARE_16_WINCE_H__ */ diff --git a/src/bin/engine_software_16_x11.c b/src/bin/engine_software_16_x11.c index 2dd03ac..b760e03 100644 --- a/src/bin/engine_software_16_x11.c +++ b/src/bin/engine_software_16_x11.c @@ -36,7 +36,7 @@ engine_software_16_x11_args(int argc, char **argv) if (!einfo) { printf("Evas does not support the Software 16bit X11 Engine\n"); - return 0; + goto close_display; } einfo->info.display = disp; @@ -57,11 +57,14 @@ engine_software_16_x11_args(int argc, char **argv) CWBackPixmap | CWBorderPixel | CWBitGravity | CWEventMask, &attr); + if (!win) + goto close_display; + einfo->info.drawable = win; if (!evas_engine_info_set(evas, (Evas_Engine_Info *) einfo)) { printf("Evas can not setup the informations of the Software 16bit X11 Engine\n"); - return 0; + goto destroy_window; } XStoreName(disp, win, "Expedite - Evas Test Suite"); @@ -77,6 +80,13 @@ engine_software_16_x11_args(int argc, char **argv) while (!first_expose) engine_software_16_x11_loop(); return 1; + + destroy_window: + XDestroyWindow(disp, win); + close_display: + XCloseDisplay(disp); + + return 0; } void @@ -201,3 +211,10 @@ engine_software_16_x11_loop(void) } goto again; } + +void +engine_software_16_x11_shutdown(void) +{ + XDestroyWindow(disp, win); + XCloseDisplay(disp); +} diff --git a/src/bin/engine_software_16_x11.h b/src/bin/engine_software_16_x11.h index 67f06a1..f79b668 100644 --- a/src/bin/engine_software_16_x11.h +++ b/src/bin/engine_software_16_x11.h @@ -3,5 +3,6 @@ int engine_software_16_x11_args(int argc, char **argv); void engine_software_16_x11_loop(void); +void engine_software_16_x11_shutdown(void); #endif diff --git a/src/bin/engine_software_ddraw.cpp b/src/bin/engine_software_ddraw.cpp index 839d1c3..ac55cdf 100644 --- a/src/bin/engine_software_ddraw.cpp +++ b/src/bin/engine_software_ddraw.cpp @@ -5,6 +5,7 @@ static HWND window; +static HINSTANCE instance; static LRESULT CALLBACK @@ -175,7 +176,6 @@ engine_software_ddraw_args(int argc, char **argv) { WNDCLASS wc; RECT rect; - HINSTANCE instance; HDC dc; Evas_Engine_Info_Software_DDraw *einfo; DWORD style; @@ -292,3 +292,11 @@ engine_software_ddraw_loop(void) goto again; } + +void +engine_software_ddraw_shutdown(void) +{ + DestroyWindow(window); + UnregisterClass("Evas_Software_DDraw_Test", instance); + FreeLibrary(instance); +} diff --git a/src/bin/engine_software_ddraw.h b/src/bin/engine_software_ddraw.h index aa58ba9..c2798aa 100644 --- a/src/bin/engine_software_ddraw.h +++ b/src/bin/engine_software_ddraw.h @@ -9,6 +9,7 @@ extern "C" { int engine_software_ddraw_args(int argc, char **argv); void engine_software_ddraw_loop(void); +void engine_software_ddraw_shutdown(void); #ifdef __cplusplus diff --git a/src/bin/engine_software_gdi.c b/src/bin/engine_software_gdi.c index 545446f..fe57b3f 100644 --- a/src/bin/engine_software_gdi.c +++ b/src/bin/engine_software_gdi.c @@ -5,6 +5,7 @@ static HWND window; +static HINSTANCE instance; static LRESULT CALLBACK @@ -175,7 +176,6 @@ engine_software_gdi_args(int argc, char **argv) { WNDCLASS wc; RECT rect; - HINSTANCE instance; HDC dc; Evas_Engine_Info_Software_Gdi *einfo; DWORD style; @@ -294,3 +294,11 @@ engine_software_gdi_loop(void) goto again; } + +void +engine_software_gdi_shutdown(void) +{ + DestroyWindow(window); + UnregisterClass("Evas_Software_Gdi_Test", instance); + FreeLibrary(instance); +} diff --git a/src/bin/engine_software_gdi.h b/src/bin/engine_software_gdi.h index c7e1695..3d5a41c 100644 --- a/src/bin/engine_software_gdi.h +++ b/src/bin/engine_software_gdi.h @@ -9,6 +9,7 @@ extern "C" { int engine_software_gdi_args(int argc, char **argv); void engine_software_gdi_loop(void); +void engine_software_gdi_shutdown(void); #ifdef __cplusplus diff --git a/src/bin/engine_software_sdl.c b/src/bin/engine_software_sdl.c index dd9f38a..aa480c9 100644 --- a/src/bin/engine_software_sdl.c +++ b/src/bin/engine_software_sdl.c @@ -178,3 +178,8 @@ engine_software_sdl_loop(void) } } } + +void +engine_software_sdl_shutdown(void) +{ +} diff --git a/src/bin/engine_software_sdl.h b/src/bin/engine_software_sdl.h index 6bacf71..55ebbd4 100644 --- a/src/bin/engine_software_sdl.h +++ b/src/bin/engine_software_sdl.h @@ -3,5 +3,6 @@ int engine_software_sdl_args(int argc, char **argv); void engine_software_sdl_loop(void); +void engine_software_sdl_shutdown(void); #endif diff --git a/src/bin/engine_software_xcb.c b/src/bin/engine_software_xcb.c index b79ddb3..30ed03c 100644 --- a/src/bin/engine_software_xcb.c +++ b/src/bin/engine_software_xcb.c @@ -92,7 +92,7 @@ engine_software_xcb_args(int argc, char **argv) if (!einfo) { printf("Evas does not support the Software XCB Engine\n"); - return 0; + goto close_connection; } einfo->info.backend = EVAS_ENGINE_INFO_SOFTWARE_X11_BACKEND_XCB; @@ -121,6 +121,8 @@ engine_software_xcb_args(int argc, char **argv) value_list[5] = einfo->info.colormap; win = xcb_generate_id(conn); + if (!win) + goto close_connection; xcb_create_window(conn, einfo->info.depth, win, screen->root, 0, 0, win_w, win_h, 0, @@ -135,7 +137,7 @@ engine_software_xcb_args(int argc, char **argv) if (!evas_engine_info_set(evas, (Evas_Engine_Info *) einfo)) { printf("Evas can not setup the informations of the Software XCB Engine\n"); - return 0; + goto destroy_window; } /* XStoreName(disp, win, "Expedite - Evas Test Suite"); */ @@ -206,6 +208,13 @@ engine_software_xcb_args(int argc, char **argv) while (!first_expose) engine_software_xcb_loop(); return 1; + + destroy_window: + xcb_destroy_window(conn, win); + close_connection: + xcb_disconnect(conn); + + return 0; } void @@ -290,7 +299,7 @@ engine_software_xcb_loop(void) xcb_key_press_event_t *e; xcb_key_symbols_t *kss; xcb_keysym_t ks; - char *str; + char *str = ""; e = (xcb_key_press_event_t *)ev; @@ -329,7 +338,7 @@ engine_software_xcb_loop(void) str = "Escape"; if (ks == XK_Return) str = "Return"; - if (ks == 71) + if (ks == 113) str = "q"; evas_event_feed_key_down(evas, str, str, NULL, NULL, 0, NULL); @@ -342,7 +351,7 @@ engine_software_xcb_loop(void) xcb_key_release_event_t *e; xcb_key_symbols_t *kss; xcb_keysym_t ks; - char *str; + char *str = ""; e = (xcb_key_release_event_t *)ev; @@ -367,7 +376,7 @@ engine_software_xcb_loop(void) str = "Escape"; if (ks == XK_Return) str = "Return"; - if (ks == 71) + if (ks == 113) str = "q"; evas_event_feed_key_up(evas, str, str, NULL, NULL, 0, NULL); @@ -383,3 +392,10 @@ engine_software_xcb_loop(void) goto again; } + +void +engine_software_xcb_shutdown(void) +{ + xcb_destroy_window(conn, win); + xcb_disconnect(conn); +} diff --git a/src/bin/engine_software_xcb.h b/src/bin/engine_software_xcb.h index a25136d..a73a0b8 100644 --- a/src/bin/engine_software_xcb.h +++ b/src/bin/engine_software_xcb.h @@ -3,5 +3,6 @@ int engine_software_xcb_args(int argc, char **argv); void engine_software_xcb_loop(void); +void engine_software_xcb_shutdown(void); #endif diff --git a/src/bin/engine_software_xlib.c b/src/bin/engine_software_xlib.c index 1cc4555..443e482 100644 --- a/src/bin/engine_software_xlib.c +++ b/src/bin/engine_software_xlib.c @@ -36,7 +36,7 @@ engine_software_xlib_args(int argc, char **argv) if (!einfo) { printf("Evas does not support the Software Xlib Engine\n"); - return 0; + goto close_display; } einfo->info.backend = EVAS_ENGINE_INFO_SOFTWARE_X11_BACKEND_XLIB; @@ -64,11 +64,14 @@ engine_software_xlib_args(int argc, char **argv) CWBackPixmap | CWBorderPixel | CWBitGravity | CWEventMask, &attr); + if (!win) + goto close_display; + einfo->info.drawable = win; if (!evas_engine_info_set(evas, (Evas_Engine_Info *) einfo)) { printf("Evas can not setup the informations of the Software Xlib Engine\n"); - return 0; + goto destroy_window; } XStoreName(disp, win, "Expedite - Evas Test Suite"); @@ -84,6 +87,13 @@ engine_software_xlib_args(int argc, char **argv) while (!first_expose) engine_software_xlib_loop(); return 1; + + destroy_window: + XDestroyWindow(disp, win); + close_display: + XCloseDisplay(disp); + + return 0; } void @@ -208,3 +218,10 @@ engine_software_xlib_loop(void) } goto again; } + +void +engine_software_xlib_shutdown(void) +{ + XDestroyWindow(disp, win); + XCloseDisplay(disp); +} diff --git a/src/bin/engine_software_xlib.h b/src/bin/engine_software_xlib.h index 7964ef7..1df1df7 100644 --- a/src/bin/engine_software_xlib.h +++ b/src/bin/engine_software_xlib.h @@ -3,5 +3,6 @@ int engine_software_xlib_args(int argc, char **argv); void engine_software_xlib_loop(void); +void engine_software_xlib_shutdown(void); #endif diff --git a/src/bin/engine_xrender_x11.c b/src/bin/engine_xrender_x11.c index 6585756..6f12c7b 100644 --- a/src/bin/engine_xrender_x11.c +++ b/src/bin/engine_xrender_x11.c @@ -36,7 +36,7 @@ engine_xrender_x11_args(int argc, char **argv) if (!einfo) { printf("Evas does not support the XRender X11 Engine\n"); - return 0; + goto close_display; } einfo->info.backend = EVAS_ENGINE_INFO_XRENDER_BACKEND_XLIB; @@ -59,12 +59,14 @@ engine_xrender_x11_args(int argc, char **argv) CWBackPixmap | CWBorderPixel | CWBitGravity | CWEventMask, &attr); + if (!win) + goto close_display; einfo->info.drawable = win; if (!evas_engine_info_set(evas, (Evas_Engine_Info *) einfo)) { printf("Evas can not setup the informations of the XRender X11 Engine\n"); - return 0; + goto destroy_window; } XStoreName(disp, win, "Expedite - Evas Test Suite"); @@ -80,6 +82,13 @@ engine_xrender_x11_args(int argc, char **argv) while (!first_expose) engine_xrender_x11_loop(); return 1; + + destroy_window: + XDestroyWindow(disp, win); + close_display: + XCloseDisplay(disp); + + return 0; } void @@ -204,3 +213,10 @@ engine_xrender_x11_loop(void) } goto again; } + +void +engine_xrender_x11_shutdown(void) +{ + XDestroyWindow(disp, win); + XCloseDisplay(disp); +} diff --git a/src/bin/engine_xrender_x11.h b/src/bin/engine_xrender_x11.h index 38a87d6..701d6be 100644 --- a/src/bin/engine_xrender_x11.h +++ b/src/bin/engine_xrender_x11.h @@ -3,5 +3,6 @@ int engine_xrender_x11_args(int argc, char **argv); void engine_xrender_x11_loop(void); +void engine_xrender_x11_shutdown(void); #endif diff --git a/src/bin/engine_xrender_xcb.c b/src/bin/engine_xrender_xcb.c index 72232e1..f663fe2 100644 --- a/src/bin/engine_xrender_xcb.c +++ b/src/bin/engine_xrender_xcb.c @@ -111,7 +111,7 @@ engine_xrender_xcb_args(int argc, char **argv) if (!einfo) { printf("Evas does not support the XRender XCB Engine\n"); - return 0; + goto close_connection; } einfo->info.backend = EVAS_ENGINE_INFO_XRENDER_BACKEND_XCB; @@ -136,6 +136,8 @@ engine_xrender_xcb_args(int argc, char **argv) value_list[5] =screen->default_colormap; win = xcb_generate_id(conn); + if (!win) + goto close_connection; xcb_create_window(conn, screen->root_depth, win, screen->root, 0, 0, win_w, win_h, 0, @@ -148,7 +150,7 @@ engine_xrender_xcb_args(int argc, char **argv) if (!evas_engine_info_set(evas, (Evas_Engine_Info *) einfo)) { printf("Evas can not setup the informations of the XRender XCB Engine\n"); - return 0; + goto destroy_window; } xcb_map_window(conn, win); @@ -221,6 +223,13 @@ engine_xrender_xcb_args(int argc, char **argv) while (!first_expose) engine_xrender_xcb_loop(); return 1; + + destroy_window: + xcb_destroy_window(conn, win); + close_connection: + xcb_disconnect(conn); + + return 0; } void @@ -305,7 +314,7 @@ engine_xrender_xcb_loop(void) xcb_key_press_event_t *e; xcb_key_symbols_t *kss; xcb_keysym_t ks; - char *str; + char *str = ""; e = (xcb_key_press_event_t *)ev; @@ -344,7 +353,7 @@ engine_xrender_xcb_loop(void) str = "Escape"; if (ks == XK_Return) str = "Return"; - if (ks == 71) + if (ks == 113) str = "q"; evas_event_feed_key_down(evas, str, str, NULL, NULL, 0, NULL); @@ -357,7 +366,7 @@ engine_xrender_xcb_loop(void) xcb_key_release_event_t *e; xcb_key_symbols_t *kss; xcb_keysym_t ks; - char *str; + char *str = ""; e = (xcb_key_release_event_t *)ev; @@ -382,7 +391,7 @@ engine_xrender_xcb_loop(void) str = "Escape"; if (ks == XK_Return) str = "Return"; - if (ks == 71) + if (ks == 113) str = "q"; evas_event_feed_key_up(evas, str, str, NULL, NULL, 0, NULL); @@ -398,3 +407,10 @@ engine_xrender_xcb_loop(void) goto again; } + +void +engine_xrender_xcb_shutdown(void) +{ + xcb_destroy_window(conn, win); + xcb_disconnect(conn); +} diff --git a/src/bin/engine_xrender_xcb.h b/src/bin/engine_xrender_xcb.h index 867b943..ba15b4c 100644 --- a/src/bin/engine_xrender_xcb.h +++ b/src/bin/engine_xrender_xcb.h @@ -3,5 +3,6 @@ int engine_xrender_xcb_args(int argc, char **argv); void engine_xrender_xcb_loop(void); +void engine_xrender_xcb_shutdown(void); #endif diff --git a/src/bin/main.c b/src/bin/main.c index cc1edc1..6d18cd8 100644 --- a/src/bin/main.c +++ b/src/bin/main.c @@ -7,6 +7,7 @@ int loops = LOOPS; static char *datadir = NULL; static int go = 1; static void (*loop_func) (void) = NULL; +static void (*shutdown_func) (void) = NULL; /* this guarantees that "random" numbers will always be the same set regardless * of what os/system/etc we are on - as often i need just some "random" set of @@ -1118,6 +1119,12 @@ engine_loop(void) loop_func(); } +void +engine_shutdown(void) +{ + shutdown_func(); +} + static int _engine_go(void) { @@ -1191,67 +1198,115 @@ _engine_args(int argc, char **argv) profile_ok = _profile_parse(argc, argv); #if HAVE_EVAS_SOFTWARE_XLIB if (engine_software_xlib_args(argc, argv)) - loop_func = engine_software_xlib_loop; + { + loop_func = engine_software_xlib_loop; + shutdown_func = engine_software_xlib_shutdown; + } #endif #if HAVE_EVAS_XRENDER_X11 if (engine_xrender_x11_args(argc, argv)) - loop_func = engine_xrender_x11_loop; + { + loop_func = engine_xrender_x11_loop; + shutdown_func = engine_xrender_x11_shutdown; + } #endif #if HAVE_EVAS_OPENGL_X11 if (engine_gl_x11_args(argc, argv)) - loop_func = engine_gl_x11_loop; + { + loop_func = engine_gl_x11_loop; + shutdown_func = engine_gl_x11_shutdown; + } #endif #if HAVE_EVAS_SOFTWARE_XCB if (engine_software_xcb_args(argc, argv)) - loop_func = engine_software_xcb_loop; + { + loop_func = engine_software_xcb_loop; + shutdown_func = engine_software_xcb_shutdown; + } #endif #if HAVE_EVAS_XRENDER_XCB if (engine_xrender_xcb_args(argc, argv)) - loop_func = engine_xrender_xcb_loop; + { + loop_func = engine_xrender_xcb_loop; + shutdown_func = engine_xrender_xcb_shutdown; + } #endif #if HAVE_EVAS_SOFTWARE_GDI if (engine_software_gdi_args(argc, argv)) - loop_func = engine_software_gdi_loop; + { + loop_func = engine_software_gdi_loop; + shutdown_func = engine_software_gdi_shutdown; + } #endif #if HAVE_EVAS_SOFTWARE_DDRAW if (engine_software_ddraw_args(argc, argv)) - loop_func = engine_software_ddraw_loop; + { + loop_func = engine_software_ddraw_loop; + shutdown_func = engine_software_ddraw_shutdown; + } #endif #if HAVE_EVAS_DIRECT3D if (engine_direct3d_args(argc, argv)) - loop_func = engine_direct3d_loop; + { + loop_func = engine_direct3d_loop; + shutdown_func = engine_direct3d_shutdown; + } #endif #if HAVE_EVAS_OPENGL_GLEW if (engine_gl_glew_args(argc, argv)) - loop_func = engine_gl_glew_loop; + { + loop_func = engine_gl_glew_loop; + shutdown_func = engine_gl_glew_shutdown; + } #endif #if HAVE_EVAS_SOFTWARE_SDL if (engine_software_sdl_args(argc, argv)) - loop_func = engine_software_sdl_loop; + { + loop_func = engine_software_sdl_loop; + shutdown_func = engine_software_sdl_shutdown; + } #endif #if HAVE_EVAS_FB if (engine_fb_args(argc, argv)) - loop_func = engine_fb_loop; + { + loop_func = engine_fb_loop; + shutdown_func = engine_fb_shutdown; + } #endif #if HAVE_EVAS_DIRECTFB if (engine_directfb_args(argc, argv)) - loop_func = engine_directfb_loop; + { + loop_func = engine_directfb_loop; + shutdown_func = engine_directfb_shutdown; + } #endif #if HAVE_EVAS_QUARTZ if (engine_quartz_args(argc, argv)) - loop_func = engine_quartz_loop; + { + loop_func = engine_quartz_loop; + shutdown_func = engine_quartz_shutdown; + } #endif #if HAVE_EVAS_SOFTWARE_16_X11 if (engine_software_16_x11_args(argc, argv)) - loop_func = engine_software_16_x11_loop; + { + loop_func = engine_software_16_x11_loop; + shutdown_func = engine_software_16_x11_shutdown; + } #endif #if HAVE_EVAS_SOFTWARE_16_DDRAW if (engine_software_16_ddraw_args(argc, argv)) - loop_func = engine_software_16_ddraw_loop; + { + loop_func = engine_software_16_ddraw_loop; + shutdown_func = engine_software_16_ddraw_shutdown; + } #endif #if HAVE_EVAS_SOFTWARE_16_WINCE if (engine_software_16_wince_args(argc, argv)) - loop_func = engine_software_16_wince_loop; + { + loop_func = engine_software_16_wince_loop; + shutdown_func = engine_software_16_wince_shutdown; + } #endif if ((!loop_func) || (!profile_ok)) { @@ -1377,5 +1432,6 @@ main(int argc, char **argv) evas_free(evas); evas_shutdown(); + engine_shutdown(); return 0; } -- 2.7.4