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.
diff --git a/examples/heightmap.c b/examples/heightmap.c
index 5139a49..94e2bb9 100644
--- a/examples/heightmap.c
+++ b/examples/heightmap.c
@@ -595,6 +595,8 @@
free(vertex_shader_src);
free(fragment_shader_src);
+
+ glfwTerminate();
exit(EXIT_FAILURE);
}
@@ -608,6 +610,8 @@
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 @@
{
fprintf(stderr, "ERROR: during creation of the shader program\n");
usage();
+
+ glfwTerminate();
exit(EXIT_FAILURE);
}
@@ -683,6 +689,7 @@
}
}
+ glfwTerminate();
exit(EXIT_SUCCESS);
}