Added clearing of callbacks on window destruction.

This commit is contained in:
Camilla Berglund 2012-12-23 16:08:17 +01:00
parent ed9e403750
commit be7ad339f7
1 changed files with 14 additions and 0 deletions

View File

@ -494,6 +494,20 @@ GLFWAPI void glfwDestroyWindow(GLFWwindow handle)
if (window == NULL) if (window == NULL)
return; 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 // The window's context must not be current on another thread when the
// window is destroyed // window is destroyed
if (window == _glfwPlatformGetCurrentContext()) if (window == _glfwPlatformGetCurrentContext())