I have no idea why, but if a Texture has image data loaded when its destructor is called, it causes a segfault. I'm using CodeBlocks with MinGW, and my SFML build was just updated about a month ago. No segfault occurs if the image is not loaded, however.
Some code that reproduces the crash:
#include <SFML.hpp>
using namespace sf;
int main()
{
RenderWindow window(VideoMode(640, 480, 32), "Texture Crasher");
Texture tx1, tx2;
tx1.loadFromFile("image.png");
tx2.loadFromFile("image.png");
while(window.isOpen())
{
Event event;
while (window.pollEvent(event))
{
if (event.type==Event::Closed)
window.close();
}
window.clear();
window.display();
sleep(milliseconds(25));
}
return 0;
}
GDP outputs:
#0 7763E3BE ntdll!LdrWx86FormatVirtualImage() (C:\Windows\system32\ntdll.dll:??)
#1 00000000 0x00000000 in ??() (??:??)
Any idea on why this is happening or how I can fix it? Outside of a debugger, the program will rarely crash, but that doesn't mean everything is working ok.