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
This commit is contained in:
Paul Davis 2011-11-21 17:51:15 +00:00
parent 28a40f81ba
commit 274a97a402
2 changed files with 24 additions and 2 deletions

View File

@ -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
{

View File

@ -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;