From 91f2653b71f573216d4bf4344ebf77f32e10d93e Mon Sep 17 00:00:00 2001 From: Emmanuele Bassi Date: Fri, 31 Oct 2008 12:48:26 +0000 Subject: [PATCH] 2008-10-31 Emmanuele Bassi Bug 1200 - Crash with invalid DISPLAY * clutter/clutter-main.c: Use the ClutterBackend wrapper API instead of directly checking the class structure. * clutter/glx/clutter-backend-glx.c: Return the correct value in case of failure. * clutter/x11/clutter-backend-x11.c: Bail out if XOpenDisplay() failed. --- ChangeLog | 13 +++++++++++++ clutter/clutter-main.c | 10 +++------- clutter/glx/clutter-backend-glx.c | 6 ++++-- clutter/x11/clutter-backend-x11.c | 8 ++++++++ 4 files changed, 28 insertions(+), 9 deletions(-) diff --git a/ChangeLog b/ChangeLog index 4bdd16a3f..4d8f1be3b 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,16 @@ +2008-10-31 Emmanuele Bassi + + Bug 1200 - Crash with invalid DISPLAY + + * clutter/clutter-main.c: Use the ClutterBackend wrapper API + instead of directly checking the class structure. + + * clutter/glx/clutter-backend-glx.c: Return the correct value + in case of failure. + + * clutter/x11/clutter-backend-x11.c: Bail out if XOpenDisplay() + failed. + 2008-10-30 Emmanuele Bassi * clutter/cogl/cogl-color.h: diff --git a/clutter/clutter-main.c b/clutter/clutter-main.c index 0176e484c..4b00fbd2f 100644 --- a/clutter/clutter-main.c +++ b/clutter/clutter-main.c @@ -1063,9 +1063,8 @@ clutter_init_real (GError **error) /* * Call backend post parse hooks. */ - if (CLUTTER_BACKEND_GET_CLASS (backend)->post_parse) - if (!CLUTTER_BACKEND_GET_CLASS (backend)->post_parse (backend, error)) - return CLUTTER_INIT_ERROR_BACKEND; + if (!_clutter_backend_post_parse (backend, error)) + return CLUTTER_INIT_ERROR_BACKEND; /* * Resolution requires display to be open, so can only be queried after @@ -1208,10 +1207,7 @@ pre_parse_hook (GOptionContext *context, clutter_default_fps = CLAMP (default_fps, 1, 1000); } - if (CLUTTER_BACKEND_GET_CLASS (backend)->pre_parse) - return CLUTTER_BACKEND_GET_CLASS (backend)->pre_parse (backend, error); - - return TRUE; + return _clutter_backend_pre_parse (backend, error); } /* post_parse_hook: initialise the context and data structures diff --git a/clutter/glx/clutter-backend-glx.c b/clutter/glx/clutter-backend-glx.c index 0369716ee..9f4f47b4a 100644 --- a/clutter/glx/clutter-backend-glx.c +++ b/clutter/glx/clutter-backend-glx.c @@ -135,14 +135,16 @@ clutter_backend_glx_post_parse (ClutterBackend *backend, g_set_error (error, CLUTTER_INIT_ERROR, CLUTTER_INIT_ERROR_BACKEND, "XServer appears to lack required GLX support"); - return 1; + + return FALSE; } } + else + return FALSE; return TRUE; } - static const GOptionEntry entries[] = { { "vblank", 0, diff --git a/clutter/x11/clutter-backend-x11.c b/clutter/x11/clutter-backend-x11.c index c4123143f..f05589b9f 100644 --- a/clutter/x11/clutter-backend-x11.c +++ b/clutter/x11/clutter-backend-x11.c @@ -138,6 +138,14 @@ clutter_backend_x11_post_parse (ClutterBackend *backend, CLUTTER_NOTE (BACKEND, "XOpenDisplay on `%s'", clutter_display_name); backend_x11->xdpy = XOpenDisplay (clutter_display_name); + if (backend_x11->xdpy == None) + { + g_set_error (error, CLUTTER_INIT_ERROR, + CLUTTER_INIT_ERROR_BACKEND, + "Unable to open display `%s'", + clutter_display_name); + return FALSE; + } } else {