From 4de25822f373782dab54d09e1be978d94b97ca76 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Sun, 15 Sep 2013 00:14:51 +0000 Subject: [PATCH 1/1] Don't crash when laying out wxGridBagSizer with only hidden elements. wxGridBagSizer lay out algorithm needs at least a single row and a single column to work, so simply don't run it at all if there is nothing to lay out. Closes #15475. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@74810 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- docs/changes.txt | 1 + src/common/gbsizer.cpp | 6 +++++- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/docs/changes.txt b/docs/changes.txt index d822b9852f..865271b1e8 100644 --- a/docs/changes.txt +++ b/docs/changes.txt @@ -576,6 +576,7 @@ All (GUI): - Add wxPropertyGridPageState::GetColumnFullWidth() (Teodor Petrov). - wxRTC: extracted XML utilities into a separate class for potential reuse. - wxPropertyGrid: improve composite flags handling (Jens Lody). +- Don't crash laying out wxGridBagSizer with only hidden elements (briceandre). wxGTK: diff --git a/src/common/gbsizer.cpp b/src/common/gbsizer.cpp index 1a1dda0928..88a6394175 100644 --- a/src/common/gbsizer.cpp +++ b/src/common/gbsizer.cpp @@ -505,7 +505,11 @@ wxSize wxGridBagSizer::CalcMin() void wxGridBagSizer::RecalcSizes() { - if (m_children.GetCount() == 0) + // We can't lay out our elements if we don't have at least a single row and + // a single column. Notice that this may happen even if we have some + // children but all of them are hidden, so checking for m_children being + // non-empty is not enough, see #15475. + if ( m_rowHeights.empty() || m_colWidths.empty() ) return; wxPoint pt( GetPosition() ); -- 2.45.2