Fix inefficient delayed setting of wxSplitterWindow sash

If setting sash position to a value that cannot be satisfied due to
minimum size constraints, wxSplitterWindow would continue endlessly
trying and failing to set it, causing constant CPU use on OS X. This was
because delayed sash setting was invoked from idle handler and if it
failed, the code would repeat the same action again and again.

Instead, perform this delayed setting from OnSize handler. If setting
sash position failed in the first place, it must have been due to too
small size of the window. Therefore it's pointless to try again until
the size changes.

(cherry picked from commit 513fca5d4c)
This commit is contained in:
Václav Slavík
2016-02-21 18:43:10 +01:00
parent d99d4568df
commit d918dabb2d

View File

@@ -192,21 +192,15 @@ void wxSplitterWindow::OnInternalIdle()
{
wxWindow::OnInternalIdle();
// We may need to update the children sizes in two cases: either because
// we're in the middle of a live update as indicated by m_needUpdating or
// because we have a requested but not yet set sash position as indicated
// by m_requestedSashPosition having a valid value.
// We may need to update the children sizes if we're in the middle of
// a live update as indicated by m_needUpdating. The other possible case,
// when we have a requested but not yet set sash position (as indicated
// by m_requestedSashPosition having a valid value) is handled by OnSize.
if ( m_needUpdating )
{
m_needUpdating = false;
}
else if ( m_requestedSashPosition == INT_MAX )
{
// We don't need to resize the children.
return;
}
SizeWindows();
}
}
void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event)