From: Vadim Zeitlin <vadim@wxwidgets.org>
Date: Fri, 12 Dec 2008 16:31:39 +0000 (+0000)
Subject: fix best size caching
X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/7bf5be6b568bc2f217519c46280d0cd9adce9bc1?ds=inline

fix best size caching

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@57289 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
---

diff --git a/src/generic/headerctrlg.cpp b/src/generic/headerctrlg.cpp
index 4ec2a61120..961c42b5d4 100644
--- a/src/generic/headerctrlg.cpp
+++ b/src/generic/headerctrlg.cpp
@@ -115,9 +115,14 @@ void wxHeaderCtrl::DoSetCount(unsigned int count)
 
         m_colIndices = colIndices;
     }
+    else // count didn't really change
+    {
+        return;
+    }
 
     m_numColumns = count;
 
+    InvalidateBestSize();
     Refresh();
 }
 
@@ -128,6 +133,8 @@ unsigned int wxHeaderCtrl::DoGetCount() const
 
 void wxHeaderCtrl::DoUpdate(unsigned int idx)
 {
+    InvalidateBestSize();
+
     // we need to refresh not only this column but also the ones after it in
     // case it was shown or hidden or its width changed -- it would be nice to
     // avoid doing this unnecessary by storing the old column width (TODO)
@@ -154,9 +161,11 @@ wxSize wxHeaderCtrl::DoGetBestSize() const
 {
     // the vertical size is rather arbitrary but it looks better if we leave
     // some space around the text
-    return wxSize(IsEmpty() ? wxHeaderCtrlBase::DoGetBestSize().x
-                            : GetColEnd(GetColumnCount() - 1),
-                  (7*GetCharHeight())/4);
+    const wxSize size(IsEmpty() ? wxHeaderCtrlBase::DoGetBestSize().x
+                                : GetColEnd(GetColumnCount() - 1),
+                      (7*GetCharHeight())/4);
+    CacheBestSize(size);
+    return size;
 }
 
 int wxHeaderCtrl::GetColStart(unsigned int idx) const