Upon closing a program, SFML causes an access violation in certain situations with sf::Texture. I'm using 64-bit Windows 7 and Visual Studio 2010. In VS, at program close, I get
"First-chance exception at 0x773532d0 in Test.exe: 0xC0000005: Access violation reading location 0x000008bcd188e2f8."
The thread 'Win64 Thread' (0x48c) has exited with code 0 (0x0).
The program '[4896] Test.exe: Native' has exited with code 0 (0x0).
The following code is a pretty good demonstration:
#define SFML_DYNAMIC
#include <SFML/Graphics.hpp>
#define ACCESS_VIOLATION
int main()
{
#ifdef ACCESS_VIOLATION
sf::RenderWindow App(sf::VideoMode(800, 600, 32), "Title");
#endif
sf::Texture Texture1;
if (!Texture1.LoadFromFile("sprite1.png"))
return EXIT_FAILURE;
sf::Texture Texture2;
if (!Texture2.LoadFromFile("sprite2.png"))
return EXIT_FAILURE;
#ifdef ACCESS_VIOLATION
App.Close();
#endif
return EXIT_SUCCESS;
}
The following code has the same behavior, which is confusing:
#define SFML_DYNAMIC
#include <SFML/Graphics.hpp>
#define ACCESS_VIOLATION
int main()
{
sf::RenderWindow App(sf::VideoMode(800, 600, 32), "Title");
sf::Texture Texture1;
if (!Texture1.LoadFromFile("sprite1.png"))
return EXIT_FAILURE;
sf::Texture Texture2;
#ifdef ACCESS_VIOLATION
if (!Texture2.LoadFromFile("sprite2.png"))
return EXIT_FAILURE;
#endif
App.Close();
return EXIT_SUCCESS;
}
Commenting out the #define ACCESS_VIOLATION results in no error.