diff options
author | Paul Davis <paul@linuxaudiosystems.com> | 2011-11-21 17:51:15 +0000 |
---|---|---|
committer | Paul Davis <paul@linuxaudiosystems.com> | 2011-11-21 17:51:15 +0000 |
commit | 274a97a4021e342e4aaf66837c3f1d54b8c14e66 (patch) | |
tree | 72c248d539b512fe99f27d5dbc84e7ba3571ca36 /gtk2_ardour | |
parent | 28a40f81bad56ad30741e328f4442e7f76ab1b00 (diff) |
add validation checks on TC.hours, BBT.ticks and validate minsec data entry
git-svn-id: svn://localhost/ardour2/branches/3.0@10740 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'gtk2_ardour')
-rw-r--r-- | gtk2_ardour/audio_clock.cc | 25 | ||||
-rw-r--r-- | gtk2_ardour/audio_clock.h | 1 |
2 files changed, 24 insertions, 2 deletions
diff --git a/gtk2_ardour/audio_clock.cc b/gtk2_ardour/audio_clock.cc index eb41ef319d..802b0dbbba 100644 --- a/gtk2_ardour/audio_clock.cc +++ b/gtk2_ardour/audio_clock.cc @@ -554,6 +554,7 @@ AudioClock::end_edit (bool modify) break; case MinSec: + ok = minsec_validate_edit (edit_string); break; case Frames: @@ -1667,7 +1668,11 @@ AudioClock::bbt_validate_edit (const string& str) if (sscanf (str.c_str(), BBT_SCANF_FORMAT, &any.bbt.bars, &any.bbt.beats, &any.bbt.ticks) != 3) { return false; } - + + if (any.bbt.ticks > Timecode::BBT_Time::ticks_per_beat) { + return false; + } + if (!is_duration && any.bbt.bars == 0) { return false; } @@ -1689,7 +1694,7 @@ AudioClock::timecode_validate_edit (const string& str) return false; } - if (TC.minutes > 59U || TC.seconds > 59U) { + if (TC.hours > 23U || TC.minutes > 59U || TC.seconds > 59U) { return false; } @@ -1706,6 +1711,22 @@ AudioClock::timecode_validate_edit (const string& str) return true; } +bool +AudioClock::minsec_validate_edit (const string& str) +{ + int hrs, mins, secs, millisecs; + + if (sscanf (str.c_str(), "%d:%d:%d.%d", &hrs, &mins, &secs, &millisecs) != 4) { + return false; + } + + if (hrs > 23 || mins > 59 || secs > 59 || millisecs > 999) { + return false; + } + + return true; +} + framepos_t AudioClock::frames_from_timecode_string (const string& str) const { diff --git a/gtk2_ardour/audio_clock.h b/gtk2_ardour/audio_clock.h index 011c2ed81a..07770df0f6 100644 --- a/gtk2_ardour/audio_clock.h +++ b/gtk2_ardour/audio_clock.h @@ -188,6 +188,7 @@ class AudioClock : public CairoWidget, public ARDOUR::SessionHandlePtr bool timecode_validate_edit (const std::string&); bool bbt_validate_edit (const std::string&); + bool minsec_validate_edit (const std::string&); framepos_t frames_from_timecode_string (const std::string&) const; framepos_t frames_from_bbt_string (framepos_t, const std::string&) const; |