]> git.saurik.com Git - wxWidgets.git/blobdiff - src/propgrid/propgrid.cpp
fix for crash when undocking AUI toolbars (same as r59107 in 2.8 branch)
[wxWidgets.git] / src / propgrid / propgrid.cpp
index d111896c389c61569164471045b54d2f32fa30e2..f33e2c71198ce39bb7da0cbce9a3eebd4e625482 100644 (file)
@@ -63,8 +63,6 @@
 
 #include "wx/timer.h"
 #include "wx/dcbuffer.h"
-#include "wx/clipbrd.h"
-#include "wx/dataobj.h"
 
 #ifdef __WXMSW__
     #include "wx/msw/private.h"
@@ -825,11 +823,17 @@ void wxPropertyGrid::SetExtraStyle( long exStyle )
 // returns the best acceptable minimal size
 wxSize wxPropertyGrid::DoGetBestSize() const
 {
-    int hei = 15;
-    if ( m_lineHeight > hei )
-        hei = m_lineHeight;
-    wxSize sz = wxSize( 60, hei+40 );
+    int lineHeight = wxMax(15, m_lineHeight);
 
+    // don't make the grid too tall (limit height to 10 items) but don't
+    // make it too small neither
+    int numLines = wxMin
+                   (
+                    wxMax(m_pState->m_properties->GetChildCount(), 3),
+                    10
+                   );
+
+    const wxSize sz = wxSize(60, lineHeight*numLines + 40);
     CacheBestSize(sz);
     return sz;
 }
@@ -1034,7 +1038,7 @@ bool wxPropertyGrid::SetFont( const wxFont& font )
     ClearSelection(false);
 
     bool res = wxScrolledWindow::SetFont( font );
-    if ( res )
+    if ( res && GetParent()) // may not have been Create()ed yet
     {
         CalculateFontAndBitmapStuff( m_vspacing );
         Refresh();