Small mistake. Didn't maintain the texture pointer in the sprite so it could go out of scope and crash with use after free.
This commit is contained in:
parent
516f20124f
commit
e88179b788
3 changed files with 8 additions and 3 deletions
|
|
@ -59,7 +59,8 @@ namespace guecs {
|
|||
if(new_name != name) {
|
||||
name = new_name;
|
||||
auto sprite_texture = BACKEND->get_sprite(name);
|
||||
sprite->setTexture(*sprite_texture.texture);
|
||||
texture = sprite_texture.texture;
|
||||
sprite->setTexture(*texture);
|
||||
sprite->setTextureRect({{0,0},sprite_texture.frame_size});
|
||||
}
|
||||
}
|
||||
|
|
@ -71,7 +72,8 @@ namespace guecs {
|
|||
auto bounds = sprite_texture.frame_size;
|
||||
|
||||
sf::IntRect rect{{0,0}, bounds};
|
||||
sprite = make_shared<sf::Sprite>(*sprite_texture.texture, rect);
|
||||
texture = sprite_texture.texture;
|
||||
sprite = make_shared<sf::Sprite>(*texture, rect);
|
||||
|
||||
if(stretch) {
|
||||
sprite->setScale({
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue