From da2f5491aecb9663f5be8f8ea1a77e384e25d930 Mon Sep 17 00:00:00 2001 From: Paul Licameli Date: Thu, 9 Jan 2020 14:15:20 -0500 Subject: [PATCH] Revert "Bug 2275 - Crash when unchecking Multi-view with neither of the views checked" This reverts commit 57ff92b20c01ce6da39475858775619a532e106b. --- .../wavetrack/ui/WaveTrackView.cpp | 39 +++++-------------- 1 file changed, 10 insertions(+), 29 deletions(-) diff --git a/src/tracks/playabletrack/wavetrack/ui/WaveTrackView.cpp b/src/tracks/playabletrack/wavetrack/ui/WaveTrackView.cpp index 5a04a5762..0bf441597 100644 --- a/src/tracks/playabletrack/wavetrack/ui/WaveTrackView.cpp +++ b/src/tracks/playabletrack/wavetrack/ui/WaveTrackView.cpp @@ -559,50 +559,31 @@ void WaveTrackView::ToggleSubView(WaveTrackDisplay display) return false; } ) ) { auto &foundPlacement = mPlacements[found]; - auto index = foundPlacement.index; - unsigned nn = 0; - - // if found and active, deactivate it.. if ( foundPlacement.fraction > 0.0 ) { - for (auto &placement : mPlacements) { - if (placement.fraction > 0.0 && placement.index >= 0) { - nn++; - } - } - // if removing the last one, then don't! - // Switch to radio-button view instead. - if (nn <= 1) { - DoSetDisplay(display); - SetMultiView(false); - } - else - { - foundPlacement = { -1, 0.0 }; - if (index >= 0) { - for (auto &placement : mPlacements) { - if (placement.index > index) - --placement.index; - } + auto index = foundPlacement.index; + foundPlacement = { -1, 0.0 }; + if (index >= 0) { + for ( auto &placement : mPlacements ) { + if ( placement.index > index ) + --placement.index; } } } - // else found and zero size, so add it on the bottom. else { float total = 0; int greatest = -1; + unsigned nn = 0; + int removedIndex = foundPlacement.index; for ( auto &placement : mPlacements ) { if ( placement.fraction >= 0.0 && placement.index >= 0 ) { // renumber in case there's an item removed. - if( (index >= 0) && (placement.index >= index)) - --placement.index; + if( (removedIndex >= 0) && (placement.index >= removedIndex)) + placement.index -= 1; total += placement.fraction; greatest = std::max( greatest, placement.index ); ++nn; } } - // - if ( index >= 0) - --nn; // Turn on the sub-view, putting it lowest, and with average of the // heights of the other sub-views foundPlacement = { greatest + 1, total / nn };