Bug 2060: Windows: no access to microphone causes crash

Problem:
1. Set no access to microphone in Privacy category of Settings app.
2. Try to record in a new track. (not append to an existing track.)
3. Audacity crashes.

Cause of crash:
TrackPanel::OnTrackListResizing is called with a track after a call to
TrackList::ClearPendingTracks, which has removed its owner.
TrackPanel::OnTrackListResizing ends up calling TrackPanel::UpdateTrackVRuler,
and this function calls TrackList::Channels(t)), which assumes the track has an owner.
Crash.

Fix: in TrackPanel::OnTrackListResizing, check that the track has an owner.
This commit is contained in:
David Bailes 2019-02-05 14:29:22 +00:00
parent 807a763c90
commit 012d707a8a
2 changed files with 4 additions and 1 deletions

View File

@ -329,6 +329,8 @@ public:
// For use when loading a file. Return true if ok, else make repair
bool LinkConsistencyCheck();
bool HasOwner() const { return static_cast<bool>(GetOwner());}
private:
std::shared_ptr<TrackList> GetOwner() const { return mList.lock(); }

View File

@ -715,7 +715,8 @@ void TrackPanel::OnTrackListResizing(TrackListEvent & e)
{
auto t = e.mpTrack.lock();
// A deleted track can trigger the event. In which case do nothing here.
if( t )
// A deleted track can have a valid pointer but no owner, bug 2060
if( t && t->HasOwner() )
UpdateVRuler(t.get());
e.Skip();
}