Create wxPGGlobalVars on demand and not on startup

This is slightly more efficient as it avoids allocating an object which
is possibly not ever going to be used on startup of any application
linking with the propgrid library (at the price of slower access to this
object, but this should never be done in performance-critical parts of
the code, hopefully) and avoids a problem with losing the previously
registered editors when re-initializing wx modules, as wxPython does.

Closes #23165.

See #23187.
This commit is contained in:
Vadim Zeitlin 2023-01-29 17:14:11 +00:00
parent cd0c527889
commit 0130282987
2 changed files with 25 additions and 4 deletions

View file

@ -113,7 +113,14 @@ public:
int HasExtraStyle( int style ) const { return (m_extraStyle & style); }
};
extern WXDLLIMPEXP_DATA_PROPGRID(wxPGGlobalVarsClass*) wxPGGlobalVars;
// Internal class providing access to the global wxPGGlobalVars instance.
class WXDLLIMPEXP_PROPGRID wxPGGlobalVarsPtr
{
public:
wxPGGlobalVarsClass* operator->() const;
};
extern WXDLLIMPEXP_DATA_PROPGRID(wxPGGlobalVarsPtr) wxPGGlobalVars;
#define wxPGVariant_EmptyString (wxPGGlobalVars->m_vEmptyString)
#define wxPGVariant_Zero (wxPGGlobalVars->m_vZero)