mirror of https://github.com/OpenTTD/OpenTTD
(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.
parent
b997ebb942
commit
77d1dcb926
|
@ -255,6 +255,9 @@ public:
|
||||||
|
|
||||||
virtual void OnInvalidateData(int data)
|
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) {
|
if (data == 0) {
|
||||||
this->vehicles.ForceRebuild();
|
this->vehicles.ForceRebuild();
|
||||||
this->groups.ForceRebuild();
|
this->groups.ForceRebuild();
|
||||||
|
|
|
@ -1334,6 +1334,12 @@ public:
|
||||||
this->vscroll->SetCapacityFromWidget(this, IDW_INDUSTRY_LIST);
|
this->vscroll->SetCapacityFromWidget(this, IDW_INDUSTRY_LIST);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void OnPaint()
|
||||||
|
{
|
||||||
|
if (this->industries.NeedRebuild()) this->BuildSortIndustriesList();
|
||||||
|
this->DrawWidgets();
|
||||||
|
}
|
||||||
|
|
||||||
virtual void OnHundredthTick()
|
virtual void OnHundredthTick()
|
||||||
{
|
{
|
||||||
this->industries.ForceResort();
|
this->industries.ForceResort();
|
||||||
|
@ -1342,12 +1348,14 @@ public:
|
||||||
|
|
||||||
virtual void OnInvalidateData(int data)
|
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) {
|
if (data == 0) {
|
||||||
this->industries.ForceRebuild();
|
this->industries.ForceRebuild();
|
||||||
} else {
|
} else {
|
||||||
this->industries.ForceResort();
|
this->industries.ForceResort();
|
||||||
}
|
}
|
||||||
this->BuildSortIndustriesList();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -164,9 +164,7 @@ struct SignListWindow : QueryStringBaseWindow, SignList {
|
||||||
/* Create initial list. */
|
/* Create initial list. */
|
||||||
this->signs.ForceRebuild();
|
this->signs.ForceRebuild();
|
||||||
this->signs.ForceResort();
|
this->signs.ForceResort();
|
||||||
this->BuildSignsList();
|
this->BuildSortSignList();
|
||||||
this->SortSignsList();
|
|
||||||
this->vscroll->SetCount(this->signs.Length());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -214,6 +212,7 @@ struct SignListWindow : QueryStringBaseWindow, SignList {
|
||||||
|
|
||||||
virtual void OnPaint()
|
virtual void OnPaint()
|
||||||
{
|
{
|
||||||
|
if (this->signs.NeedRebuild()) this->BuildSortSignList();
|
||||||
this->DrawWidgets();
|
this->DrawWidgets();
|
||||||
if (!this->IsShaded()) this->DrawEditBox(SLW_FILTER_TEXT);
|
if (!this->IsShaded()) this->DrawEditBox(SLW_FILTER_TEXT);
|
||||||
}
|
}
|
||||||
|
@ -352,23 +351,36 @@ struct SignListWindow : QueryStringBaseWindow, SignList {
|
||||||
this->HandleEditBox(SLW_FILTER_TEXT);
|
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)
|
virtual void OnInvalidateData(int data)
|
||||||
{
|
{
|
||||||
/* When there is a filter string, we always need to rebuild the list even if
|
/* 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
|
* the amount of signs in total is unchanged, as the subset of signs that is
|
||||||
* accepted by the filter might has changed.
|
* 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
|
if (data == 0 || !StrEmpty(this->filter_string)) { // New or deleted sign, or there is a filter string
|
||||||
this->signs.ForceRebuild();
|
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
|
} else { // Change of sign contents while there is no filter string
|
||||||
this->signs.ForceResort();
|
this->signs.ForceResort();
|
||||||
}
|
}
|
||||||
|
|
||||||
this->SortSignsList();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static Hotkey<SignListWindow> signlist_hotkeys[];
|
static Hotkey<SignListWindow> signlist_hotkeys[];
|
||||||
|
|
|
@ -689,6 +689,9 @@ public:
|
||||||
|
|
||||||
virtual void OnInvalidateData(int data)
|
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) {
|
if (data == 0) {
|
||||||
this->stations.ForceRebuild();
|
this->stations.ForceRebuild();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -846,6 +846,12 @@ public:
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
virtual void OnPaint()
|
||||||
|
{
|
||||||
|
if (this->towns.NeedRebuild()) this->BuildSortTownList();
|
||||||
|
this->DrawWidgets();
|
||||||
|
}
|
||||||
|
|
||||||
virtual void OnHundredthTick()
|
virtual void OnHundredthTick()
|
||||||
{
|
{
|
||||||
this->BuildSortTownList();
|
this->BuildSortTownList();
|
||||||
|
@ -859,12 +865,14 @@ public:
|
||||||
|
|
||||||
virtual void OnInvalidateData(int data)
|
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) {
|
if (data == 0) {
|
||||||
this->towns.ForceRebuild();
|
this->towns.ForceRebuild();
|
||||||
} else {
|
} else {
|
||||||
this->towns.ForceResort();
|
this->towns.ForceResort();
|
||||||
}
|
}
|
||||||
this->BuildSortTownList();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1609,6 +1609,9 @@ public:
|
||||||
return;
|
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) {
|
if (data == 0) {
|
||||||
this->vehicles.ForceRebuild();
|
this->vehicles.ForceRebuild();
|
||||||
} else {
|
} else {
|
||||||
|
|
Loading…
Reference in New Issue