Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - Masadow

Pages: [1]
1
Graphics / [SOLVED]sf::Sprite::SetImage() crash
« on: October 31, 2011, 10:55:23 am »
uh... how can i be so stupid :p


Merci Laurent x)

2
Graphics / [SOLVED]sf::Sprite::SetImage() crash
« on: October 30, 2011, 11:54:37 pm »
Yeah, sf::Sprite pointer was a test, forgot to change :p

I use SFML 1.6

Maybe i should give you the Item struct returned by insert().

Code: [Select]
struct Item
{
void *ptr;
std::string name;
enum Type type;
struct Item *next;
};

3
Graphics / [SOLVED]sf::Sprite::SetImage() crash
« on: October 30, 2011, 11:05:35 pm »
Hi,

I searched for hours but i can't find why this code crash

Code: [Select]
ge::Menu::Menu(std::string bg_path)
{
m_bg = new sf::Sprite;

std::cout << "receive addr " << ge::ResourceManager::getInstance()->getImage(bg_path) << std::endl;
sf::Image &test = *ge::ResourceManager::getInstance()->getImage(bg_path);
m_bg->SetImage(test);
}


Code: [Select]
sf::Image* ge::ResourceManager::getImage(std::string path)
{
Item *it;

if ((it = search(IMAGE, path)))
{
return (sf::Image*)(it->ptr);
}
sf::Image img;
if (img.LoadFromFile(path))
{
sf::Image *i = (sf::Image*)insert(&img, IMAGE, path)->ptr;
std::cout << "Create image at addr " << i << std::endl;
return i;
}
return NULL;
}


And the console output

Quote

Create image at addr 0x28fb40
receive addr 0x28fb40
cast addr 0x28fb40


The crash seems to be a Segmentation Fault on sf::Sprite::SetImage() call.
Someone can give me a tip ? Or more code is needed ?

Thanks in advance

Pages: [1]
anything