Linkgraph: Avoid attempting to merge/apply job when cleaning schedule.

This can cause crashes when switching savegame.
Move job merge/apply out of destructor into separate function.
This commit is contained in:
Jonathan G Rennison
2016-11-26 00:15:01 +00:00
parent e1a841aa05
commit d08d1cbd67
3 changed files with 11 additions and 5 deletions

View File

@@ -129,7 +129,8 @@ void LinkGraphSchedule::JoinNext()
std::unique_ptr<LinkGraphJob> next = std::move(this->running.front());
this->running.pop_front();
LinkGraphID id = next->LinkGraphIndex();
next.reset(); // implicitly joins the thread
next->FinaliseJob(); // joins the thread and finalises the job
next.reset();
if (LinkGraph::IsValidID(id)) {
LinkGraph *lg = LinkGraph::Get(id);
this->Unqueue(lg); // Unqueue to avoid double-queueing recycled IDs.