1
0
mirror of https://github.com/cookiengineer/audacity synced 2025-05-06 23:02:42 +02:00

Bug 1401 - Wait for window visibility before starting timer

This commit is contained in:
Darrell Walisser 2017-02-25 16:16:42 -05:00
parent ebd767f81b
commit 43291687a5
2 changed files with 21 additions and 1 deletions

View File

@ -516,7 +516,8 @@ TrackPanel::TrackPanel(wxWindow * parent, wxWindowID id,
mTimeCount = 0;
mTimer.parent = this;
mTimer.Start(kTimerInterval, FALSE);
// Timer is started after the window is visible
GetProject()->Bind(wxEVT_IDLE, &TrackPanel::OnIdle, this);
//Initialize a member variable pointing to the current
//drawing track.
@ -904,6 +905,24 @@ AudacityProject * TrackPanel::GetProject() const
return (AudacityProject*)pWind;
}
void TrackPanel::OnIdle(wxIdleEvent& event)
{
// The window must be ready when the timer fires (#1401)
if (IsShownOnScreen())
{
mTimer.Start(kTimerInterval, FALSE);
// Timer is started, we don't need the event anymore
GetProject()->Unbind(wxEVT_IDLE, &TrackPanel::OnIdle, this);
}
else
{
// Get another idle event, wx only guarantees we get one
// event after "some other normal events occur"
event.RequestMore();
}
}
/// AS: This gets called on our wx timer events.
void TrackPanel::OnTimer(wxTimerEvent& )
{

View File

@ -171,6 +171,7 @@ class AUDACITY_DLL_API TrackPanel final : public OverlayPanel {
virtual double GetMostRecentXPos();
virtual void OnIdle(wxIdleEvent & event);
virtual void OnTimer(wxTimerEvent& event);
virtual int GetLeftOffset() const { return GetLabelWidth() + 1;}