mirror of
https://github.com/cookiengineer/audacity
synced 2025-09-17 16:50:26 +02:00
Don't rely on order of Bind to EVT_TRACK_PANEL_TIMER from project...
... instead, re-process the event, and let each handler bind to the one it depends on. This still leaves a critical ordering of construction of playback scroller and play indicator overlay in AudacityProject::AudacityProject (reverse of the previous), but that will be removed by other means.
This commit is contained in:
parent
a73970d864
commit
ac2fecf151
@ -1178,8 +1178,6 @@ AudacityProject::AudacityProject(wxWindow * parent, wxWindowID id,
|
||||
mRuler);
|
||||
mTrackPanel->UpdatePrefs();
|
||||
|
||||
mIndicatorOverlay = std::make_unique<PlayIndicatorOverlay>(this);
|
||||
|
||||
mCursorOverlay = std::make_unique<EditCursorOverlay>(this);
|
||||
|
||||
mBackgroundCell = std::make_shared<BackgroundCell>(this);
|
||||
@ -1189,16 +1187,10 @@ AudacityProject::AudacityProject(wxWindow * parent, wxWindowID id,
|
||||
mScrubber = std::make_unique<Scrubber>(this);
|
||||
#endif
|
||||
|
||||
// More order dependencies here...
|
||||
// This must follow construction of *mIndicatorOverlay, because it must
|
||||
// attach its timer event handler later (so that its handler is invoked
|
||||
// earlier)
|
||||
mPlaybackScroller = std::make_unique<PlaybackScroller>(this);
|
||||
|
||||
// This must follow construction of *mPlaybackScroller,
|
||||
// because it must
|
||||
// attach its timer event handler later (so that its handler is invoked
|
||||
// earlier)
|
||||
mIndicatorOverlay = std::make_unique<PlayIndicatorOverlay>(this);
|
||||
|
||||
this->Bind(EVT_TRACK_PANEL_TIMER,
|
||||
&ViewInfo::OnTimer,
|
||||
&mViewInfo);
|
||||
@ -5532,9 +5524,9 @@ int AudacityProject::GetEstimatedRecordingMinsLeftOnDisk(long lCaptureChannels)
|
||||
AudacityProject::PlaybackScroller::PlaybackScroller(AudacityProject *project)
|
||||
: mProject(project)
|
||||
{
|
||||
mProject->Bind(EVT_TRACK_PANEL_TIMER,
|
||||
&PlaybackScroller::OnTimer,
|
||||
this);
|
||||
mProject->GetViewInfo().Bind(EVT_TRACK_PANEL_TIMER,
|
||||
&PlaybackScroller::OnTimer,
|
||||
this);
|
||||
}
|
||||
|
||||
void AudacityProject::PlaybackScroller::OnTimer(wxCommandEvent &event)
|
||||
@ -5542,6 +5534,11 @@ void AudacityProject::PlaybackScroller::OnTimer(wxCommandEvent &event)
|
||||
// Let other listeners get the notification
|
||||
event.Skip();
|
||||
|
||||
auto cleanup = finally([&]{
|
||||
// Propagate the message to other listeners bound to this
|
||||
this->ProcessEvent( event );
|
||||
});
|
||||
|
||||
if(!mProject->IsAudioActive())
|
||||
return;
|
||||
else if (mMode == Mode::Refresh) {
|
||||
|
@ -204,4 +204,6 @@ void ViewInfo::OnTimer(wxCommandEvent &event)
|
||||
{
|
||||
mRecentStreamTime = gAudioIO->GetStreamTime();
|
||||
event.Skip();
|
||||
// Propagate the message to other listeners bound to this
|
||||
this->ProcessEvent( event );
|
||||
}
|
||||
|
@ -110,9 +110,9 @@ void PlayIndicatorOverlayBase::Draw(OverlayPanel &panel, wxDC &dc)
|
||||
PlayIndicatorOverlay::PlayIndicatorOverlay(AudacityProject *project)
|
||||
: PlayIndicatorOverlayBase(project, true)
|
||||
{
|
||||
mProject->Bind(EVT_TRACK_PANEL_TIMER,
|
||||
&PlayIndicatorOverlay::OnTimer,
|
||||
this);
|
||||
mProject->GetPlaybackScroller().Bind(EVT_TRACK_PANEL_TIMER,
|
||||
&PlayIndicatorOverlay::OnTimer,
|
||||
this);
|
||||
}
|
||||
|
||||
PlayIndicatorOverlay::~PlayIndicatorOverlay()
|
||||
|
Loading…
x
Reference in New Issue
Block a user