fix crash when no active tasks

This commit is contained in:
David Rose 2008-12-24 00:44:55 +00:00
parent 00a3bd8462
commit eccea893f3

View File

@ -1357,19 +1357,21 @@ do_write(ostream &out, int indent_level) const {
} }
} }
sort(tasks.begin(), tasks.end(), AsyncTaskSortPriority());
double now = _manager->_clock->get_frame_time(); double now = _manager->_clock->get_frame_time();
if (!tasks.empty()) {
sort(tasks.begin(), tasks.end(), AsyncTaskSortPriority());
TaskHeap::reverse_iterator ti;
int current_sort = tasks.back()->get_sort() - 1;
// Since AsyncTaskSortPriority() sorts backwards (because of STL's // Since AsyncTaskSortPriority() sorts backwards (because of STL's
// push_heap semantics), we go through the task list in reverse // push_heap semantics), we go through the task list in reverse
// order to print them forwards. // order to print them forwards.
TaskHeap::reverse_iterator ti;
int current_sort = tasks.back()->get_sort() - 1;
for (ti = tasks.rbegin(); ti != tasks.rend(); ++ti) { for (ti = tasks.rbegin(); ti != tasks.rend(); ++ti) {
AsyncTask *task = (*ti); AsyncTask *task = (*ti);
write_task_line(out, indent_level, task, now); write_task_line(out, indent_level, task, now);
} }
}
// Instead of iterating through the _sleeping list in heap order, // Instead of iterating through the _sleeping list in heap order,
// copy it and then use repeated pops to get it out in sorted // copy it and then use repeated pops to get it out in sorted