From 72f9fade8d83ff82985a66afa8ea42e10a7b41ad Mon Sep 17 00:00:00 2001 From: James Crook Date: Mon, 17 Sep 2018 15:31:55 +0100 Subject: [PATCH] Bug 1749 - Timer record dialog: wxWidgets assert failure The problem was that the end time was set to prohibit changes that brought it before the start time. However an update to start time could update the end time before the end time updated its legal range. The prohibition on going backwards in time is only for user interaction with that control, so we now clear the legal range before update and then recreate it. This change also fixes: Bug 1978 - Windows: Timer Record - a "debugging check" dialog is shown to the user In passing I also noticed that the controls were being updated every 50ms. This is totally pointless as they only show the nearest second. So I set the granularity for control updates to 1s. (1000ms). --- src/TimerRecordDialog.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/src/TimerRecordDialog.cpp b/src/TimerRecordDialog.cpp index ad5897eeb..e99b001e6 100644 --- a/src/TimerRecordDialog.cpp +++ b/src/TimerRecordDialog.cpp @@ -79,6 +79,11 @@ enum { POST_TIMER_RECORD_SHUTDOWN }; +// The slow timer interval is used to update the start and end times, which only show +// time to the nearest second. So we only need an update once a second. +const int kSlowTimerInterval = 1000; // ms + +// This timer interval is used in some busy-wait loops and is much shorter. const int kTimerInterval = 50; // ms static double wxDateTime_to_AudacityTime(wxDateTime& dateTime) @@ -177,7 +182,7 @@ TimerRecordDialog::TimerRecordDialog(wxWindow* parent, bool bAlreadySaved) m_pTimeTextCtrl_Duration->SetFieldFocus(3); m_timer.SetOwner(this, TIMER_ID); - m_timer.Start(kTimerInterval); + m_timer.Start(kSlowTimerInterval); // Do we need to tidy up when the timer recording has been completed? m_bProjectCleanupRequired = !(this->HaveFilesToRecover()); @@ -1019,7 +1024,15 @@ void TimerRecordDialog::UpdateEnd() { //v Use remaining disk -> record time calcs from AudacityProject::OnTimer to set range? m_DateTime_End = m_DateTime_Start + m_TimeSpan_Duration; + //wxLogDebug( "Time start %s end %s", + // m_DateTime_Start.FormatISOCombined(' '), + // m_DateTime_End.FormatISOCombined(' ') ); + + // Disable the range limitation (to fix Bug 1749 and 1978) + // Otherwise SetVallue asserts when going back in time. + m_pDatePickerCtrl_End->SetRange(wxInvalidDateTime, wxInvalidDateTime); m_pDatePickerCtrl_End->SetValue(m_DateTime_End); + // Re-enable range limitation to constrain user input. m_pDatePickerCtrl_End->SetRange(m_DateTime_Start, wxInvalidDateTime); // No backdating. m_pDatePickerCtrl_End->Refresh(); m_pTimeTextCtrl_End->SetValue(wxDateTime_to_AudacityTime(m_DateTime_End));