# HG changeset patch # User Chris Cannam # Date 1591880876 -3600 # Node ID b4b11af915f4a478ab45dcddfe183e4dc8569964 # Parent 14bf9bf5ac2880b89aec227aeed789d07c26b738 If duration < 0, swap start time and duration rather than throwing an exception - this is too deep to be throwing an exception here, we end up with bugs like #1989 (Crash when trying to import CSV file with certain unexpected data in it) - and the meaning of negative duration is not actually ambiguous diff -r 14bf9bf5ac28 -r b4b11af915f4 base/Event.h --- a/base/Event.h Fri May 29 17:37:41 2020 +0100 +++ b/base/Event.h Thu Jun 11 14:07:56 2020 +0100 @@ -84,7 +84,10 @@ m_haveDuration(true), m_haveReferenceFrame(false), m_value(value), m_level(0.f), m_frame(frame), m_duration(duration), m_referenceFrame(0), m_label(label) { - if (m_duration < 0) throw std::logic_error("duration must be >= 0"); + if (m_duration < 0) { + m_frame += m_duration; + m_duration = -m_duration; + } } Event(sv_frame_t frame, float value, sv_frame_t duration, @@ -93,7 +96,10 @@ m_haveDuration(true), m_haveReferenceFrame(false), m_value(value), m_level(level), m_frame(frame), m_duration(duration), m_referenceFrame(0), m_label(label) { - if (m_duration < 0) throw std::logic_error("duration must be >= 0"); + if (m_duration < 0) { + m_frame += m_duration; + m_duration = -m_duration; + } } Event(const Event &event) =default; @@ -135,7 +141,10 @@ Event p(*this); p.m_duration = duration; p.m_haveDuration = true; - if (duration < 0) throw std::logic_error("duration must be >= 0"); + if (p.m_duration < 0) { + p.m_frame += p.m_duration; + p.m_duration = -p.m_duration; + } return p; } Event withoutDuration() const {