From cf79f91da09d0a9ef939954a6d1790a6d2574a3b Mon Sep 17 00:00:00 2001 From: David Bailes Date: Fri, 24 Jun 2016 13:59:10 +0100 Subject: [PATCH] Fix bug 1418 - track focus problem. To reproduce the bug: open audacity, press r, then spacebar to record some audio. The track is not the focus - the track panel is. This was caused by commit 519a202. Most of the changes in this commit were latter reverted in commit 80e19f2, but not the changes to the file src/TrackPanelAx.cpp The fix is to go back to the version of TrackPanelAx.cpp in commit db35301, the commit before 519a202. --- src/TrackPanelAx.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/src/TrackPanelAx.cpp b/src/TrackPanelAx.cpp index a512efa94..41aadee1d 100644 --- a/src/TrackPanelAx.cpp +++ b/src/TrackPanelAx.cpp @@ -46,7 +46,12 @@ TrackPanelAx::~TrackPanelAx() // Returns currently focused track or first one if none focused Track *TrackPanelAx::GetFocus() { - if( mFocusedTrack && !TrackNum( mFocusedTrack ) ) + if( !mFocusedTrack ) + { + SetFocus( NULL ); + } + + if( !TrackNum( mFocusedTrack ) ) { mFocusedTrack = NULL; } @@ -67,6 +72,12 @@ void TrackPanelAx::SetFocus( Track *track ) } #endif + if( track == NULL ) + { + TrackListIterator iter( mTrackPanel->mTracks ); + track = iter.First(); + } + mFocusedTrack = track; #if wxUSE_ACCESSIBILITY @@ -95,8 +106,13 @@ void TrackPanelAx::SetFocus( Track *track ) // Returns TRUE if passed track has the focus bool TrackPanelAx::IsFocused( Track *track ) { + if( !mFocusedTrack ) + { + SetFocus( NULL ); + } + if( ( track == mFocusedTrack ) || - ( mFocusedTrack && track == mFocusedTrack->GetLink() ) ) + ( track == mFocusedTrack->GetLink() ) ) { return true; }