1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-11-16 14:13:53 +01:00

Bug1933: commit 2c28af05e8 needs null checks

This commit is contained in:
Paul Licameli
2018-08-12 15:44:08 -04:00
parent 932734c89a
commit 328aa58966
5 changed files with 40 additions and 32 deletions

View File

@@ -192,7 +192,9 @@ UIHandle::Result StretchHandle::Drag
const wxMouseEvent &event = evt.event; const wxMouseEvent &event = evt.event;
const int x = event.m_x; const int x = event.m_x;
Track *clickedTrack = Track *clickedTrack;
if (evt.pCell)
clickedTrack =
static_cast<CommonTrackPanelCell*>(evt.pCell.get())->FindTrack().get(); static_cast<CommonTrackPanelCell*>(evt.pCell.get())->FindTrack().get();
if (clickedTrack == NULL && mpTrack != NULL) if (clickedTrack == NULL && mpTrack != NULL)

View File

@@ -178,7 +178,8 @@ UIHandle::Result EnvelopeHandle::Click
const ViewInfo &viewInfo = pProject->GetViewInfo(); const ViewInfo &viewInfo = pProject->GetViewInfo();
const auto pTrack = static_cast<Track*>(evt.pCell.get()); const auto pTrack = static_cast<Track*>(evt.pCell.get());
if (pTrack->GetKind() == Track::Wave) { if (pTrack &&
pTrack->GetKind() == Track::Wave) {
WaveTrack *const wt = static_cast<WaveTrack*>(pTrack); WaveTrack *const wt = static_cast<WaveTrack*>(pTrack);
if (wt->GetDisplay() != WaveTrack::Waveform) if (wt->GetDisplay() != WaveTrack::Waveform)
return Cancelled; return Cancelled;
@@ -203,7 +204,8 @@ UIHandle::Result EnvelopeHandle::Click
std::make_unique< EnvelopeEditor >( *clickedEnvelope, true ); std::make_unique< EnvelopeEditor >( *clickedEnvelope, true );
} }
} }
else if (pTrack->GetKind() == Track::Time) else if (pTrack &&
pTrack->GetKind() == Track::Time)
{ {
TimeTrack *const tt = static_cast<TimeTrack*>(pTrack); TimeTrack *const tt = static_cast<TimeTrack*>(pTrack);
if (!mEnvelope) if (!mEnvelope)

View File

@@ -837,6 +837,7 @@ UIHandle::Result SelectHandle::Drag
return RefreshNone; return RefreshNone;
} }
if (evt.pCell) {
if ( auto clickedTrack = if ( auto clickedTrack =
static_cast<CommonTrackPanelCell*>(evt.pCell.get())->FindTrack() ) { static_cast<CommonTrackPanelCell*>(evt.pCell.get())->FindTrack() ) {
// Handle which tracks are selected // Handle which tracks are selected
@@ -866,6 +867,7 @@ UIHandle::Result SelectHandle::Drag
AdjustSelection(pProject, viewInfo, x, mRect.x, clickedTrack.get()); AdjustSelection(pProject, viewInfo, x, mRect.x, clickedTrack.get());
} }
}
return RefreshNone return RefreshNone

View File

@@ -431,6 +431,8 @@ UIHandle::Result TimeShiftHandle::Click
const ViewInfo &viewInfo = pProject->GetViewInfo(); const ViewInfo &viewInfo = pProject->GetViewInfo();
const auto pTrack = std::static_pointer_cast<Track>(evt.pCell); const auto pTrack = std::static_pointer_cast<Track>(evt.pCell);
if (!pTrack)
return RefreshCode::Cancelled;
TrackList *const trackList = pProject->GetTracks(); TrackList *const trackList = pProject->GetTracks();