add validation checks on TC.hours, BBT.ticks and validate minsec data entry
authorPaul Davis <paul@linuxaudiosystems.com>
Mon, 21 Nov 2011 17:51:15 +0000 (17:51 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Mon, 21 Nov 2011 17:51:15 +0000 (17:51 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@10740 d708f5d6-7413-0410-9779-e7cbd77b26cf

gtk2_ardour/audio_clock.cc
gtk2_ardour/audio_clock.h

index eb41ef319d113788e0369999b07f1f2964163890..802b0dbbba34b102725e6abe5ac16ea8f4067259 100644 (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
 {
index 011c2ed81a17e90d8d242a2721481c35adfc2266..07770df0f62d5b63aeb99fb60f747d0ffe74b8ba 100644 (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;