changeset 12325:a35a11685f0c draft

(svn r16745) -Fix [FS#3011]: invalidate JoinStation window after removing item from the pool
author smatz <smatz@openttd.org>
date Sun, 05 Jul 2009 13:20:05 +0000
parents 124e9247dd35
children c926b98c339d
files src/core/pool_func.hpp src/core/pool_type.hpp src/station.cpp src/station_base.h
diffstat 4 files changed, 22 insertions(+), 2 deletions(-) [+]
line wrap: on
line diff
--- a/src/core/pool_func.hpp
+++ b/src/core/pool_func.hpp
@@ -108,6 +108,7 @@
 	this->data[index] = NULL;
 	this->first_free = min(this->first_free, index);
 	this->items--;
+	if (!this->cleaning) Titem::PostDestructor(index);
 }
 
 DEFINE_POOL_METHOD(void)::CleanPool()
--- a/src/core/pool_type.hpp
+++ b/src/core/pool_type.hpp
@@ -221,6 +221,15 @@
 		{
 			return Tpool->items;
 		}
+
+		/**
+		 * Dummy function called after destructor of each member.
+		 * If you want to use it, override it in PoolItem's subclass.
+		 * @param index index of deleted item
+		 * @note when this function is called, PoolItem::Get(index) == NULL.
+		 * @note it's called only when !CleaningPool()
+		 */
+		static FORCEINLINE void PostDestructor(size_t index) { }
 	};
 
 private:
--- a/src/station.cpp
+++ b/src/station.cpp
@@ -94,8 +94,6 @@
 	/* Remove all news items */
 	DeleteStationNews(this->index);
 
-	InvalidateWindowData(WC_SELECT_STATION, 0, 0);
-
 	for (CargoID c = 0; c < NUM_CARGO; c++) {
 		goods[c].cargo.Truncate(0);
 	}
@@ -109,6 +107,16 @@
 
 
 /**
+ * Invalidating of the JoinStation window has to be done
+ * after removing item from the pool.
+ * @param index index of deleted item
+ */
+void Station::PostDestructor(size_t index)
+{
+	InvalidateWindowData(WC_SELECT_STATION, 0, 0);
+}
+
+/**
  * Get the primary road stop (the first road stop) that the given vehicle can load/unload.
  * @param v the vehicle to get the first road stop for
  * @return the first roadstop that this vehicle can load at
--- a/src/station_base.h
+++ b/src/station_base.h
@@ -186,6 +186,8 @@
 	{
 		return Station::Get(GetStationIndex(tile));
 	}
+
+	static void PostDestructor(size_t index);
 };
 
 #define FOR_ALL_STATIONS_FROM(var, start) FOR_ALL_ITEMS_FROM(Station, station_index, var, start)