changeset 14149:c1109b4a2d8a draft

(svn r18697) -Fix [FS#3471]: crash when scrolling to an item removed by filtering in the 'add NewGRF window'
author rubidium <rubidium@openttd.org>
date Sun, 03 Jan 2010 15:25:51 +0000
parents 6b64f6a6535e
children 90cc587db2f1
files src/newgrf_gui.cpp
diffstat 1 files changed, 6 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/newgrf_gui.cpp
+++ b/src/newgrf_gui.cpp
@@ -216,7 +216,12 @@
 	void SortGrfList()
 	{
 		if (!this->grfs.Sort()) return;
+		this->UpdateListPosition();
+	}
 
+	/** Update selection position. */
+	void UpdateListPosition()
+	{
 		/* update list position */
 		if (this->sel != NULL) {
 			this->sel_pos = this->grfs.FindIndex(this->sel);
@@ -239,6 +244,7 @@
 	void FilterGrfList()
 	{
 		if (!this->grfs.Filter(this->edit_str_buf)) return;
+		this->UpdateListPosition();
 	}
 
 	/** Make sure that the currently selected grf is within the visible part of the list */