Hello,
Since 2 weeks i have been trying to debbug a simply class that i made. Is a class that i will use to manage the objects of my game. I have reduced it to the minimal components, it has sprite, image and it uses heritage to get a pointer to the RenderWindow. I have tracked the bug, and the segfault is in the second App->Draw section, into the Draw() method of entity. Im using sfml 1.6
Here is the header:
#ifndef _entity
#define _entity
class Entity : public SharedData{
private:
sf::Sprite Mine;
sf::Image imag;
int x,y;
public:
Entity(const int&, const int&, const int&);
void Draw();
void SetType(const int&);
void SetPosition(const int&,const int&);
};
#endif
Here is the source:
Entity::Entity(const int& xx,const int& yy, const int& a){
if(!imag.LoadFromFile("Entitys.tga")) std::cout << "Error " << std::endl;
imag.SetSmooth(false);
Mine.SetImage(imag);
Mine.SetPosition(0,0);
Mine.SetCenter(0,0);
App->Draw(Mine);
App->Display();
}
void Entity::SetPosition(const int& xx ,const int& yy){
}
void Entity::SetType(const int& a){
}
void Entity::Draw(){
Mine.SetImage(imag);
App->Draw(Mine);
std::cout << "Im alive" << std::endl;
}
The gdb said me this:
Program received signal SIGSEGV, Segmentation fault.
0x0804d024 in std::_Rb_tree<sf::ResourcePtr<sf::Image>*, sf::ResourcePtr<sf::Image>*, std::_Identity<sf::ResourcePtr<sf::Image>*>, std::less<sf::ResourcePtr<sf::Image>*>, std::allocator<sf::ResourcePtr<sf::Image>*> >::_M_begin (this=0x1) at /usr/include/c++/4.4/bits/stl_tree.h:482
482 { return static_cast<_Link_type>(this->_M_impl._M_header._M_parent); }
Thanks