From c98860db9e462e1a66a730d638f5bb7b162f6197 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Camilla=20L=C3=B6wy?= Date: Sun, 3 Dec 2023 17:07:25 +0100 Subject: [PATCH] Add assertions for context function invariants Related to #2327 (cherry picked from commit 93d70cb6a8c9571b5b493936596633a1a8538cea) --- src/egl_context.c | 1 + src/glx_context.c | 1 + src/nsgl_context.m | 9 ++++----- src/wgl_context.c | 1 + 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/egl_context.c b/src/egl_context.c index aeadbded..53667bd5 100644 --- a/src/egl_context.c +++ b/src/egl_context.c @@ -304,6 +304,7 @@ static int extensionSupportedEGL(const char* extension) static GLFWglproc getProcAddressEGL(const char* procname) { _GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot); + assert(window != NULL); if (window->context.egl.client) { diff --git a/src/glx_context.c b/src/glx_context.c index 46f63476..220e3d02 100644 --- a/src/glx_context.c +++ b/src/glx_context.c @@ -190,6 +190,7 @@ static void swapBuffersGLX(_GLFWwindow* window) static void swapIntervalGLX(int interval) { _GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot); + assert(window != NULL); if (_glfw.glx.EXT_swap_control) { diff --git a/src/nsgl_context.m b/src/nsgl_context.m index 78d688c4..e984caeb 100644 --- a/src/nsgl_context.m +++ b/src/nsgl_context.m @@ -81,11 +81,10 @@ static void swapIntervalNSGL(int interval) @autoreleasepool { _GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot); - if (window) - { - [window->context.nsgl.object setValues:&interval - forParameter:NSOpenGLContextParameterSwapInterval]; - } + assert(window != NULL); + + [window->context.nsgl.object setValues:&interval + forParameter:NSOpenGLContextParameterSwapInterval]; } // autoreleasepool } diff --git a/src/wgl_context.c b/src/wgl_context.c index a7704738..eebf6cd5 100644 --- a/src/wgl_context.c +++ b/src/wgl_context.c @@ -333,6 +333,7 @@ static void swapBuffersWGL(_GLFWwindow* window) static void swapIntervalWGL(int interval) { _GLFWwindow* window = _glfwPlatformGetTls(&_glfw.contextSlot); + assert(window != NULL); window->context.wgl.interval = interval;