When I close my app in a certain state, this code runs:
void GameEndState::exit(){
delete m_pGameObjectManager;
delete m_pSceneManager;
}
After running m_pGameObjectManager’s destructor, which is:
GameObjectManager::~GameObjectManager(){
std::for_each(gameObjects.begin(),gameObjects.end(),GameObjectDeallocator());
}
//gameObjects is a std::map<sf::String,VisibleGameObject*>
///////////////
struct GameObjectDeallocator{
void operator()(const std::pair<sf::String,VisibleGameObject*>&p) const{
delete p.second;
}
};
it will produce the title’s error. I haven’t found any results of this error from googling. I am using SFML 2.0.
VisibleGameObject’s destructor:
VisibleGameObject::~VisibleGameObject(){
m_pSceneManager->removeSprite(name);
}
void SceneManager::removeSprite(sf::String spritename){
std::cout << "removed " << std::string(spritename) << std::endl;
sprites.erase(sprites.find(spritename));
}
//sprites is a std::map<sf::String,sf::Sprite>
Thanks in advance
The error is in this line, evidently
sprites.findis not finding the name you’ve given it and is returningsprites.end().