Move wxTextCtrl constructors out of line in wxMSW

When inheriting from std::streambuf, as is the case by default, and
creating wxTextCtrl in the application (as is common) and destroying it
in the library (as is even more so, as it's typically done when the
parent window is destroyed), having inline constructor but not inline
destructor apparently results in std::locale, which is part of
std::streambuf, to be allocated and destroyed using different heaps or
something similar when using TDM-GCC libstdc++, as destroying
std::locale inside the library corrupts the heap and results in crashes
when the next std::locale object is destroyed -- i.e. creating, and then
destroying, more than one wxTextCtrl results in a crash.

Work around this by moving the constructors out of line, as this is
sufficient to avoid the problem, even if it's exact causes are not
exactly clear.

This commit is best viewed with Git --color-moved option.

See #22639.
This commit is contained in:
Vadim Zeitlin 2022-07-18 20:44:02 +01:00
parent e9d299d92c
commit 70c5ec6eff
2 changed files with 21 additions and 7 deletions

View file

@ -393,6 +393,25 @@ void wxTextCtrl::Init()
m_isNativeCaretShown = true;
}
wxTextCtrl::wxTextCtrl()
{
Init();
}
wxTextCtrl::wxTextCtrl(wxWindow *parent,
wxWindowID id,
const wxString& value,
const wxPoint& pos,
const wxSize& size,
long style,
const wxValidator& validator,
const wxString& name)
{
Init();
Create(parent, id, value, pos, size, style, validator, name);
}
wxTextCtrl::~wxTextCtrl()
{
#if wxUSE_DRAG_AND_DROP && wxUSE_RICHEDIT