Postpone initialization of owner-drawn menu metrics.

Doing it during globals initialization time didn't work and could even result
in a crash due to dereferencing a NULL wxTheApp pointer.

Closes #11806.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@63712 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin 2010-03-19 09:57:15 +00:00
parent 28756ab9c5
commit 60a7194e43

View File

@ -241,6 +241,15 @@ public:
static const MenuDrawData* Get()
{
// notice that s_menuData can't be created as a global variable because
// it needs a window to initialize and no windows exist at the time of
// globals initialization yet
if ( !ms_instance )
{
static MenuDrawData s_menuData;
ms_instance = &s_menuData;
}
#if wxUSE_UXTHEME
bool theme = MenuLayout() == FullTheme;
if ( ms_instance->Theme != theme )
@ -251,7 +260,6 @@ public:
MenuDrawData()
{
ms_instance = this;
Init();
}
@ -299,8 +307,6 @@ private:
MenuDrawData* MenuDrawData::ms_instance = NULL;
MenuDrawData s_menuData;
void MenuDrawData::Init()
{
#if wxUSE_UXTHEME