From: Mikko Rasa Date: Fri, 13 Feb 2015 00:48:03 +0000 (+0200) Subject: Don't segfault if an emergency doesn't have a block X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=f74a48e60ff2e818ada3bbbfcb200e5cd2b633d6;p=r2c2.git Don't segfault if an emergency doesn't have a block --- diff --git a/source/engineer/engineer.cpp b/source/engineer/engineer.cpp index fc93cf6..68533bc 100644 --- a/source/engineer/engineer.cpp +++ b/source/engineer/engineer.cpp @@ -314,10 +314,13 @@ Object *Engineer::pick_object(const Vector &p) void Engineer::emergency(Block *block, const string &msg) { set_status(msg); - TrackChain3D *tch3d = new TrackChain3D(layout_3d, *block); - tch3d->set_color(GL::Color(1.0f, 0.0f, 0.0f)); - tch3d->set_layer(2); - emergencies.push_back(tch3d); + if(block) + { + TrackChain3D *tch3d = new TrackChain3D(layout_3d, *block); + tch3d->set_color(GL::Color(1.0f, 0.0f, 0.0f)); + tch3d->set_layer(2); + emergencies.push_back(tch3d); + } } void Engineer::halt_event(bool h)