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 - aleksav013

Pages: [1]
1
Graphics / Re: sf::Font::getTexture Segmentation fault
« on: May 30, 2021, 11:01:48 pm »
The problem was with the fact that default copy constructor was used for defining object of type Game in State class constructor, which was just temporary, and references to Font and Textures were deleted after exiting State class constructor.

2
Graphics / sf::Font::getTexture Segmentation fault
« on: May 30, 2021, 06:40:44 pm »
Why does first code work, but the second one gives segmentation fault.
I am providing minimal cpp files as attachments.

gdb:
Code: [Select]
Thread 1 "sfml.out" received signal SIGSEGV, Segmentation fault.
0x00007ffff7f5dbec in sf::Font::getTexture(unsigned int) const () from /usr/lib/libsfml-graphics.so.2.5
(gdb) ba
#0  0x00007ffff7f5dbec in sf::Font::getTexture(unsigned int) const () from /usr/lib/libsfml-graphics.so.2.5
#1  0x00007ffff7f99a4d in sf::Text::ensureGeometryUpdate() const () from /usr/lib/libsfml-graphics.so.2.5
#2  0x00007ffff7f9a34c in sf::Text::draw(sf::RenderTarget&, sf::RenderStates) const () from /usr/lib/libsfml-graphics.so.2.5
#3  0x00007ffff7f8bed9 in sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates const&) () from /usr/lib/libsfml-graphics.so.2.5
#4  0x00005555555564e6 in Game::draw (this=0x7fffffffe3d0) at notworking.cpp:37
#5  0x0000555555556540 in Game::loop (this=0x7fffffffe3d0) at notworking.cpp:42
#6  State::loop (this=this@entry=0x7fffffffe1c0) at notworking.cpp:60
#7  0x0000555555556340 in main () at notworking.cpp:65

Thanks in advance and sorry for bad looking post, it is my first time on this forum.

Pages: [1]