mirror of
https://github.com/glfw/glfw.git
synced 2024-11-26 03:52:01 +00:00
Removed registering glfwTerminate with atexit.
Functions registered with atexit are called from the thread calling exit. glfwTerminate should only be called from the main thread. Mistakes should be explicit.
This commit is contained in:
parent
5df4df6ca4
commit
d68acb78bf
@ -595,6 +595,8 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
free(vertex_shader_src);
|
free(vertex_shader_src);
|
||||||
free(fragment_shader_src);
|
free(fragment_shader_src);
|
||||||
|
|
||||||
|
glfwTerminate();
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -608,6 +610,8 @@ int main(int argc, char** argv)
|
|||||||
fprintf(stderr, "ERROR: unable to resolve OpenGL function pointers\n");
|
fprintf(stderr, "ERROR: unable to resolve OpenGL function pointers\n");
|
||||||
free(vertex_shader_src);
|
free(vertex_shader_src);
|
||||||
free(fragment_shader_src);
|
free(fragment_shader_src);
|
||||||
|
|
||||||
|
glfwTerminate();
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
/* Prepare opengl resources for rendering */
|
/* Prepare opengl resources for rendering */
|
||||||
@ -619,6 +623,8 @@ int main(int argc, char** argv)
|
|||||||
{
|
{
|
||||||
fprintf(stderr, "ERROR: during creation of the shader program\n");
|
fprintf(stderr, "ERROR: during creation of the shader program\n");
|
||||||
usage();
|
usage();
|
||||||
|
|
||||||
|
glfwTerminate();
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -683,6 +689,7 @@ int main(int argc, char** argv)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glfwTerminate();
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -463,6 +463,8 @@ int main(void)
|
|||||||
if (!window)
|
if (!window)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to open GLFW window\n");
|
fprintf(stderr, "Failed to open GLFW window\n");
|
||||||
|
|
||||||
|
glfwTerminate();
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -27,6 +27,8 @@ int main(void)
|
|||||||
if (!window)
|
if (!window)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to open GLFW window\n");
|
fprintf(stderr, "Failed to open GLFW window\n");
|
||||||
|
|
||||||
|
glfwTerminate();
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,6 +318,7 @@ version of GLFW.</p>
|
|||||||
<li>Removed the entire threading API</li>
|
<li>Removed the entire threading API</li>
|
||||||
<li>Removed the entire image loading API</li>
|
<li>Removed the entire image loading API</li>
|
||||||
<li>Removed deprecated Carbon port</li>
|
<li>Removed deprecated Carbon port</li>
|
||||||
|
<li>Removed registering <code>glfwTerminate</code> with <code>atexit</code></li>
|
||||||
<li>Removed <code>glfwSleep</code> function</li>
|
<li>Removed <code>glfwSleep</code> function</li>
|
||||||
<li>Removed <code>glfwGetNumberOfProcessors</code> function</li>
|
<li>Removed <code>glfwGetNumberOfProcessors</code> function</li>
|
||||||
<li>Removed <code>glfwGetGLVersion</code> function</li>
|
<li>Removed <code>glfwGetGLVersion</code> function</li>
|
||||||
|
@ -127,8 +127,6 @@ GLFWAPI int glfwInit(void)
|
|||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
atexit(glfwTerminate);
|
|
||||||
|
|
||||||
_glfwInitialized = GL_TRUE;
|
_glfwInitialized = GL_TRUE;
|
||||||
|
|
||||||
// Not all window hints have zero as their default value
|
// Not all window hints have zero as their default value
|
||||||
|
@ -106,7 +106,10 @@ static void list_extensions(int api, int major, int minor)
|
|||||||
{
|
{
|
||||||
PFNGLGETSTRINGIPROC glGetStringi = (PFNGLGETSTRINGIPROC) glfwGetProcAddress("glGetStringi");
|
PFNGLGETSTRINGIPROC glGetStringi = (PFNGLGETSTRINGIPROC) glfwGetProcAddress("glGetStringi");
|
||||||
if (!glGetStringi)
|
if (!glGetStringi)
|
||||||
|
{
|
||||||
|
glfwTerminate();
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
glGetIntegerv(GL_NUM_EXTENSIONS, &count);
|
glGetIntegerv(GL_NUM_EXTENSIONS, &count);
|
||||||
|
|
||||||
@ -267,7 +270,10 @@ int main(int argc, char** argv)
|
|||||||
|
|
||||||
window = glfwCreateWindow(0, 0, GLFW_WINDOWED, "Version", NULL);
|
window = glfwCreateWindow(0, 0, GLFW_WINDOWED, "Version", NULL);
|
||||||
if (!window)
|
if (!window)
|
||||||
|
{
|
||||||
|
glfwTerminate();
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
glfwMakeContextCurrent(window);
|
glfwMakeContextCurrent(window);
|
||||||
|
|
||||||
|
@ -157,6 +157,8 @@ static void test_modes(void)
|
|||||||
if (!window_handle)
|
if (!window_handle)
|
||||||
{
|
{
|
||||||
printf("User terminated program\n");
|
printf("User terminated program\n");
|
||||||
|
|
||||||
|
glfwTerminate();
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -224,6 +226,7 @@ int main(int argc, char** argv)
|
|||||||
else if (mode == TEST_MODE)
|
else if (mode == TEST_MODE)
|
||||||
test_modes();
|
test_modes();
|
||||||
|
|
||||||
|
glfwTerminate();
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -120,6 +120,8 @@ int main(void)
|
|||||||
if (!open_window())
|
if (!open_window())
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to open GLFW window: %s\n", glfwErrorString(glfwGetError()));
|
fprintf(stderr, "Failed to open GLFW window: %s\n", glfwErrorString(glfwGetError()));
|
||||||
|
|
||||||
|
glfwTerminate();
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -138,6 +140,8 @@ int main(void)
|
|||||||
if (!open_window())
|
if (!open_window())
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to open GLFW window: %s\n", glfwErrorString(glfwGetError()));
|
fprintf(stderr, "Failed to open GLFW window: %s\n", glfwErrorString(glfwGetError()));
|
||||||
|
|
||||||
|
glfwTerminate();
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,7 +132,10 @@ int main(int argc, char** argv)
|
|||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
if (!open_window(640, 480, (count & 1) ? GLFW_FULLSCREEN : GLFW_WINDOWED))
|
if (!open_window(640, 480, (count & 1) ? GLFW_FULLSCREEN : GLFW_WINDOWED))
|
||||||
|
{
|
||||||
|
glfwTerminate();
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
}
|
||||||
|
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glOrtho(-1.f, 1.f, -1.f, 1.f, 1.f, -1.f);
|
glOrtho(-1.f, 1.f, -1.f, 1.f, 1.f, -1.f);
|
||||||
@ -156,6 +159,8 @@ int main(int argc, char** argv)
|
|||||||
{
|
{
|
||||||
close_window();
|
close_window();
|
||||||
printf("User closed window\n");
|
printf("User closed window\n");
|
||||||
|
|
||||||
|
glfwTerminate();
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -137,6 +137,8 @@ int main(int argc, char** argv)
|
|||||||
if (!windows[0])
|
if (!windows[0])
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to open first GLFW window: %s\n", glfwErrorString(glfwGetError()));
|
fprintf(stderr, "Failed to open first GLFW window: %s\n", glfwErrorString(glfwGetError()));
|
||||||
|
|
||||||
|
glfwTerminate();
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -149,6 +151,8 @@ int main(int argc, char** argv)
|
|||||||
if (!windows[1])
|
if (!windows[1])
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to open second GLFW window: %s\n", glfwErrorString(glfwGetError()));
|
fprintf(stderr, "Failed to open second GLFW window: %s\n", glfwErrorString(glfwGetError()));
|
||||||
|
|
||||||
|
glfwTerminate();
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -73,9 +73,9 @@ int main(void)
|
|||||||
window = glfwCreateWindow(0, 0, GLFW_WINDOWED, "", NULL);
|
window = glfwCreateWindow(0, 0, GLFW_WINDOWED, "", NULL);
|
||||||
if (!window)
|
if (!window)
|
||||||
{
|
{
|
||||||
glfwTerminate();
|
|
||||||
|
|
||||||
fprintf(stderr, "Failed to open GLFW window: %s\n", glfwErrorString(glfwGetError()));
|
fprintf(stderr, "Failed to open GLFW window: %s\n", glfwErrorString(glfwGetError()));
|
||||||
|
|
||||||
|
glfwTerminate();
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -51,6 +51,8 @@ int main(void)
|
|||||||
if (!window)
|
if (!window)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to open GLFW window: %s\n", glfwErrorString(glfwGetError()));
|
fprintf(stderr, "Failed to open GLFW window: %s\n", glfwErrorString(glfwGetError()));
|
||||||
|
|
||||||
|
glfwTerminate();
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -66,6 +68,7 @@ int main(void)
|
|||||||
glfwWaitEvents();
|
glfwWaitEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glfwTerminate();
|
||||||
exit(EXIT_SUCCESS);
|
exit(EXIT_SUCCESS);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -60,6 +60,7 @@ int main(void)
|
|||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to open GLFW window: %s\n",
|
fprintf(stderr, "Failed to open GLFW window: %s\n",
|
||||||
glfwErrorString(glfwGetError()));
|
glfwErrorString(glfwGetError()));
|
||||||
|
|
||||||
glfwTerminate();
|
glfwTerminate();
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user