Don't crash in wxAuiToolBar::GetToolBarFits().

The code could crash if m_overflowVisible was true but m_overflowSizerItem was
NULL. Ideally this shouldn't happen in the first place, but it did, so at
least fix the crash for now -- and hopefully this code will be refactored to
make it more clear later.

Backport from trunk, see #15747.

git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_3_0_BRANCH@75399 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
Vadim Zeitlin
2013-12-18 16:18:16 +00:00
parent 09bdd20bb7
commit e2f2fbffa9
2 changed files with 3 additions and 2 deletions

View File

@@ -588,6 +588,7 @@ All (GUI):
- Fix wxCommandProcessor::IsDirty() return value which was wrong after undoing - Fix wxCommandProcessor::IsDirty() return value which was wrong after undoing
all commands without saving (Neil Chittenden). all commands without saving (Neil Chittenden).
- Fix crash when Destroy()-ing a TLW with non-TLW parent. - Fix crash when Destroy()-ing a TLW with non-TLW parent.
- Fix crash in wxAuiToolBar::GetToolBarFits().
wxGTK: wxGTK:

View File

@@ -1772,7 +1772,7 @@ bool wxAuiToolBar::GetToolFitsByIndex(int tool_idx) const
if (m_orientation == wxVERTICAL) if (m_orientation == wxVERTICAL)
{ {
// take the dropdown size into account // take the dropdown size into account
if (m_overflowVisible) if (m_overflowVisible && m_overflowSizerItem)
cli_h -= m_overflowSizerItem->GetSize().y; cli_h -= m_overflowSizerItem->GetSize().y;
if (rect.y+rect.height < cli_h) if (rect.y+rect.height < cli_h)
@@ -1781,7 +1781,7 @@ bool wxAuiToolBar::GetToolFitsByIndex(int tool_idx) const
else else
{ {
// take the dropdown size into account // take the dropdown size into account
if (m_overflowVisible) if (m_overflowVisible && m_overflowSizerItem)
cli_w -= m_overflowSizerItem->GetSize().x; cli_w -= m_overflowSizerItem->GetSize().x;
if (rect.x+rect.width < cli_w) if (rect.x+rect.width < cli_w)