Added clearing of callbacks on terminate.

This commit is contained in:
Camilla Berglund 2013-07-30 17:06:06 +02:00
parent a6a5fa937c
commit 63a191eb8d
3 changed files with 11 additions and 6 deletions

View File

@ -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);

View File

@ -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;

View File

@ -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;
}