X-Git-Url: http://git.tdb.fi/?a=blobdiff_plain;f=source%2Flibr2c2%2Ftrainrouteplanner.cpp;h=9e74eca1c7b1b2c0c18846d586cf86a774c363a1;hb=ee92bee98fa084645b17f65cebe4eabf70e4dee9;hp=0d0103cb3f4ef274cd1ea4544d2557f87a9fa8c5;hpb=5c3d55f48318bb16865012c13619990004747090;p=r2c2.git diff --git a/source/libr2c2/trainrouteplanner.cpp b/source/libr2c2/trainrouteplanner.cpp index 0d0103c..9e74eca 100644 --- a/source/libr2c2/trainrouteplanner.cpp +++ b/source/libr2c2/trainrouteplanner.cpp @@ -29,7 +29,11 @@ TrainRoutePlanner::TrainRoutePlanner(Layout &layout): TrainRoutePlanner::~TrainRoutePlanner() { - delete thread; + if(thread) + { + thread->join(); + delete thread; + } } TrainRoutePlanner::Result TrainRoutePlanner::plan() @@ -55,9 +59,13 @@ TrainRoutePlanner::Result TrainRoutePlanner::check() { if(result==PENDING && goal) { + if(thread) + { + thread->join(); + delete thread; + thread = 0; + } finalize_plan(); - delete thread; - thread = 0; } return result;