diff --git a/include/wx/window.h b/include/wx/window.h index 1b88bc156c..7a20ca1615 100644 --- a/include/wx/window.h +++ b/include/wx/window.h @@ -317,7 +317,7 @@ public: // reset the cached best size value so it will be recalculated the // next time it is needed. - void InvalidateBestSize() { m_bestSizeCache = wxDefaultSize; } + void InvalidateBestSize(); void CacheBestSize(const wxSize& size) const { wxConstCast(this, wxWindowBase)->m_bestSizeCache = size; } diff --git a/src/common/wincmn.cpp b/src/common/wincmn.cpp index 784b618111..c15d4f4da9 100644 --- a/src/common/wincmn.cpp +++ b/src/common/wincmn.cpp @@ -530,6 +530,16 @@ static bool wxHasRealChildren(const wxWindowBase* win) return (realChildCount > 0); } #endif + +void wxWindowBase::InvalidateBestSize() +{ + m_bestSizeCache = wxDefaultSize; + + // parent's best size calculation may depend on its children's + // best sizes, so let's invalidate it as well to be safe: + if (m_parent) + m_parent->InvalidateBestSize(); +} // return the size best suited for the current window wxSize wxWindowBase::DoGetBestSize() const