SFML community forums
Help => Graphics => Topic started by: deviouskoopa on June 28, 2013, 11:49:55 pm
-
I'm having a strange issue with my SFML project. When I create a pointer for a sf::Text then draw it to the window in the same function scope, it works. However, when I create the sf::Text and store in a class in one function then draw from that member variable, it breaks in Debug mode with the message: "Unhandled exception at 0x77cc15de in TestSfmlApp.exe: 0xC0000005: Access violation reading location 0xccccccd0." Below is my project info and a condensed test program that fails for me.
System Info:
SFML 2.0 for "Visual C++ 10 (2010) - 32 bits"
Windows 7 64-bit, VS 2010
VS 2010 settings:
dynamic libs according to http://sfml-dev.org/tutorials/2.0/start-vc.php
Test program that crashes at line 42:
http://pastebin.com/L2XQeCdU
(but works when I remove lines 29-31 and 65)
Not sure if I copied the right stuff, but here's the call stack:
ntdll.dll!77cc15de()
[Frames below may be incorrect and/or missing, no symbols loaded for ntdll.dll]
ntdll.dll!77cc15de()
ntdll.dll!77cb014e()
sfml-graphics-d-2.dll!5b80ad77()
sfml-graphics-d-2.dll!5b80cd56()
sfml-graphics-d-2.dll!5b80abae()
sfml-graphics-d-2.dll!5b80869a()
sfml-graphics-d-2.dll!5b805b2d()
sfml-graphics-d-2.dll!5b852986()
sfml-graphics-d-2.dll!5b8346e3()
> TestSfmlApp.exe!Game::Loop() Line 42 + 0x1a bytes C++
TestSfmlApp.exe!main(int argc, char * * argv) Line 66 C++
TestSfmlApp.exe!__tmainCRTStartup() Line 555 + 0x19 bytes C
TestSfmlApp.exe!mainCRTStartup() Line 371 C
kernel32.dll!770333aa()
ntdll.dll!77cd9ef2()
ntdll.dll!77cd9ec5()
I've been stuck on this for 3-4 days now, but haven't found anything on forums or tutorials. Everything I read suggests the VS 2010 settings are wrong for linking the libraries, but I followed that link above exactly. Any suggestions?
-
sf::Font at line 19 is local to start so it dies after quitting that function's scope.
-
Wow that was definitely it, thank you! Can't believe it was that easy...
-
Just curious:
Is there a good reason that the sf::Text class stores a reference to the sf::Font instead of a sf::Font itself? Then you could copy from the reference in the setFont() function and wouldn't have to manage the lifecycle of the sf::Font separately... but maybe that's the intended use.
-
Font instances are very heavy to copy and store.