]> git.tdb.fi Git - r2c2.git/commitdiff
Don't clear timetable before all rows are successfully parsed
authorMikko Rasa <tdb@tdb.fi>
Mon, 26 Apr 2010 09:09:21 +0000 (09:09 +0000)
committerMikko Rasa <tdb@tdb.fi>
Mon, 26 Apr 2010 09:09:21 +0000 (09:09 +0000)
Do a more complete reset of timetable state when clearing
Also reset timetable state when toggling enabled state

source/engineer/timetabledialog.cpp
source/libmarklin/timetable.cpp
source/libmarklin/timetable.h

index 978b14bcb53a9e73d0e82fb913a1862ca05ab540..fcb06f84fceba54e736834ee706adc1f0a52f8c6 100644 (file)
@@ -53,13 +53,13 @@ TimetableDialog::TimetableDialog(const GLtk::Resources &r, Timetable &tt):
 void TimetableDialog::enabled_toggled(bool value)
 {
        timetable.set_enabled(value);
+       timetable.reset();
 }
 
 void TimetableDialog::on_response(int code)
 {
        if(code)
        {
-               timetable.clear();
                vector<string> lines = split(ent_timetable->get_text(), '\n');
                vector<Timetable::Row> rows;
                rows.reserve(lines.size());
@@ -67,6 +67,7 @@ void TimetableDialog::on_response(int code)
                {
                        for(vector<string>::const_iterator i=lines.begin(); i!=lines.end(); ++i)
                                rows.push_back(Timetable::Row::parse(*i));
+                       timetable.clear();
                        for(vector<Timetable::Row>::const_iterator i=rows.begin(); i!=rows.end(); ++i)
                                timetable.append(*i);
                }
index cfe2ef6c0d6226eaec15ee2896c096f4372557a2..1d65d0969791461abadd4f02f380496cd466aab1 100644 (file)
@@ -35,10 +35,18 @@ void Timetable::set_enabled(bool e)
        enabled = e;
 }
 
+void Timetable::reset()
+{
+       current_row = 0;
+       wait_timeout = Time::TimeStamp();
+       pending_block = 0;
+       executing = true;
+}
+
 void Timetable::clear()
 {
        rows.clear();
-       current_row = 0;
+       reset();
 }
 
 void Timetable::append(const Row &row)
index 6631f3822c734f2ff99c8a9b28b8e70fd01bc4b5..ec4212e64c459da07895ed4c3958a9a6e67abcd0 100644 (file)
@@ -71,6 +71,7 @@ public:
 
        void set_enabled(bool);
        bool is_enabled() const { return enabled; }
+       void reset();
 
        void clear();
        void append(const Row &);