From e2ecc5a6e8e8056cd09599e60140498f322b87b6 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Mon, 26 Apr 2010 09:09:21 +0000 Subject: [PATCH] Don't clear timetable before all rows are successfully parsed Do a more complete reset of timetable state when clearing Also reset timetable state when toggling enabled state --- source/engineer/timetabledialog.cpp | 3 ++- source/libmarklin/timetable.cpp | 10 +++++++++- source/libmarklin/timetable.h | 1 + 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/source/engineer/timetabledialog.cpp b/source/engineer/timetabledialog.cpp index 978b14b..fcb06f8 100644 --- a/source/engineer/timetabledialog.cpp +++ b/source/engineer/timetabledialog.cpp @@ -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 lines = split(ent_timetable->get_text(), '\n'); vector rows; rows.reserve(lines.size()); @@ -67,6 +67,7 @@ void TimetableDialog::on_response(int code) { for(vector::const_iterator i=lines.begin(); i!=lines.end(); ++i) rows.push_back(Timetable::Row::parse(*i)); + timetable.clear(); for(vector::const_iterator i=rows.begin(); i!=rows.end(); ++i) timetable.append(*i); } diff --git a/source/libmarklin/timetable.cpp b/source/libmarklin/timetable.cpp index cfe2ef6..1d65d09 100644 --- a/source/libmarklin/timetable.cpp +++ b/source/libmarklin/timetable.cpp @@ -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) diff --git a/source/libmarklin/timetable.h b/source/libmarklin/timetable.h index 6631f38..ec4212e 100644 --- a/source/libmarklin/timetable.h +++ b/source/libmarklin/timetable.h @@ -71,6 +71,7 @@ public: void set_enabled(bool); bool is_enabled() const { return enabled; } + void reset(); void clear(); void append(const Row &); -- 2.45.2