mirror of
https://github.com/SFML/SFML.git
synced 2024-11-25 04:41:05 +08:00
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:
parent
3621cb10f7
commit
cdc1346612
@ -158,14 +158,28 @@ const Image& Font::GetImage() const
|
|||||||
////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////
|
||||||
const Font& Font::GetDefaultFont()
|
const Font& Font::GetDefaultFont()
|
||||||
{
|
{
|
||||||
static Font DefaultFont;
|
#if defined(SFML_SYSTEM_WINDOWS) && defined(SFML_DYNAMIC)
|
||||||
static bool DefaultFontLoaded = false;
|
|
||||||
|
// 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;
|
||||||
|
|
||||||
|
#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[] =
|
static const char DefaultFontData[] =
|
||||||
{
|
{
|
||||||
#include <SFML/Graphics/Arial.hpp>
|
#include <SFML/Graphics/Arial.hpp>
|
||||||
};
|
};
|
||||||
|
|
||||||
// Load the default font on first call
|
// Load the default font on first call
|
||||||
|
static bool DefaultFontLoaded = false;
|
||||||
if (!DefaultFontLoaded)
|
if (!DefaultFontLoaded)
|
||||||
{
|
{
|
||||||
DefaultFont.LoadFromMemory(DefaultFontData, sizeof(DefaultFontData), 30);
|
DefaultFont.LoadFromMemory(DefaultFontData, sizeof(DefaultFontData), 30);
|
||||||
|
Loading…
Reference in New Issue
Block a user