From: Mikko Rasa Date: Sun, 14 Nov 2010 16:39:33 +0000 (+0000) Subject: Fix a segfault in removing vehicles when creating a new train X-Git-Url: http://git.tdb.fi/?a=commitdiff_plain;h=6ac4610e9a94f7415b8f01a653242b570057a02b;p=r2c2.git Fix a segfault in removing vehicles when creating a new train --- diff --git a/source/engineer/trainproperties.cpp b/source/engineer/trainproperties.cpp index e574925..eaddc8b 100644 --- a/source/engineer/trainproperties.cpp +++ b/source/engineer/trainproperties.cpp @@ -151,7 +151,7 @@ void TrainProperties::remove_vehicle_clicked() lst_vehicles->remove(selected); - unsigned n_vehicles = train->get_n_vehicles()-rem_vehicles.size(); + unsigned n_vehicles = (train ? train->get_n_vehicles()-rem_vehicles.size() : 0); if(static_cast(selected)>=n_vehicles) add_vehicles.erase(add_vehicles.begin()+(selected-n_vehicles)); else