1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-08-08 08:01:19 +02:00

Bug1770: fix crash applying chains

This commit is contained in:
Paul Licameli 2017-11-04 13:33:11 -04:00
parent 68897d8932
commit 5dd72acc02
3 changed files with 17 additions and 6 deletions

View File

@ -882,9 +882,8 @@ void TrackList::DeletionEvent()
void TrackList::ResizingEvent(TrackNodePointer node)
{
auto e = std::make_unique<wxCommandEvent>(EVT_TRACKLIST_RESIZING);
if (!isNull(node))
e->SetClientData(node->get());
auto e = std::make_unique<TrackListEvent>(EVT_TRACKLIST_RESIZING);
e->mpTrack = *node;
// wxWidgets will own the event object
QueueEvent(e.release());
}

View File

@ -518,11 +518,23 @@ class AUDACITY_DLL_API SyncLockedTracksIterator final : public TrackListIterator
* Clear, and Contains, plus serialization of the list of tracks.
*/
struct TrackListEvent : public wxCommandEvent
{
TrackListEvent(wxEventType commandType = wxEVT_NULL, int winid = 0)
: wxCommandEvent{ commandType, winid } {}
TrackListEvent( const TrackListEvent& ) = default;
wxEvent *Clone() const override { return new TrackListEvent(*this); }
std::weak_ptr<Track> mpTrack;
};
// Posted when tracks are reordered but otherwise unchanged.
DECLARE_EXPORTED_EVENT_TYPE(AUDACITY_DLL_API, EVT_TRACKLIST_PERMUTED, -1);
// Posted when some track was added or changed its height.
// The wxCommandEvent::GetClientData() method can be used to retrieve it.
// Cast to TrackListEvent and examine mpTrack to retrieve it.
DECLARE_EXPORTED_EVENT_TYPE(AUDACITY_DLL_API, EVT_TRACKLIST_RESIZING, -1);
// Posted when a track has been deleted from a tracklist.

View File

@ -1158,10 +1158,10 @@ void TrackPanel::OnPlayback(wxCommandEvent &e)
// ruler size for the track that triggered the event.
void TrackPanel::OnTrackListResizing(wxCommandEvent & e)
{
Track *t = (Track *) e.GetClientData();
auto t = static_cast<TrackListEvent&>(e).mpTrack.lock();
// A deleted track can trigger the event. In which case do nothing here.
if( t )
UpdateVRuler(t);
UpdateVRuler(t.get());
e.Skip();
}