Changeset - r17355:e67faa335e9c
[Not reviewed]
master
0 4 0
rubidium - 13 years ago 2011-02-19 18:02:17
rubidium@openttd.org
(svn r22111) -Codechange/fix-ish: upon cleaning a pool a destructor should not delete items from other pools
4 files changed with 22 insertions and 2 deletions:
0 comments (0 inline, 0 general)
src/cargopacket.cpp
Show inline comments
 
@@ -155,6 +155,16 @@ CargoList<Tinst>::~CargoList()
 
}
 

	
 
/**
 
 * Empty the cargo list, but don't free the cargo packets;
 
 * the cargo packets are cleaned by CargoPacket's CleanPool.
 
 */
 
template <class Tinst>
 
void CargoList<Tinst>::OnCleanPool()
 
{
 
	this->packets.clear();
 
}
 

	
 
/**
 
 * Update the cached values to reflect the removal of this packet.
 
 * Decreases count and days_in_transit.
 
 * @param cp Packet to be removed from cache.
src/cargopacket.h
Show inline comments
 
@@ -197,6 +197,8 @@ public:
 

	
 
	~CargoList();
 

	
 
	void OnCleanPool();
 

	
 
	/**
 
	 * Returns a pointer to the cargo packet list (so you can iterate over it etc).
 
	 * @return Pointer to the packet list.
src/station.cpp
Show inline comments
 
@@ -70,7 +70,12 @@ Station::Station(TileIndex tile) :
 
 */
 
Station::~Station()
 
{
 
	if (CleaningPool()) return;
 
	if (CleaningPool()) {
 
		for (CargoID c = 0; c < NUM_CARGO; c++) {
 
			this->goods[c].cargo.OnCleanPool();
 
		}
 
		return;
 
	}
 

	
 
	while (!this->loading_vehicles.empty()) {
 
		this->loading_vehicles.front()->LeaveStation();
src/vehicle.cpp
Show inline comments
 
@@ -736,7 +736,10 @@ Vehicle::~Vehicle()
 
{
 
	free(this->name);
 

	
 
	if (CleaningPool()) return;
 
	if (CleaningPool()) {
 
		this->cargo.OnCleanPool();
 
		return;
 
	}
 

	
 
	/* sometimes, eg. for disaster vehicles, when company bankrupts, when removing crashed/flooded vehicles,
 
	 * it may happen that vehicle chain is deleted when visible */
0 comments (0 inline, 0 general)