Weird SDL_TTF problem

First of all, apologies if this thread is only for SDL and not for the other
libraries.

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?

Hello !

Have you tried to modify the showfont example
that comes with SDL_ttf, in that way that it shows
the same problem as your app ?

CU

Torsten Giebl <wizard syntheticsw.com> writes:

Hello !

Have you tried to modify the showfont example
that comes with SDL_ttf, in that way that it shows
the same problem as your app ?

CU

I haven’t done that specifically, but I have tried making a separate test
program to simulate the error. It seems that making two TTF_Font*s that both
have cour.ttf as their font makes things a little screwy, and also, back in my
main program, changing to a different font other than cour.ttf makes the errors
stop.

I just recompiled the project with Visual C++ 2005 Express Edition instead of
g++, and the error does not occur. What could this possibly mean?

My expierience with this kind of errors is, that you might have some bad
memory access or uninitialized data, which not directly causes your
program to crash. Then debugging is an unthankful job. Try to reduce
your code step by step and ensure that your error still occurs with g++.
If you end up with a very small program, that still crashes you can walk
through with gdb.
I know, thats no big help…

James Brawn wrote:> I just recompiled the project with Visual C++ 2005 Express Edition instead of

g++, and the error does not occur. What could this possibly mean?


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org