diff options
author | rubidium <rubidium@openttd.org> | 2007-08-05 21:20:55 +0000 |
---|---|---|
committer | rubidium <rubidium@openttd.org> | 2007-08-05 21:20:55 +0000 |
commit | 83e1fdcb0167c36729889511f7b1165038044c88 (patch) | |
tree | bfe043c51f23052fc39f35769a2ede1e66998148 /src/vehicle.cpp | |
parent | ab5fa3add2f5f2feeb8f48127f6ee5ab69d42f65 (diff) | |
download | openttd-83e1fdcb0167c36729889511f7b1165038044c88.tar.xz |
(svn r10799) -Fix: only calling QuickFree and not the destructor on pool cleanups might cause memory leaks due to the way C++ works.
Diffstat (limited to 'src/vehicle.cpp')
-rw-r--r-- | src/vehicle.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/vehicle.cpp b/src/vehicle.cpp index c845a00b0..78b857c35 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -564,6 +564,8 @@ bool IsEngineCountable(const Vehicle *v) void Vehicle::PreDestructor() { + if (CleaningPool()) return; + if (IsValidStationID(this->last_station_visited)) { GetStation(this->last_station_visited)->loading_vehicles.remove(this); @@ -579,7 +581,6 @@ void Vehicle::PreDestructor() if (this->IsPrimaryVehicle()) DecreaseGroupNumVehicle(this->group_id); } - this->QuickFree(); if (this->type == VEH_ROAD) ClearSlot(this); if (this->type != VEH_TRAIN || (this->type == VEH_TRAIN && (IsFrontEngine(this) || IsFreeWagon(this)))) { @@ -599,6 +600,10 @@ void Vehicle::PreDestructor() Vehicle::~Vehicle() { + DeleteName(this->string_id); + + if (CleaningPool()) return; + UpdateVehiclePosHash(this, INVALID_COORD, 0); this->next_hash = NULL; this->next_new_hash = NULL; @@ -608,11 +613,6 @@ Vehicle::~Vehicle() new (this) InvalidVehicle(); } -void Vehicle::QuickFree() -{ - DeleteName(this->string_id); -} - /** * Deletes all vehicles in a chain. * @param v The first vehicle in the chain. |