Don't leak wxMSWHeaderCtrlCustomDraw in dark mode

The pointer may have been already allocated when the code initializing
it in Create() when using dark mode is executed, so unconditionally
reassigning to it leaked memory.
This commit is contained in:
Vadim Zeitlin 2024-01-06 15:25:01 +01:00
parent e97d27165a
commit 9d21630069

View file

@ -221,7 +221,11 @@ bool wxMSWHeaderCtrl::Create(wxWindow *parent,
if ( wxMSWDarkMode::IsActive() )
{
m_customDraw = new wxMSWHeaderCtrlCustomDraw();
// Note that it may have been already allocated by MSWCreateControl()
// which calls SetFont() from InheritAttributes(), so don't recreate it
// in this case.
if ( !m_customDraw )
m_customDraw = new wxMSWHeaderCtrlCustomDraw();
m_customDraw->UseHeaderThemeColors(GetHwnd());
}