FS#152 - Fix crash with the default font at global exit on Windows

git-svn-id: https://sfml.svn.sourceforge.net/svnroot/sfml/trunk@1401 4e206d99-4929-0410-ac5d-dfc041789085
This commit is contained in:
LaurentGom 2010-02-11 08:31:52 +00:00
parent 3621cb10f7
commit cdc1346612

View File

@ -158,14 +158,28 @@ const Image& Font::GetImage() const
////////////////////////////////////////////////////////////
const Font& Font::GetDefaultFont()
{
#if defined(SFML_SYSTEM_WINDOWS) && defined(SFML_DYNAMIC)
// On Windows dynamic build, the default font causes a crash at global exit.
// This is a temporary workaround that turns the crash into a memory leak.
// Note that this bug doesn't exist anymore in SFML 2.
static Font* DefaultFontPtr = new Font;
Font& DefaultFont = *DefaultFontPtr;
#else
static Font DefaultFont;
static bool DefaultFontLoaded = false;
#endif
// Get the raw data of the Arial font file into an array, so that we can load it into the font
static const char DefaultFontData[] =
{
#include <SFML/Graphics/Arial.hpp>
};
// Load the default font on first call
static bool DefaultFontLoaded = false;
if (!DefaultFontLoaded)
{
DefaultFont.LoadFromMemory(DefaultFontData, sizeof(DefaultFontData), 30);