summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2011-03-08 20:52:59 +0000
committerfrosch <frosch@openttd.org>2011-03-08 20:52:59 +0000
commit77d1dcb92633b2bd8ce9c878f75b1e9363324983 (patch)
tree5ebc7be52bfc90174a44de3cf7879b386b3cc6c1 /src
parentb997ebb94292972f445bd11678ae7768618e0299 (diff)
downloadopenttd-77d1dcb92633b2bd8ce9c878f75b1e9363324983.tar.xz
(svn r22228) -Fix (r22135)[FS#4546]: Do not resort town, industry and signs list directly in OnInvalidateData(). There might be a scheduled rebuild which needs execution first. So, only set a trigger for resorting.
Diffstat (limited to 'src')
-rw-r--r--src/group_gui.cpp3
-rw-r--r--src/industry_gui.cpp10
-rw-r--r--src/signs_gui.cpp30
-rw-r--r--src/station_gui.cpp3
-rw-r--r--src/town_gui.cpp10
-rw-r--r--src/vehicle_gui.cpp3
6 files changed, 48 insertions, 11 deletions
diff --git a/src/group_gui.cpp b/src/group_gui.cpp
index 1c1453bcf..6f23af3fb 100644
--- a/src/group_gui.cpp
+++ b/src/group_gui.cpp
@@ -255,6 +255,9 @@ public:
virtual void OnInvalidateData(int data)
{
+ /* We can only set the trigger for resorting/rebuilding.
+ * We cannot safely resort at this point, as there might be multiple scheduled invalidations,
+ * and a rebuild needs to be done first though it is scheduled later. */
if (data == 0) {
this->vehicles.ForceRebuild();
this->groups.ForceRebuild();
diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp
index f3e2c2b1c..012d0a39d 100644
--- a/src/industry_gui.cpp
+++ b/src/industry_gui.cpp
@@ -1334,6 +1334,12 @@ public:
this->vscroll->SetCapacityFromWidget(this, IDW_INDUSTRY_LIST);
}
+ virtual void OnPaint()
+ {
+ if (this->industries.NeedRebuild()) this->BuildSortIndustriesList();
+ this->DrawWidgets();
+ }
+
virtual void OnHundredthTick()
{
this->industries.ForceResort();
@@ -1342,12 +1348,14 @@ public:
virtual void OnInvalidateData(int data)
{
+ /* We can only set the trigger for resorting/rebuilding.
+ * We cannot safely resort at this point, as there might be multiple scheduled invalidations,
+ * and a rebuild needs to be done first though it is scheduled later. */
if (data == 0) {
this->industries.ForceRebuild();
} else {
this->industries.ForceResort();
}
- this->BuildSortIndustriesList();
}
};
diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp
index 7cdc1151c..f3101e99a 100644
--- a/src/signs_gui.cpp
+++ b/src/signs_gui.cpp
@@ -164,9 +164,7 @@ struct SignListWindow : QueryStringBaseWindow, SignList {
/* Create initial list. */
this->signs.ForceRebuild();
this->signs.ForceResort();
- this->BuildSignsList();
- this->SortSignsList();
- this->vscroll->SetCount(this->signs.Length());
+ this->BuildSortSignList();
}
/**
@@ -214,6 +212,7 @@ struct SignListWindow : QueryStringBaseWindow, SignList {
virtual void OnPaint()
{
+ if (this->signs.NeedRebuild()) this->BuildSortSignList();
this->DrawWidgets();
if (!this->IsShaded()) this->DrawEditBox(SLW_FILTER_TEXT);
}
@@ -352,23 +351,36 @@ struct SignListWindow : QueryStringBaseWindow, SignList {
this->HandleEditBox(SLW_FILTER_TEXT);
}
+ void BuildSortSignList()
+ {
+ if (this->signs.NeedRebuild()) {
+ this->BuildSignsList();
+ this->vscroll->SetCount(this->signs.Length());
+ this->SetWidgetDirty(SLW_CAPTION);
+ }
+ this->SortSignsList();
+ }
+
+ virtual void OnHundredthTick()
+ {
+ this->BuildSortSignList();
+ this->SetDirty();
+ }
virtual void OnInvalidateData(int data)
{
/* When there is a filter string, we always need to rebuild the list even if
* the amount of signs in total is unchanged, as the subset of signs that is
* accepted by the filter might has changed.
- */
+ *
+ * We can only set the trigger for resorting/rebuilding.
+ * We cannot safely resort at this point, as there might be multiple scheduled invalidations,
+ * and a rebuild needs to be done first though it is scheduled later. */
if (data == 0 || !StrEmpty(this->filter_string)) { // New or deleted sign, or there is a filter string
this->signs.ForceRebuild();
- this->BuildSignsList();
- this->SetWidgetDirty(SLW_CAPTION);
- this->vscroll->SetCount(this->signs.Length());
} else { // Change of sign contents while there is no filter string
this->signs.ForceResort();
}
-
- this->SortSignsList();
}
static Hotkey<SignListWindow> signlist_hotkeys[];
diff --git a/src/station_gui.cpp b/src/station_gui.cpp
index 433ab12bb..fc27ae615 100644
--- a/src/station_gui.cpp
+++ b/src/station_gui.cpp
@@ -689,6 +689,9 @@ public:
virtual void OnInvalidateData(int data)
{
+ /* We can only set the trigger for resorting/rebuilding.
+ * We cannot safely resort at this point, as there might be multiple scheduled invalidations,
+ * and a rebuild needs to be done first though it is scheduled later. */
if (data == 0) {
this->stations.ForceRebuild();
} else {
diff --git a/src/town_gui.cpp b/src/town_gui.cpp
index fce2a8ce6..cbcb43f20 100644
--- a/src/town_gui.cpp
+++ b/src/town_gui.cpp
@@ -846,6 +846,12 @@ public:
}
}
+ virtual void OnPaint()
+ {
+ if (this->towns.NeedRebuild()) this->BuildSortTownList();
+ this->DrawWidgets();
+ }
+
virtual void OnHundredthTick()
{
this->BuildSortTownList();
@@ -859,12 +865,14 @@ public:
virtual void OnInvalidateData(int data)
{
+ /* We can only set the trigger for resorting/rebuilding.
+ * We cannot safely resort at this point, as there might be multiple scheduled invalidations,
+ * and a rebuild needs to be done first though it is scheduled later. */
if (data == 0) {
this->towns.ForceRebuild();
} else {
this->towns.ForceResort();
}
- this->BuildSortTownList();
}
};
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index d8a69c04e..f8ff6d5c1 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -1609,6 +1609,9 @@ public:
return;
}
+ /* We can only set the trigger for resorting/rebuilding.
+ * We cannot safely resort at this point, as there might be multiple scheduled invalidations,
+ * and a rebuild needs to be done first though it is scheduled later. */
if (data == 0) {
this->vehicles.ForceRebuild();
} else {