Sign in to follow this  
derefed

Weird SDL_TTF problem...

Recommended Posts

Okay, so I'm doing some tests of the GUI I'm developing for my game, and I run into an annoying little problem. Seems like every once in a while, upon exiting the program, I get a "Send error report to Microsoft" error window stating that the error occurred in "sdl_ttf.dll". I eventually track it down and figure out what exactly is causing the problem. You see, I have some text field controls, and apparently whenever I have to render a captial 'M' for one, this little error occurs. I experimented some more and just made the TTF_RenderText_Blended() call output just a letter "M" and not what was actually stored in the text field, and it still happens, which means that it's not keypresses or my handling code, it's the Render call. I also tried Solid(), and it still does the same thing. Then I tried taking out all the text controls but one, and this does *not* make an error upon exiting, which would lead me to conclude that some pointer is getting deleted in one of them before the other is done with it. The only such pointer I have is a TTF_Font*, which each text control has. Upon instantiation, each one opens a new Courier New font, and in the destructor, the font is closed and NULL'ed. The behavior of my program upon exit would lead me to believe that only one TTF_Font* can be opened per .ttf file, but I can't find anything in the SDL_TTF docs that supports that theory or issues a warning about that. Also, if this were the case, would it not popup an error after *any* use of multiple text controls in the program, and not just when a capital 'M' is rendered?

Share this post


Link to post
Share on other sites
I have just tested both Blended and Solid rendering with SDL_ttf with 3 fonts from the same TTF file, 2 with same sizes and 1 with different one. Rendered text strings with and without 'M' and simply the "M" string and didn't get any leaks. Check if that happens with another TTF file (/shrug on how the TTF file could be blamed for that) and if you have the last SDL_ttf version (2.0.8).

Share this post


Link to post
Share on other sites
Hmm... must be something weird with how I'm handling pointers. I still don't understand, though, how the error could only occur when it has to render an 'M'. I've also verified that I'm using SDL_TTF 2.0.8. Well, guess I'll have to go through line-by-line and see what I can do... if anyone has any more ideas, I'm open to 'em.

Share this post


Link to post
Share on other sites
Tried it out on verdana.ttf instead, and the error doesn't occur. Could it be cour.ttf that's causing the problem?

Share this post


Link to post
Share on other sites
Okay, so in an attempt to get some debugging help, I moved my project from compiling with the g++ command line to VC2005. After grappling with a few setup issues, I finally got my code to compile, and guess what? No weird "M" problem. So what gives? Does anyone have any idea why it behaved that way? Am I safe, and it's just a g++ problem, or will this error rear its head again in some other form?

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this