SFML community forums
Help => Graphics => Topic started by: Fox3 on June 13, 2010, 01:33:28 pm
-
I have a problem with my code, it suddenly crashes when I SetText :(
textbutton okbutton(24, 24, 64, 32);
okbutton.settext("OK", resmgr.fonts["tuffy"]);
struct textbutton : button
{
sf::String text;
void settext(std::string newtext, sf::Font newfont);
void drawtext(sf::RenderWindow *app);
textbutton() : button::button(){};
textbutton(int nx, int ny, int nw, int nh) : button::button(nx, ny, nw, nh){};
};
void textbutton::settext(std::string newtext, sf::Font newfont)
{
text.SetFont(newfont);
text.SetSize(12);
--->text.SetText(newtext);
}
-
Some facts:
Its a SIGTRAP from ntdll :(
text is shown as incomplete type.
-
You must pass your sf::Font by reference, otherwise it is copied locally to the function, and your string uses this local copy which is detroyed after the function ends.
-
OMG!!! IT WORKS NOW!!! :D
Many thanks to Laurent ^^