From d918dabb2d6e3c86a498a99d4305f9c7a0cf687f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Va=CC=81clav=20Slavi=CC=81k?= Date: Sun, 21 Feb 2016 18:43:10 +0100 Subject: [PATCH] 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 513fca5d4cff571028bc18482689dd68f1a96a95) --- src/generic/splitter.cpp | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/generic/splitter.cpp b/src/generic/splitter.cpp index 826b92a7d8..fce272f564 100644 --- a/src/generic/splitter.cpp +++ b/src/generic/splitter.cpp @@ -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; + SizeWindows(); } - else if ( m_requestedSashPosition == INT_MAX ) - { - // We don't need to resize the children. - return; - } - - SizeWindows(); } void wxSplitterWindow::OnMouseEvent(wxMouseEvent& event)