In the unlikely event that the thread doesn't terminate fast enough after
setting the goal pointer, deleting it would send it a kill signal.
Remove this possibility by explicitly jouning the thread.
TrainRoutePlanner::~TrainRoutePlanner()
{
- delete thread;
+ if(thread)
+ {
+ thread->join();
+ delete thread;
+ }
}
TrainRoutePlanner::Result TrainRoutePlanner::plan()
{
if(result==PENDING && goal)
{
+ if(thread)
+ {
+ thread->join();
+ delete thread;
+ thread = 0;
+ }
finalize_plan();
- delete thread;
- thread = 0;
}
return result;