mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 21:14:35 +00:00
Added clearing of callbacks on terminate.
This commit is contained in:
parent
a6a5fa937c
commit
63a191eb8d
@ -150,6 +150,8 @@ GLFWAPI void glfwTerminate(void)
|
|||||||
if (!_glfwInitialized)
|
if (!_glfwInitialized)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
memset(&_glfw.callbacks, 0, sizeof(_glfw.callbacks));
|
||||||
|
|
||||||
// Close all remaining windows
|
// Close all remaining windows
|
||||||
while (_glfw.windowListHead)
|
while (_glfw.windowListHead)
|
||||||
glfwDestroyWindow((GLFWwindow*) _glfw.windowListHead);
|
glfwDestroyWindow((GLFWwindow*) _glfw.windowListHead);
|
||||||
|
@ -304,7 +304,10 @@ struct _GLFWlibrary
|
|||||||
|
|
||||||
_GLFWmonitor** monitors;
|
_GLFWmonitor** monitors;
|
||||||
int monitorCount;
|
int monitorCount;
|
||||||
GLFWmonitorfun monitorCallback;
|
|
||||||
|
struct {
|
||||||
|
GLFWmonitorfun monitor;
|
||||||
|
} callbacks;
|
||||||
|
|
||||||
// This is defined in the window API's platform.h
|
// This is defined in the window API's platform.h
|
||||||
_GLFW_PLATFORM_LIBRARY_WINDOW_STATE;
|
_GLFW_PLATFORM_LIBRARY_WINDOW_STATE;
|
||||||
|
@ -141,8 +141,8 @@ void _glfwInputMonitorChange(void)
|
|||||||
window->monitor = NULL;
|
window->monitor = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_glfw.monitorCallback)
|
if (_glfw.callbacks.monitor)
|
||||||
_glfw.monitorCallback((GLFWmonitor*) monitors[i], GLFW_DISCONNECTED);
|
_glfw.callbacks.monitor((GLFWmonitor*) monitors[i], GLFW_DISCONNECTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Find and report newly connected monitors (not in the old list)
|
// Find and report newly connected monitors (not in the old list)
|
||||||
@ -163,8 +163,8 @@ void _glfwInputMonitorChange(void)
|
|||||||
if (j < monitorCount)
|
if (j < monitorCount)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
if (_glfw.monitorCallback)
|
if (_glfw.callbacks.monitor)
|
||||||
_glfw.monitorCallback((GLFWmonitor*) _glfw.monitors[i], GLFW_CONNECTED);
|
_glfw.callbacks.monitor((GLFWmonitor*) _glfw.monitors[i], GLFW_CONNECTED);
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfwDestroyMonitors(monitors, monitorCount);
|
_glfwDestroyMonitors(monitors, monitorCount);
|
||||||
@ -326,7 +326,7 @@ GLFWAPI const char* glfwGetMonitorName(GLFWmonitor* handle)
|
|||||||
GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun cbfun)
|
GLFWAPI GLFWmonitorfun glfwSetMonitorCallback(GLFWmonitorfun cbfun)
|
||||||
{
|
{
|
||||||
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
||||||
_GLFW_SWAP_POINTERS(_glfw.monitorCallback, cbfun);
|
_GLFW_SWAP_POINTERS(_glfw.callbacks.monitor, cbfun);
|
||||||
return cbfun;
|
return cbfun;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user