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:
Camilla Berglund 2012-10-22 03:20:16 +02:00
parent 5df4df6ca4
commit d68acb78bf
13 changed files with 40 additions and 4 deletions

View File

@ -595,6 +595,8 @@ int main(int argc, char** argv)
free(vertex_shader_src);
free(fragment_shader_src);
glfwTerminate();
exit(EXIT_FAILURE);
}
@ -608,6 +610,8 @@ int main(int argc, char** argv)
fprintf(stderr, "ERROR: unable to resolve OpenGL function pointers\n");
free(vertex_shader_src);
free(fragment_shader_src);
glfwTerminate();
exit(EXIT_FAILURE);
}
/* 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");
usage();
glfwTerminate();
exit(EXIT_FAILURE);
}
@ -683,6 +689,7 @@ int main(int argc, char** argv)
}
}
glfwTerminate();
exit(EXIT_SUCCESS);
}

View File

@ -463,6 +463,8 @@ int main(void)
if (!window)
{
fprintf(stderr, "Failed to open GLFW window\n");
glfwTerminate();
exit(EXIT_FAILURE);
}

View File

@ -27,6 +27,8 @@ int main(void)
if (!window)
{
fprintf(stderr, "Failed to open GLFW window\n");
glfwTerminate();
exit(EXIT_FAILURE);
}

View File

@ -318,6 +318,7 @@ version of GLFW.</p>
<li>Removed the entire threading API</li>
<li>Removed the entire image loading API</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>glfwGetNumberOfProcessors</code> function</li>
<li>Removed <code>glfwGetGLVersion</code> function</li>

View File

@ -127,8 +127,6 @@ GLFWAPI int glfwInit(void)
return GL_FALSE;
}
atexit(glfwTerminate);
_glfwInitialized = GL_TRUE;
// Not all window hints have zero as their default value

View File

@ -106,7 +106,10 @@ static void list_extensions(int api, int major, int minor)
{
PFNGLGETSTRINGIPROC glGetStringi = (PFNGLGETSTRINGIPROC) glfwGetProcAddress("glGetStringi");
if (!glGetStringi)
{
glfwTerminate();
exit(EXIT_FAILURE);
}
glGetIntegerv(GL_NUM_EXTENSIONS, &count);
@ -267,7 +270,10 @@ int main(int argc, char** argv)
window = glfwCreateWindow(0, 0, GLFW_WINDOWED, "Version", NULL);
if (!window)
{
glfwTerminate();
exit(EXIT_FAILURE);
}
glfwMakeContextCurrent(window);

View File

@ -157,6 +157,8 @@ static void test_modes(void)
if (!window_handle)
{
printf("User terminated program\n");
glfwTerminate();
exit(EXIT_SUCCESS);
}
}
@ -224,6 +226,7 @@ int main(int argc, char** argv)
else if (mode == TEST_MODE)
test_modes();
glfwTerminate();
exit(EXIT_SUCCESS);
}

View File

@ -120,6 +120,8 @@ int main(void)
if (!open_window())
{
fprintf(stderr, "Failed to open GLFW window: %s\n", glfwErrorString(glfwGetError()));
glfwTerminate();
exit(EXIT_FAILURE);
}
@ -138,6 +140,8 @@ int main(void)
if (!open_window())
{
fprintf(stderr, "Failed to open GLFW window: %s\n", glfwErrorString(glfwGetError()));
glfwTerminate();
exit(EXIT_FAILURE);
}

View File

@ -132,7 +132,10 @@ int main(int argc, char** argv)
for (;;)
{
if (!open_window(640, 480, (count & 1) ? GLFW_FULLSCREEN : GLFW_WINDOWED))
{
glfwTerminate();
exit(EXIT_FAILURE);
}
glMatrixMode(GL_PROJECTION);
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();
printf("User closed window\n");
glfwTerminate();
exit(EXIT_SUCCESS);
}
}

View File

@ -137,6 +137,8 @@ int main(int argc, char** argv)
if (!windows[0])
{
fprintf(stderr, "Failed to open first GLFW window: %s\n", glfwErrorString(glfwGetError()));
glfwTerminate();
exit(EXIT_FAILURE);
}
@ -149,6 +151,8 @@ int main(int argc, char** argv)
if (!windows[1])
{
fprintf(stderr, "Failed to open second GLFW window: %s\n", glfwErrorString(glfwGetError()));
glfwTerminate();
exit(EXIT_FAILURE);
}

View File

@ -73,9 +73,9 @@ int main(void)
window = glfwCreateWindow(0, 0, GLFW_WINDOWED, "", NULL);
if (!window)
{
glfwTerminate();
fprintf(stderr, "Failed to open GLFW window: %s\n", glfwErrorString(glfwGetError()));
glfwTerminate();
exit(EXIT_FAILURE);
}

View File

@ -51,6 +51,8 @@ int main(void)
if (!window)
{
fprintf(stderr, "Failed to open GLFW window: %s\n", glfwErrorString(glfwGetError()));
glfwTerminate();
exit(EXIT_FAILURE);
}
@ -66,6 +68,7 @@ int main(void)
glfwWaitEvents();
}
glfwTerminate();
exit(EXIT_SUCCESS);
}

View File

@ -60,6 +60,7 @@ int main(void)
{
fprintf(stderr, "Failed to open GLFW window: %s\n",
glfwErrorString(glfwGetError()));
glfwTerminate();
exit(EXIT_FAILURE);
}