Fix up criticals from GdkGLTexture
authorMatthias Clasen <mclasen@redhat.com>
Fri, 24 Mar 2023 15:29:38 +0000 (11:29 -0400)
committerMatthias Clasen <mclasen@redhat.com>
Fri, 24 Mar 2023 15:29:38 +0000 (11:29 -0400)
I broke this in 4291f27b562f58.
I overlooked that there may not be a current context.

gdk/gdkgltexture.c

index 3a9e230afe183c7e83a2206259a59f5ac587f003..ece45ed28c9055d4e2ed82dbeddadcc4474a3805 100644 (file)
@@ -320,14 +320,17 @@ static void
 gdk_gl_texture_determine_format (GdkGLTexture *self)
 {
   GdkTexture *texture = GDK_TEXTURE (self);
+  GdkGLContext *context;
   GLint active_texture;
   GLint internal_format;
   GLint width, height;
 
   /* Abort if somebody else is GL-ing here... */
-  if (!gdk_gl_context_is_shared (self->context, gdk_gl_context_get_current ()) ||
+  context = gdk_gl_context_get_current ();
+  if (context == NULL ||
+      !gdk_gl_context_is_shared (self->context, context) ||
       /* ... or glGetTexLevelParameter() isn't supported */
-      !gdk_gl_context_check_version (gdk_gl_context_get_current (), 0, 0, 3, 1))
+      !gdk_gl_context_check_version (context, 0, 0, 3, 1))
     {
       texture->format = GDK_MEMORY_DEFAULT;
       self->has_mipmap = FALSE;