From f74a48e60ff2e818ada3bbbfcb200e5cd2b633d6 Mon Sep 17 00:00:00 2001 From: Mikko Rasa Date: Fri, 13 Feb 2015 02:48:03 +0200 Subject: [PATCH] Don't segfault if an emergency doesn't have a block --- source/engineer/engineer.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) 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) -- 2.45.2