I have a class TextureManager class which has a std::list of pointers to Ressource
struct Ressource
{
sf::Image img;
std::string path;
};
I get this error:
std::_List_alloc<std::_List_base_types<ASC::TextureManager::Ressource *,std::allocator<ASC::TextureManager::Ressource *> > >::_Myhead(...) returned 0x4.
methods:
const sf::Image& TextureManager::load(std::string dPath)
{
Ressource * res = new Ressource;
res->img.loadFromFile(dPath);
res->path = dPath;
data.push_front(res);
return res->img;
}
const sf::Image& TextureManager::get(std::string dPath)
{
return load(dPath);
}
the TextureManager is a member of RessourceHandler
which has the following getter method:
const sf::Image& RessourceHandler::getTexture(std::string path)
{
return tManager.get(path);
}
That method gets called by different objects which have a pointer to an instance of the RessourceHandler. Thats when the exception gets thrown.
it works all fine if i delete the line where i push_back the Ressource into the list at TextureManager::load()
it also works fine when i call TextureManager::load() from the RessourceHandler's Constructor. Even without deleting the push_back.
I can't figure out why that happens. has anyone an idea?
Aucun commentaire:
Enregistrer un commentaire