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

Author Topic: sf::Font::getTexture Segmentation fault  (Read 3640 times)

0 Members and 1 Guest are viewing this topic.

aleksav013

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
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.

aleksav013

  • Newbie
  • *
  • Posts: 2
    • View Profile
    • Email
Re: sf::Font::getTexture Segmentation fault
« Reply #1 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.

 

anything