Avoid updating wxStaticBitmap unnecessarily

If the kind of the bitmap/icon used by the control didn't change (which
will be most often the case, as using both an icon and a bitmap with the
same control is vanishingly rare), there is no need to update the window
style.

No real changes, this is just a micro-optimization.
This commit is contained in:
Vadim Zeitlin
2019-05-16 22:26:13 +02:00
parent eb0fc45d92
commit 2039d864ba

View File

@@ -289,6 +289,8 @@ void wxStaticBitmap::SetImageNoCopy( wxGDIImage* image)
if ( image )
sizeNew = image->GetSize();
const bool wasIcon = m_isIcon;
Free();
if ( sizeNew != sizeOld )
@@ -326,9 +328,13 @@ void wxStaticBitmap::SetImageNoCopy( wxGDIImage* image)
}
}
#endif // wxUSE_WXDIB
wxMSWWinStyleUpdater(GetHwnd())
.TurnOff(SS_BITMAP | SS_ICON)
.TurnOn(m_isIcon ? SS_ICON : SS_BITMAP);
if ( m_isIcon != wasIcon )
{
wxMSWWinStyleUpdater(GetHwnd())
.TurnOff(SS_BITMAP | SS_ICON)
.TurnOn(m_isIcon ? SS_ICON : SS_BITMAP);
}
MSWReplaceImageHandle((WXLPARAM)handle);