diff --git a/kstars/ekos/scheduler/scheduler.cpp b/kstars/ekos/scheduler/scheduler.cpp --- a/kstars/ekos/scheduler/scheduler.cpp +++ b/kstars/ekos/scheduler/scheduler.cpp @@ -1436,17 +1436,20 @@ updatePreDawn(); - /* If there jobs left to run in the filtered list, check reschedule */ + /* Remove complete and invalid jobs that could have appeared during the last evaluation */ + sortedJobs.erase(std::remove_if(sortedJobs.begin(), sortedJobs.end(),[](SchedulerJob* job) + { return SchedulerJob::JOB_ABORTED < job->getState(); }), sortedJobs.end()); + + /* If there are no jobs left to run in the filtered list, shutdown scheduler */ if (sortedJobs.isEmpty()) { if (startupState == STARTUP_COMPLETE) { appendLogText(i18n("No jobs left in the scheduler queue, starting shutdown procedure...")); // Let's start shutdown procedure checkShutdownState(); } - else - stop(); + else stop(); return; }