mirror of
https://github.com/brl/mutter.git
synced 2024-11-23 00:20:42 -05:00
cogl/context: Report error if allocating fallback texture failed
Error out if we fail to allocate the 1x1 all white fallback texture. If we don't do this, and instead continue, any future (likely) allocation failure will end up in obscure places that assumes the fallback texture exists. Related: https://bugzilla.redhat.com/show_bug.cgi?id=1989726 Part-of: <https://gitlab.gnome.org/GNOME/mutter/-/merge_requests/1994>
This commit is contained in:
parent
b10b77cc46
commit
9bd2c5c6f2
@ -49,6 +49,7 @@
|
||||
#include "cogl-gtype-private.h"
|
||||
#include "winsys/cogl-winsys-private.h"
|
||||
|
||||
#include <gio/gio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
@ -98,6 +99,7 @@ cogl_context_new (CoglDisplay *display,
|
||||
uint8_t white_pixel[] = { 0xff, 0xff, 0xff, 0xff };
|
||||
const CoglWinsysVtable *winsys;
|
||||
int i;
|
||||
GError *local_error = NULL;
|
||||
|
||||
_cogl_init ();
|
||||
|
||||
@ -188,6 +190,8 @@ cogl_context_new (CoglDisplay *display,
|
||||
{
|
||||
cogl_object_unref (display);
|
||||
g_free (context);
|
||||
g_set_error (error, G_IO_ERROR, G_IO_ERROR_FAILED,
|
||||
"Failed to initialize context");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@ -298,7 +302,15 @@ cogl_context_new (CoglDisplay *display,
|
||||
COGL_PIXEL_FORMAT_RGBA_8888_PRE,
|
||||
0, /* rowstride */
|
||||
white_pixel,
|
||||
NULL); /* abort on error */
|
||||
&local_error);
|
||||
if (!context->default_gl_texture_2d_tex)
|
||||
{
|
||||
cogl_object_unref (display);
|
||||
g_free (context);
|
||||
g_propagate_prefixed_error (error, local_error,
|
||||
"Failed to create 1x1 fallback texture: ");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
context->atlases = NULL;
|
||||
g_hook_list_init (&context->atlas_reorganize_callbacks, sizeof (GHook));
|
||||
|
Loading…
Reference in New Issue
Block a user