From: Vadim Zeitlin Date: Sun, 30 Oct 2011 19:48:50 +0000 (+0000) Subject: Avoid too many sash position changed events when splitter is resized. X-Git-Url: https://git.saurik.com/wxWidgets.git/commitdiff_plain/6460ce5afe03b09a8f3832bbade88373f6050fc9 Avoid too many sash position changed events when splitter is resized. We could call SetSashPositionAndNotify() twice in a row which was probably unexpected and possibly wasteful, if the user code did anything non trivial in response to this event. Just call it once after we're certain which sash position do we want to set. git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@69601 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- diff --git a/src/generic/splitter.cpp b/src/generic/splitter.cpp index f4a4107e30..dee38940af 100644 --- a/src/generic/splitter.cpp +++ b/src/generic/splitter.cpp @@ -451,20 +451,23 @@ void wxSplitterWindow::OnSize(wxSizeEvent& event) // Don't do anything if the size didn't really change. if ( size != old_size ) { + int newPosition = -1; + // Apply gravity if we use it. int delta = (int) ( (size - old_size)*m_sashGravity ); if ( delta != 0 ) { - int newPosition = m_sashPosition + delta; + newPosition = m_sashPosition + delta; if( newPosition < m_minimumPaneSize ) newPosition = m_minimumPaneSize; - SetSashPositionAndNotify(newPosition); } // Also check if the second window became too small. - int adjustedPosition = AdjustSashPosition(m_sashPosition); - if ( adjustedPosition != m_sashPosition ) - SetSashPositionAndNotify(adjustedPosition); + newPosition = AdjustSashPosition(newPosition == -1 + ? m_sashPosition + : newPosition); + if ( newPosition != m_sashPosition ) + SetSashPositionAndNotify(newPosition); } }