diff --git a/src/init.c b/src/init.c index 5e26327d..4e334d0e 100644 --- a/src/init.c +++ b/src/init.c @@ -150,6 +150,8 @@ GLFWAPI void glfwTerminate(void) if (!_glfwInitialized) return; + memset(&_glfw.callbacks, 0, sizeof(_glfw.callbacks)); + // Close all remaining windows while (_glfw.windowListHead) glfwDestroyWindow((GLFWwindow*) _glfw.windowListHead); diff --git a/src/internal.h b/src/internal.h index 9a01587f..b6e2136b 100644 --- a/src/internal.h +++ b/src/internal.h @@ -304,7 +304,10 @@ struct _GLFWlibrary _GLFWmonitor** monitors; int monitorCount; - GLFWmonitorfun monitorCallback; + + struct { + GLFWmonitorfun monitor; + } callbacks; // This is defined in the window API's platform.h _GLFW_PLATFORM_LIBRARY_WINDOW_STATE; diff --git a/src/monitor.c b/src/monitor.c index fe965edd..f80d5e9d 100644 --- a/src/monitor.c +++ b/src/monitor.c @@ -141,8 +141,8 @@ void _glfwInputMonitorChange(void) window->monitor = NULL; } - if (_glfw.monitorCallback) - _glfw.monitorCallback((GLFWmonitor*) monitors[i], GLFW_DISCONNECTED); + if (_glfw.callbacks.monitor) + _glfw.callbacks.monitor((GLFWmonitor*) monitors[i], GLFW_DISCONNECTED); } // Find and report newly connected monitors (not in the old list) @@ -163,8 +163,8 @@ void _glfwInputMonitorChange(void) if (j < monitorCount) continue; - if (_glfw.monitorCallback) - _glfw.monitorCallback((GLFWmonitor*) _glfw.monitors[i], GLFW_CONNECTED); + if (_glfw.callbacks.monitor) + _glfw.callbacks.monitor((GLFWmonitor*) _glfw.monitors[i], GLFW_CONNECTED); } _glfwDestroyMonitors(monitors, monitorCount); @@ -326,7 +326,7 @@ GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* handle) GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun cbfun) { _GLFW_REQUIRE_INIT_OR_RETURN(NULL); - _GLFW_SWAP_POINTERS(_glfw.monitorCallback, cbfun); + _GLFW_SWAP_POINTERS(_glfw.callbacks.monitor, cbfun); return cbfun; }