From: Benjamin Otte Date: Tue, 6 Jun 2023 02:57:12 +0000 (+0200) Subject: glx: Move error trap even further out X-Git-Tag: archive/raspbian/4.12.3+ds-1+rpi1~1^2^2^2~22^2~1^2~178^2~1 X-Git-Url: https://dgit.raspbian.org/?a=commitdiff_plain;h=14e44f36bfc9a9149e0411db9169416cb6769237;p=gtk4.git glx: Move error trap even further out This way we only create one error trap for all attempts to create a context instead of up to 3. --- diff --git a/gdk/x11/gdkglcontext-glx.c b/gdk/x11/gdkglcontext-glx.c index 07830897f8..4b0ff395be 100644 --- a/gdk/x11/gdkglcontext-glx.c +++ b/gdk/x11/gdkglcontext-glx.c @@ -543,8 +543,6 @@ gdk_x11_context_create_glx_context (GdkGLContext *context, if (share != NULL) share_glx = GDK_X11_GL_CONTEXT_GLX (share); - gdk_x11_display_error_trap_push (display); - supported_versions = gdk_gl_versions_get_for_api (api); for (j = 0; gdk_gl_version_greater_equal (&supported_versions[j], &version); j++) { @@ -572,8 +570,6 @@ gdk_x11_context_create_glx_context (GdkGLContext *context, break; } - gdk_x11_display_error_trap_pop_ignored (display); - if (ctx == NULL) { GDK_DISPLAY_DEBUG (display, OPENGL, "Failed to create a GLX context"); @@ -660,25 +656,35 @@ gdk_x11_gl_context_glx_realize (GdkGLContext *context, if (share != NULL && gdk_gl_context_is_legacy (share)) legacy = TRUE; + gdk_x11_display_error_trap_push (display); + if (preferred_api == GDK_GL_API_GL) { - if ((api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GL, legacy)) || - (api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GLES, legacy)) || - (api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GL, TRUE))) - return api; + api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GL, legacy); + if (api == 0) + api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GLES, legacy); + if (api == 0) + api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GL, TRUE); } else { - if ((api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GLES, FALSE)) || - (api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GL, legacy)) || - (api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GL, TRUE))) - return api; + api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GLES, FALSE); + if (api == 0) + api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GL, legacy); + if (api == 0) + api = gdk_x11_context_create_glx_context (context, GDK_GL_API_GL, TRUE); + } + + gdk_x11_display_error_trap_pop_ignored (display); + + if (api == 0) + { + g_set_error_literal (error, GDK_GL_ERROR, + GDK_GL_ERROR_NOT_AVAILABLE, + _("Unable to create a GL context")); } - g_set_error_literal (error, GDK_GL_ERROR, - GDK_GL_ERROR_NOT_AVAILABLE, - _("Unable to create a GL context")); - return 0; + return api; } #undef N_GLX_ATTRS