TTF_CloseFont() Segmentation Fault

Started by
2 comments, last by rip-off 7 years, 7 months ago
Here's the code: https://github.com/Nyapp/Cell/blob/master/src/engine_classes.h
The TTF_CloseFont() that I'm having trouble with is in Text::~Text(). When I close the game, I get a segfault. What am I doing wrong?
Advertisement

You are probably deleting/closing the font twice. Segmentation faults generally occur upon trying to dereference invalid pointers, or similar.

Set a breakpoint in the destructor and verify that your font is a valid address.

If you have TTF_CloseFont() somewhere else, put breakpoints there as well.

Hello to all my stalkers.

Check you aren't deleting text that has already been deleted too.

Interested in Fractals? Check out my App, Fractal Scout, free on the Google Play store.

Classes should obey the Rule of Three. Anytime you add a destructor to a class, think about whether to handle copying instances of that class, or else make the class as noncopyable.

This topic is closed to new replies.

Advertisement