From 32778748308168a82af100bba6b3bd6699f7aa7f Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 7 May 2007 01:52:19 +0000 Subject: Fixed assert crash bug. git-svn-id: http://svn.drobilla.net/lad/machina@515 a436a847-0d15-0410-975c-d299462d15a1 --- src/engine/JackDriver.cpp | 2 +- src/engine/Machine.cpp | 15 ++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/src/engine/JackDriver.cpp b/src/engine/JackDriver.cpp index 32439c8..f45ccc6 100644 --- a/src/engine/JackDriver.cpp +++ b/src/engine/JackDriver.cpp @@ -269,7 +269,7 @@ JackDriver::on_process(jack_nframes_t nframes) const TickCount run_dur_ticks = _cycle_time.beats_to_ticks(run_dur_beats); // Machine didn't run at all (empty, or no initial states) - if (run_dur_ticks == 0) { + if (run_dur_beats == 0) { machine->reset(); // Try again next cycle _cycle_time.set_start(0); return; diff --git a/src/engine/Machine.cpp b/src/engine/Machine.cpp index 815ba5b..61cad67 100644 --- a/src/engine/Machine.cpp +++ b/src/engine/Machine.cpp @@ -78,6 +78,10 @@ Machine::remove_node(SharedPtr node) void Machine::reset() { + for (size_t i=0; i < MAX_ACTIVE_NODES; ++i) { + _active_nodes[i].reset(); + } + if (!_is_finished) { for (Nodes::const_iterator n = _nodes.begin(); n != _nodes.end(); ++n) { const SharedPtr node = (*n); @@ -88,10 +92,6 @@ Machine::reset() assert(! node->is_active()); } } - - for (size_t i=0; i < MAX_ACTIVE_NODES; ++i) { - _active_nodes[i].reset(); - } _time = 0; _is_finished = false; @@ -234,7 +234,8 @@ Machine::run(const Raul::TimeSlice& time) if ( ! _nodes.empty()) { for (Nodes::const_iterator n = _nodes.begin(); n != _nodes.end(); ++n) { - assert( ! (*n)->is_active()); + if ((*n)->is_active()) + (*n)->exit(sink, 0); if ((*n)->is_initial()) { if (enter_node(sink, (*n))) @@ -257,6 +258,10 @@ Machine::run(const Raul::TimeSlice& time) // No more active states, machine is finished if (!earliest) { +#ifndef NDEBUG + for (Nodes::const_iterator n = _nodes.begin(); n != _nodes.end(); ++n) + assert( ! (*n)->is_active()); +#endif _is_finished = true; break; -- cgit v1.2.1