diff --git a/include/wx/msw/button.h b/include/wx/msw/button.h index 1f5ad27c9b..ee1d197e9d 100644 --- a/include/wx/msw/button.h +++ b/include/wx/msw/button.h @@ -88,8 +88,10 @@ protected: virtual void DoSetBitmapMargins(wxCoord x, wxCoord y); virtual void DoSetBitmapPosition(wxDirection dir); - // Increases the passed in size if necessary to account for the - // button image, if any + // Increases the passed in size to account for the button image. + // + // Should only be called if we do have a button, i.e. if m_imageData is + // non-NULL. void AdjustForBitmapSize(wxSize& size) const; class wxButtonImageData *m_imageData; diff --git a/src/msw/button.cpp b/src/msw/button.cpp index 240e2e9813..cabac36506 100644 --- a/src/msw/button.cpp +++ b/src/msw/button.cpp @@ -531,8 +531,7 @@ void wxButton::SetLabel(const wxString& label) void wxButton::AdjustForBitmapSize(wxSize &size) const { - if ( !m_imageData ) - return; + wxCHECK_RET( m_imageData, wxT("shouldn't be called if no image") ); // account for the bitmap size const wxSize sizeBmp = m_imageData->GetBitmap(State_Normal).GetSize(); @@ -614,6 +613,8 @@ wxSize wxButton::DoGetBestSize() const { AdjustForBitmapSize(size); + // The best size has changed so even if it had been already cached by + // ComputeBestSize() call above we still need to update it. CacheBestSize(size); }