]> git.tdb.fi Git - r2c2.git/commitdiff
Fix a segfault in removing vehicles when creating a new train
authorMikko Rasa <tdb@tdb.fi>
Sun, 14 Nov 2010 16:39:33 +0000 (16:39 +0000)
committerMikko Rasa <tdb@tdb.fi>
Sun, 14 Nov 2010 16:39:33 +0000 (16:39 +0000)
source/engineer/trainproperties.cpp

index e574925f259628e7846a692a34ee9dd29069e12b..eaddc8bb1c47a38a2ca94c5944deef0592b14773 100644 (file)
@@ -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<unsigned>(selected)>=n_vehicles)
                add_vehicles.erase(add_vehicles.begin()+(selected-n_vehicles));
        else