From 37b3c698c8fe66a89fb00e0ad1e08339cd849f80 Mon Sep 17 00:00:00 2001 From: Seth Hillbrand Date: Wed, 4 Sep 2019 11:05:33 -0700 Subject: [PATCH] fixing comparison warning --- common/dialog_shim.cpp | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/common/dialog_shim.cpp b/common/dialog_shim.cpp index 7bcf5596ef..3378d8b61a 100644 --- a/common/dialog_shim.cpp +++ b/common/dialog_shim.cpp @@ -502,12 +502,9 @@ void DIALOG_SHIM::OnCharHook( wxKeyEvent& aEvt ) auto advance = [&]( int& idx ) { - idx += delta; - - if( idx < 0 ) - idx = m_tabOrder.size() - 1; - else if ( idx >= m_tabOrder.size() ) - idx = 0; + // Wrap-around modulus + int size = m_tabOrder.size(); + idx = ( ( idx + delta ) % size + size ) % size; }; for( size_t i = 0; i < m_tabOrder.size(); ++i ) @@ -523,6 +520,8 @@ void DIALOG_SHIM::OnCharHook( wxKeyEvent& aEvt ) { advance( currentIdx ); + //todo: We don't currently have non-textentry dialog boxes but this will break if + // we add them. #ifdef __APPLE__ while( dynamic_cast( m_tabOrder[ currentIdx ] ) == nullptr ) advance( currentIdx );