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

Author Topic: sf::Font bug (SFML 2.0)  (Read 1427 times)

0 Members and 1 Guest are viewing this topic.

Platyna

  • Newbie
  • *
  • Posts: 7
    • View Profile
    • Email
sf::Font bug (SFML 2.0)
« on: February 17, 2013, 02:28:44 pm »
It's possible I have found a bug in sf::Font class.
If I have this code:
int main() {
    sf::RenderWindow window;
    sf::Font font;
    sf::Text text("Lalala", font);
    window.draw(text);

    return 0;
}
 
Everything is right. But if I have this:
int main() {
    sf::RenderWindow window;
    sf::Text text("Lalala", sf::Font());
    window.draw(text);

    return 0;
}
 

then valgrind says:
==3636== 92 bytes in 1 blocks are definitely lost in loss record 42 of 56
==3636==    at 0x4026C33: operator new(unsigned int) (vg_replace_malloc.c:282)
==3636==    by 0x41A72F1: std::_Rb_tree<unsigned int, std::pair<unsigned int const, sf::Font::Page>, std::_Select1st<std::pair<unsigned int const, sf::Font::Page> >, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, sf::Font::Page> > >::_M_insert_(std::_Rb_tree_node_base const*, std::_Rb_tree_node_base const*, std::pair<unsigned int const, sf::Font::Page> const&) (in /usr/local/lib/libsfml-graphics.so.2.0)
==3636==    by 0x41A75B0: std::_Rb_tree<unsigned int, std::pair<unsigned int const, sf::Font::Page>, std::_Select1st<std::pair<unsigned int const, sf::Font::Page> >, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, sf::Font::Page> > >::_M_insert_unique(std::pair<unsigned int const, sf::Font::Page> const&) (in /usr/local/lib/libsfml-graphics.so.2.0)
==3636==    by 0x41A76EA: std::_Rb_tree<unsigned int, std::pair<unsigned int const, sf::Font::Page>, std::_Select1st<std::pair<unsigned int const, sf::Font::Page> >, std::less<unsigned int>, std::allocator<std::pair<unsigned int const, sf::Font::Page> > >::_M_insert_unique_(std::_Rb_tree_const_iterator<std::pair<unsigned int const, sf::Font::Page> >, std::pair<unsigned int const, sf::Font::Page> const&) (in /usr/local/lib/libsfml-graphics.so.2.0)
==3636==    by 0x41A5B0E: sf::Font::getTexture(unsigned int) const (in /usr/local/lib/libsfml-graphics.so.2.0)
==3636==    by 0x41C65F1: sf::Text::draw(sf::RenderTarget&, sf::RenderStates) const (in /usr/local/lib/libsfml-graphics.so.2.0)
==3636==    by 0x41BF23B: sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates const&) (in /usr/local/lib/libsfml-graphics.so.2.0)
 

I use SFML 2.0 and I updated it two days ago from github repo.

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: sf::Font bug (SFML 2.0)
« Reply #1 on: February 17, 2013, 02:44:45 pm »
The sf::Text instance use the original font object that you provide, not a copy. So if you pass a temporary sf::Font, it crashes at draw time since the font doesn't exist anymore.
Laurent Gomila - SFML developer

 

anything