From be7ad339f7743b026cac4074722758c9e520e8a0 Mon Sep 17 00:00:00 2001 From: Camilla Berglund Date: Sun, 23 Dec 2012 16:08:17 +0100 Subject: [PATCH] Added clearing of callbacks on window destruction. --- src/window.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/window.c b/src/window.c index 112b2d50..83db3bdd 100644 --- a/src/window.c +++ b/src/window.c @@ -494,6 +494,20 @@ GLFWAPI void glfwDestroyWindow(GLFWwindow handle) if (window == NULL) return; + // Clear all callbacks to avoid exposing a half torn-down window object + window->windowPosCallback = NULL; + window->windowSizeCallback = NULL; + window->windowCloseCallback = NULL; + window->windowRefreshCallback = NULL; + window->windowFocusCallback = NULL; + window->windowIconifyCallback = NULL; + window->mouseButtonCallback = NULL; + window->cursorPosCallback = NULL; + window->cursorEnterCallback = NULL; + window->scrollCallback = NULL; + window->keyCallback = NULL; + window->charCallback = NULL; + // The window's context must not be current on another thread when the // window is destroyed if (window == _glfwPlatformGetCurrentContext())