Make sure that you use SFML debug libraries in debug mode (and release ones in release mode).
Yep made sure of that
I guess my first hypothesis was wrong, but I'm having a hard time finding what's causing the problem.
A summary of what I know so far:
I have a number of objects, each has a sprite using the same image. If I manually delete either an object or the image, there are no problems. If I do both, however, I get heap issues.
I tried to replicate this with a simple example, but it doesn't exhibit the problem.
#include <SFML/Graphics.hpp>
class testclass
{
public:
testclass(sf::Image& i)
{
sprite.SetImage(i);
}
sf::Sprite sprite;
};
int main()
{
sf::Image* Image;
Image = new sf::Image;
Image->LoadFromFile("test.png");
testclass* Sprite = new testclass(*Image);
testclass* Sprite2 = new testclass(*Image);
delete Sprite;
delete Sprite2;
delete Image;
return 0;
}
The only thing I can think it must be is that somehow the destructor for my objects is corrupting the heap so causing sf::~Resource to crash. I've searched in my code and fiddled for hours on end and I'm coming up with nothing.
What's the best way to find out where a heap corruption might be caused?