Fix bug due to undefined g_wxAnyValueTypeGlobals initialization order
This fixes the changes of commit 3543ae0177
which didn't work if any of the globals using wxPreRegisterAnyToVariant() were
instantiated before g_wxAnyValueTypeGlobals itself.
Wrap the global inside a function to ensure that we initialized it before it
is used by wxPreRegisterAnyToVariant() and not after.
This commit is contained in:
parent
4ffb9d342c
commit
f8b3ecbb0e
@ -121,16 +121,27 @@ private:
|
||||
wxVector<wxAnyToVariantRegistration*> m_anyToVariantRegs;
|
||||
};
|
||||
|
||||
static wxScopedPtr<wxAnyValueTypeGlobals> g_wxAnyValueTypeGlobals;
|
||||
static wxScopedPtr<wxAnyValueTypeGlobals>& GetAnyValueTypeGlobals()
|
||||
{
|
||||
static wxScopedPtr<wxAnyValueTypeGlobals> s_wxAnyValueTypeGlobals;
|
||||
if ( !s_wxAnyValueTypeGlobals )
|
||||
{
|
||||
// Notice that it is _not_ sufficient to just initialize the static
|
||||
// object like this because it can be used after it was reset by
|
||||
// wxAnyValueTypeGlobalsManager if the library is shut down and then
|
||||
// initialized again.
|
||||
s_wxAnyValueTypeGlobals.reset(new wxAnyValueTypeGlobals());
|
||||
}
|
||||
|
||||
return s_wxAnyValueTypeGlobals;
|
||||
}
|
||||
|
||||
|
||||
WX_IMPLEMENT_ANY_VALUE_TYPE(wxAnyValueTypeImplVariantData)
|
||||
|
||||
void wxPreRegisterAnyToVariant(wxAnyToVariantRegistration* reg)
|
||||
{
|
||||
if ( !g_wxAnyValueTypeGlobals )
|
||||
g_wxAnyValueTypeGlobals.reset(new wxAnyValueTypeGlobals());
|
||||
g_wxAnyValueTypeGlobals->PreRegisterAnyToVariant(reg);
|
||||
GetAnyValueTypeGlobals()->PreRegisterAnyToVariant(reg);
|
||||
}
|
||||
|
||||
bool wxConvertAnyToVariant(const wxAny& any, wxVariant* variant)
|
||||
@ -175,7 +186,7 @@ bool wxConvertAnyToVariant(const wxAny& any, wxVariant* variant)
|
||||
|
||||
// Find matching factory function
|
||||
wxVariantDataFactory f =
|
||||
g_wxAnyValueTypeGlobals->FindVariantDataFactory(any.GetType());
|
||||
GetAnyValueTypeGlobals()->FindVariantDataFactory(any.GetType());
|
||||
|
||||
wxVariantData* data = NULL;
|
||||
|
||||
@ -223,7 +234,7 @@ public:
|
||||
}
|
||||
virtual void OnExit() wxOVERRIDE
|
||||
{
|
||||
g_wxAnyValueTypeGlobals.reset();
|
||||
GetAnyValueTypeGlobals().reset();
|
||||
}
|
||||
private:
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user