summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorfrosch <frosch@openttd.org>2011-03-13 21:31:29 +0000
committerfrosch <frosch@openttd.org>2011-03-13 21:31:29 +0000
commitec9540a12a9170f8b88e1d715c9321edaeeebfd4 (patch)
treecf64959e316864d6bc84aead29e805c902fec8a4 /src
parent0ff6c8f42522f2b440f939baa49c42a14bb8fc85 (diff)
downloadopenttd-ec9540a12a9170f8b88e1d715c9321edaeeebfd4.tar.xz
(svn r22241) -Codechange: Add additional to-be-used parameter to OnInvalidateData().
Diffstat (limited to 'src')
-rw-r--r--src/ai/ai_gui.cpp32
-rw-r--r--src/autoreplace_gui.cpp8
-rw-r--r--src/build_vehicle_gui.cpp8
-rw-r--r--src/company_gui.cpp8
-rw-r--r--src/depot_gui.cpp8
-rw-r--r--src/dock_gui.cpp8
-rw-r--r--src/fios_gui.cpp8
-rw-r--r--src/genworld_gui.cpp8
-rw-r--r--src/graph_gui.cpp38
-rw-r--r--src/group_gui.cpp8
-rw-r--r--src/industry_gui.cpp32
-rw-r--r--src/intro_gui.cpp8
-rw-r--r--src/main_gui.cpp8
-rw-r--r--src/misc_gui.cpp16
-rw-r--r--src/music_gui.cpp16
-rw-r--r--src/network/network_chat_gui.cpp8
-rw-r--r--src/network/network_content_gui.cpp8
-rw-r--r--src/network/network_gui.cpp8
-rw-r--r--src/newgrf_debug_gui.cpp8
-rw-r--r--src/newgrf_gui.cpp15
-rw-r--r--src/news_gui.cpp24
-rw-r--r--src/order_gui.cpp8
-rw-r--r--src/osk_gui.cpp8
-rw-r--r--src/rail_gui.cpp8
-rw-r--r--src/road_gui.cpp8
-rw-r--r--src/settings_gui.cpp16
-rw-r--r--src/signs_gui.cpp8
-rw-r--r--src/smallmap_gui.cpp7
-rw-r--r--src/station_gui.cpp16
-rw-r--r--src/statusbar_gui.cpp8
-rw-r--r--src/subsidy_gui.cpp8
-rw-r--r--src/timetable_gui.cpp8
-rw-r--r--src/toolbar_gui.cpp16
-rw-r--r--src/town_gui.cpp24
-rw-r--r--src/transparency_gui.cpp8
-rw-r--r--src/tree_gui.cpp8
-rw-r--r--src/vehicle_gui.cpp32
-rw-r--r--src/viewport_gui.cpp8
-rw-r--r--src/waypoint_gui.cpp8
-rw-r--r--src/window_gui.h4
40 files changed, 427 insertions, 69 deletions
diff --git a/src/ai/ai_gui.cpp b/src/ai/ai_gui.cpp
index 1bc7ad9de..e16644d4f 100644
--- a/src/ai/ai_gui.cpp
+++ b/src/ai/ai_gui.cpp
@@ -182,8 +182,14 @@ struct AIListWindow : public Window {
nwi->widget_data = (this->vscroll->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
}
- virtual void OnInvalidateData(int data)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
if (_game_mode == GM_NORMAL && Company::IsValidID(this->slot)) {
delete this;
return;
@@ -437,8 +443,14 @@ struct AISettingsWindow : public Window {
}
}
- virtual void OnInvalidateData(int data)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
if (_game_mode == GM_NORMAL && Company::IsValidID(this->slot)) delete this;
}
};
@@ -692,8 +704,14 @@ struct AIConfigWindow : public Window {
}
}
- virtual void OnInvalidateData(int data)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
if (!IsEditable(this->selected_slot)) {
this->selected_slot = INVALID_COMPANY;
}
@@ -1032,8 +1050,14 @@ struct AIDebugWindow : public QueryStringBaseWindow {
return state;
}
- virtual void OnInvalidateData(int data = 0)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
if (data == -1 || ai_debug_company == data) this->SetDirty();
if (data == -2) {
diff --git a/src/autoreplace_gui.cpp b/src/autoreplace_gui.cpp
index 6182953d0..000df7963 100644
--- a/src/autoreplace_gui.cpp
+++ b/src/autoreplace_gui.cpp
@@ -491,8 +491,14 @@ public:
this->GetWidget<NWidgetCore>(RVW_WIDGET_RIGHT_MATRIX)->widget_data = (this->vscroll[0]->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
}
- virtual void OnInvalidateData(int data)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
if (data != 0) {
this->engines[0].ForceRebuild();
} else {
diff --git a/src/build_vehicle_gui.cpp b/src/build_vehicle_gui.cpp
index dd3d8731d..2caa42d9d 100644
--- a/src/build_vehicle_gui.cpp
+++ b/src/build_vehicle_gui.cpp
@@ -1218,8 +1218,14 @@ struct BuildVehicleWindow : Window {
}
}
- virtual void OnInvalidateData(int data)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
/* When switching to original acceleration model for road vehicles, clear the selected sort criteria if it is not available now. */
if (this->vehicle_type == VEH_ROAD &&
_settings_game.vehicle.roadveh_acceleration_model == AM_ORIGINAL &&
diff --git a/src/company_gui.cpp b/src/company_gui.cpp
index 8471ccfe3..7c45f3fed 100644
--- a/src/company_gui.cpp
+++ b/src/company_gui.cpp
@@ -800,8 +800,14 @@ public:
}
}
- virtual void OnInvalidateData(int data = 0)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
this->SetWidgetsDisabledState(true, SCLW_WIDGET_CLASS_RAIL, SCLW_WIDGET_CLASS_ROAD, SCLW_WIDGET_CLASS_SHIP, SCLW_WIDGET_CLASS_AIRCRAFT, WIDGET_LIST_END);
bool current_class_valid = this->livery_class == LC_OTHER;
diff --git a/src/depot_gui.cpp b/src/depot_gui.cpp
index d3866af42..095d67b57 100644
--- a/src/depot_gui.cpp
+++ b/src/depot_gui.cpp
@@ -635,8 +635,14 @@ struct DepotWindow : Window {
}
}
- virtual void OnInvalidateData(int data)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
this->generate_list = true;
}
diff --git a/src/dock_gui.cpp b/src/dock_gui.cpp
index 8e667ec3c..f7c50fc6a 100644
--- a/src/dock_gui.cpp
+++ b/src/dock_gui.cpp
@@ -119,8 +119,14 @@ struct BuildDocksToolbarWindow : Window {
if (_settings_client.gui.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0, false);
}
- void OnInvalidateData(int data = 0)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
this->SetWidgetsDisabledState(!CanBuildVehicleInfrastructure(VEH_SHIP),
DTW_DEPOT,
DTW_STATION,
diff --git a/src/fios_gui.cpp b/src/fios_gui.cpp
index c9bc284f5..c87167882 100644
--- a/src/fios_gui.cpp
+++ b/src/fios_gui.cpp
@@ -659,8 +659,14 @@ public:
this->vscroll->SetCapacityFromWidget(this, SLWW_DRIVES_DIRECTORIES_LIST);
}
- virtual void OnInvalidateData(int data)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
switch (data) {
case 0:
/* Rescan files */
diff --git a/src/genworld_gui.cpp b/src/genworld_gui.cpp
index 5104154d6..fffdb1587 100644
--- a/src/genworld_gui.cpp
+++ b/src/genworld_gui.cpp
@@ -425,8 +425,14 @@ struct GenerateLandscapeWindow : public QueryStringBaseWindow {
}
}
- virtual void OnInvalidateData(int data = 0)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
/* Update the climate buttons */
this->SetWidgetLoweredState(GLAND_TEMPERATE, _settings_newgame.game_creation.landscape == LT_TEMPERATE);
this->SetWidgetLoweredState(GLAND_ARCTIC, _settings_newgame.game_creation.landscape == LT_ARCTIC);
diff --git a/src/graph_gui.cpp b/src/graph_gui.cpp
index 28ccf2bed..6354366b0 100644
--- a/src/graph_gui.cpp
+++ b/src/graph_gui.cpp
@@ -91,8 +91,14 @@ struct GraphLegendWindow : Window {
InvalidateWindowData(WC_COMPANY_VALUE, 0);
}
- virtual void OnInvalidateData(int data)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
if (Company::IsValidID(data)) return;
SetBit(_legend_excluded_companies, data);
@@ -543,8 +549,14 @@ public:
this->UpdateStatistics(false);
}
- virtual void OnInvalidateData(int data)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
this->UpdateStatistics(true);
}
@@ -1013,8 +1025,14 @@ struct PaymentRatesGraphWindow : BaseGraphWindow {
/* Override default OnTick */
}
- virtual void OnInvalidateData(int data)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
this->OnHundredthTick();
}
@@ -1247,8 +1265,14 @@ public:
}
}
- virtual void OnInvalidateData(int data)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
if (data == 0) {
this->companies.ForceRebuild();
} else {
@@ -1488,11 +1512,13 @@ struct PerformanceRatingDetailWindow : Window {
}
/**
- * Invalidate the data of this window.
+ * Some data on this window has become invalid.
* @param data the company ID of the company that is going to be removed
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
*/
- virtual void OnInvalidateData(int data)
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
/* Disable the companies who are not active */
for (CompanyID i = COMPANY_FIRST; i < MAX_COMPANIES; i++) {
this->SetWidgetDisabledState(i + PRW_COMPANY_FIRST, !Company::IsValidID(i));
diff --git a/src/group_gui.cpp b/src/group_gui.cpp
index 6f23af3fb..906b099ec 100644
--- a/src/group_gui.cpp
+++ b/src/group_gui.cpp
@@ -253,8 +253,14 @@ public:
}
}
- virtual void OnInvalidateData(int data)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) 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. */
diff --git a/src/industry_gui.cpp b/src/industry_gui.cpp
index 012d0a39d..bc72f1965 100644
--- a/src/industry_gui.cpp
+++ b/src/industry_gui.cpp
@@ -597,8 +597,14 @@ public:
this->RaiseButtons();
}
- virtual void OnInvalidateData(int data = 0)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
this->SetupArrays();
const IndustrySpec *indsp = (this->selected_type == INVALID_INDUSTRYTYPE) ? NULL : GetIndustrySpec(this->selected_type);
@@ -947,8 +953,14 @@ public:
this->SetDirty();
}
- virtual void OnInvalidateData(int data)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
const Industry *i = Industry::Get(this->window_number);
if (IsProductionAlterable(i)) {
const IndustrySpec *ind = GetIndustrySpec(i->type);
@@ -1346,8 +1358,14 @@ public:
this->BuildSortIndustriesList();
}
- virtual void OnInvalidateData(int data)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) 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. */
@@ -2394,13 +2412,15 @@ struct IndustryCargoesWindow : public Window {
}
/**
- * Notify the window about external events.
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
* - data = 0 .. NUM_INDUSTRYTYPES - 1: Display the chain around the given industry.
* - data = NUM_INDUSTRYTYPES: Stop sending updates to the smallmap window.
- * @param data The event.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
*/
- virtual void OnInvalidateData(int data)
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
if (data == NUM_INDUSTRYTYPES) {
if (this->IsWidgetLowered(ICW_NOTIFY)) {
this->RaiseWidget(ICW_NOTIFY);
diff --git a/src/intro_gui.cpp b/src/intro_gui.cpp
index 8f8458cbb..1f5692d42 100644
--- a/src/intro_gui.cpp
+++ b/src/intro_gui.cpp
@@ -55,8 +55,14 @@ struct SelectGameWindow : public Window {
this->OnInvalidateData();
}
- virtual void OnInvalidateData(int data = 0)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
this->SetWidgetLoweredState(SGI_TEMPERATE_LANDSCAPE, _settings_newgame.game_creation.landscape == LT_TEMPERATE);
this->SetWidgetLoweredState(SGI_ARCTIC_LANDSCAPE, _settings_newgame.game_creation.landscape == LT_ARCTIC);
this->SetWidgetLoweredState(SGI_TROPIC_LANDSCAPE, _settings_newgame.game_creation.landscape == LT_TROPIC);
diff --git a/src/main_gui.cpp b/src/main_gui.cpp
index ed85860da..45f2d7ebb 100644
--- a/src/main_gui.cpp
+++ b/src/main_gui.cpp
@@ -432,8 +432,14 @@ struct MainWindow : Window
}
}
- virtual void OnInvalidateData(int data)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
/* Forward the message to the appropiate toolbar (ingame or scenario editor) */
InvalidateWindowData(WC_MAIN_TOOLBAR, 0, data, true);
}
diff --git a/src/misc_gui.cpp b/src/misc_gui.cpp
index c86f6c6a3..4f97bcbf4 100644
--- a/src/misc_gui.cpp
+++ b/src/misc_gui.cpp
@@ -332,8 +332,14 @@ public:
::ShowNewGRFInspectWindow(GetGrfSpecFeature(this->tile), this->tile);
}
- virtual void OnInvalidateData(int data)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
switch (data) {
case 1:
/* ReInit, "debug" sprite might have changed */
@@ -639,8 +645,14 @@ public:
return pt;
}
- virtual void OnInvalidateData(int data)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
/* If company gets shut down, while displaying an error about it, remove the error message. */
if (this->face != INVALID_COMPANY && !Company::IsValidID(this->face)) delete this;
}
diff --git a/src/music_gui.cpp b/src/music_gui.cpp
index a0cb8ac9b..3a03fb152 100644
--- a/src/music_gui.cpp
+++ b/src/music_gui.cpp
@@ -313,8 +313,14 @@ struct MusicTrackSelectionWindow : public Window {
}
}
- virtual void OnInvalidateData(int data = 0)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
for (int i = 0; i < 6; i++) {
this->SetWidgetLoweredState(MTSW_ALL + i, i == _settings_client.music.playlist);
}
@@ -638,8 +644,14 @@ struct MusicWindow : public Window {
}
}
- virtual void OnInvalidateData(int data = 0)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
for (int i = 0; i < 6; i++) {
this->SetWidgetLoweredState(MW_ALL + i, i == _settings_client.music.playlist);
}
diff --git a/src/network/network_chat_gui.cpp b/src/network/network_chat_gui.cpp
index e610f9cbf..ac7045d8c 100644
--- a/src/network/network_chat_gui.cpp
+++ b/src/network/network_chat_gui.cpp
@@ -531,8 +531,14 @@ struct NetworkChatWindow : public QueryStringBaseWindow {
ShowOnScreenKeyboard(this, wid, NWCW_CLOSE, NWCW_SENDBUTTON);
}
- virtual void OnInvalidateData(int data)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
if (data == this->dest) delete this;
}
};
diff --git a/src/network/network_content_gui.cpp b/src/network/network_content_gui.cpp
index ee3a325d9..13e0b5d59 100644
--- a/src/network/network_content_gui.cpp
+++ b/src/network/network_content_gui.cpp
@@ -751,8 +751,14 @@ public:
this->InvalidateData();
}
- virtual void OnInvalidateData(int data)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
if (this->content.NeedRebuild()) this->BuildContentList();
/* To sum all the bytes we intend to download */
diff --git a/src/network/network_gui.cpp b/src/network/network_gui.cpp
index e62f2bcae..5cb031d01 100644
--- a/src/network/network_gui.cpp
+++ b/src/network/network_gui.cpp
@@ -794,8 +794,14 @@ public:
if (this->field == NGWW_CLIENT) this->HandleEditBox(NGWW_CLIENT);
}
- virtual void OnInvalidateData(int data)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
if (data == 1) {
this->server = NULL;
this->list_pos = SLP_INVALID;
diff --git a/src/newgrf_debug_gui.cpp b/src/newgrf_debug_gui.cpp
index b96ecbd7f..40581b9b2 100644
--- a/src/newgrf_debug_gui.cpp
+++ b/src/newgrf_debug_gui.cpp
@@ -772,8 +772,14 @@ struct SpriteAlignerWindow : Window {
this->SetDirty();
}
- virtual void OnInvalidateData(int data)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
if (data == 1) {
/* Sprite picker finished */
this->RaiseWidget(SAW_PICKER);
diff --git a/src/newgrf_gui.cpp b/src/newgrf_gui.cpp
index 2034ae6ab..a1e45e3cc 100644
--- a/src/newgrf_gui.cpp
+++ b/src/newgrf_gui.cpp
@@ -379,8 +379,14 @@ struct NewGRFParametersWindow : public Window {
nwi->widget_data = (this->vscroll->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
}
- virtual void OnInvalidateData(int data)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
if (!this->action14present) {
this->SetWidgetDisabledState(GRFPAR_WIDGET_NUMPAR_DEC, this->grf_config->num_params == 0);
this->SetWidgetDisabledState(GRFPAR_WIDGET_NUMPAR_INC, this->grf_config->num_params >= this->grf_config->num_valid_params);
@@ -1025,15 +1031,18 @@ struct NewGRFWindow : public QueryStringBaseWindow {
}
/**
- * Calback to update internal data.
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
* - 0: (optionally) build availables, update button status.
* - 1: build availables, Add newly found grfs, update button status.
* - 2: (optionally) build availables, Reset preset, + 3
* - 3: (optionally) build availables, Update active scrollbar, update button status.
* - 4: Force a rebuild of the availables, + 2
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
*/
- virtual void OnInvalidateData(int data = 0)
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
switch (data) {
default: NOT_REACHED();
case 0:
diff --git a/src/news_gui.cpp b/src/news_gui.cpp
index a958e6392..4289285fc 100644
--- a/src/news_gui.cpp
+++ b/src/news_gui.cpp
@@ -498,8 +498,14 @@ struct NewsWindow : Window {
return ES_NOT_HANDLED;
}
- virtual void OnInvalidateData(int data)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
/* The chatbar has notified us that is was either created or closed */
int newtop = this->top + this->chat_height - data;
this->chat_height = data;
@@ -1035,8 +1041,14 @@ struct MessageHistoryWindow : Window {
}
}
- virtual void OnInvalidateData(int data)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
this->vscroll->SetCount(_total_news);
}
@@ -1201,8 +1213,14 @@ struct MessageOptionsWindow : Window {
}
}
- virtual void OnInvalidateData(int data)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
/* Update the dropdown value for 'set all categories'. */
this->GetWidget<NWidgetCore>(WIDGET_NEWSOPT_DROP_SUMMARY)->widget_data = this->message_opt[this->state];
diff --git a/src/order_gui.cpp b/src/order_gui.cpp
index eefeddbfb..f12b104cc 100644
--- a/src/order_gui.cpp
+++ b/src/order_gui.cpp
@@ -805,8 +805,14 @@ public:
}
}
- virtual void OnInvalidateData(int data)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
VehicleOrderID from = INVALID_VEH_ORDER_ID;
VehicleOrderID to = INVALID_VEH_ORDER_ID;
diff --git a/src/osk_gui.cpp b/src/osk_gui.cpp
index 0edb2eea3..cd323b362 100644
--- a/src/osk_gui.cpp
+++ b/src/osk_gui.cpp
@@ -247,8 +247,14 @@ struct OskWindow : public Window {
this->parent->SetWidgetDirty(this->text_btn);
}
- virtual void OnInvalidateData(int)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
this->SetWidgetDirty(OSK_WIDGET_TEXT);
}
};
diff --git a/src/rail_gui.cpp b/src/rail_gui.cpp
index 2b391218b..36576a3ca 100644
--- a/src/rail_gui.cpp
+++ b/src/rail_gui.cpp
@@ -1617,8 +1617,14 @@ public:
this->InvalidateData();
}
- virtual void OnInvalidateData(int data = 0)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
this->LowerWidget((_cur_signal_variant == SIG_ELECTRIC ? BSW_ELECTRIC_NORM : BSW_SEMAPHORE_NORM) + _cur_signal_type);
this->SetWidgetLoweredState(BSW_CONVERT, _convert_signal_button);
diff --git a/src/road_gui.cpp b/src/road_gui.cpp
index 0a9951314..9637240f3 100644
--- a/src/road_gui.cpp
+++ b/src/road_gui.cpp
@@ -341,8 +341,14 @@ struct BuildRoadToolbarWindow : Window {
if (_settings_client.gui.link_terraform_toolbar) DeleteWindowById(WC_SCEN_LAND_GEN, 0, false);
}
- void OnInvalidateData(int data = 0)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
this->SetWidgetsDisabledState(!CanBuildVehicleInfrastructure(VEH_ROAD),
RTW_DEPOT,
RTW_BUS_STATION,
diff --git a/src/settings_gui.cpp b/src/settings_gui.cpp
index 751075a20..0203b7574 100644
--- a/src/settings_gui.cpp
+++ b/src/settings_gui.cpp
@@ -460,8 +460,14 @@ struct GameOptionsWindow : Window {
}
}
- virtual void OnInvalidateData(int data)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
this->SetWidgetLoweredState(GOW_FULLSCREEN_BUTTON, _fullscreen);
bool missing_files = BaseGraphics::GetUsedSet()->GetNumMissing() == 0;
@@ -724,8 +730,14 @@ public:
}
}
- virtual void OnInvalidateData(int data = 0)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
uint i;
const SettingDesc *sd = GetSettingFromName("difficulty.max_no_competitors", &i);
for (i = 0; i < GAME_DIFFICULTY_NUM; i++, sd++) {
diff --git a/src/signs_gui.cpp b/src/signs_gui.cpp
index f3101e99a..d639e1dcc 100644
--- a/src/signs_gui.cpp
+++ b/src/signs_gui.cpp
@@ -367,8 +367,14 @@ struct SignListWindow : QueryStringBaseWindow, SignList {
this->SetDirty();
}
- virtual void OnInvalidateData(int data)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
/* 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.
diff --git a/src/smallmap_gui.cpp b/src/smallmap_gui.cpp
index b7bcd9c20..2fd86623d 100644
--- a/src/smallmap_gui.cpp
+++ b/src/smallmap_gui.cpp
@@ -1423,12 +1423,15 @@ public:
}
/**
- * Notifications for the smallmap window.
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
* - data = 0: Displayed industries at the industry chain window have changed.
* - data = 1: Companies have changed.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
*/
- virtual void OnInvalidateData(int data)
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
switch (data) {
case 1:
/* The owner legend has already been rebuilt. */
diff --git a/src/station_gui.cpp b/src/station_gui.cpp
index fc27ae615..cb40cb37d 100644
--- a/src/station_gui.cpp
+++ b/src/station_gui.cpp
@@ -687,8 +687,14 @@ public:
this->vscroll->SetCapacityFromWidget(this, SLW_LIST, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM);
}
- virtual void OnInvalidateData(int data)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) 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. */
@@ -1451,8 +1457,14 @@ struct SelectStationWindow : Window {
this->vscroll->SetCapacityFromWidget(this, JSW_PANEL, WD_FRAMERECT_TOP + WD_FRAMERECT_BOTTOM);
}
- virtual void OnInvalidateData(int data)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
FindStationsNearby<T>(this->area, true);
this->vscroll->SetCount(_stations_nearby_list.Length() + 1);
this->SetDirty();
diff --git a/src/statusbar_gui.cpp b/src/statusbar_gui.cpp
index 4c1184336..82ffeb239 100644
--- a/src/statusbar_gui.cpp
+++ b/src/statusbar_gui.cpp
@@ -183,8 +183,14 @@ struct StatusBarWindow : Window {
}
}
- virtual void OnInvalidateData(int data)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
switch (data) {
default: NOT_REACHED();
case SBI_SAVELOAD_START: this->saving = true; break;
diff --git a/src/subsidy_gui.cpp b/src/subsidy_gui.cpp
index 0b9182fdd..9e31fb970 100644
--- a/src/subsidy_gui.cpp
+++ b/src/subsidy_gui.cpp
@@ -215,8 +215,14 @@ struct SubsidyListWindow : Window {
this->vscroll->SetCapacityFromWidget(this, SLW_PANEL);
}
- virtual void OnInvalidateData(int data)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
this->vscroll->SetCount(this->CountLines());
}
};
diff --git a/src/timetable_gui.cpp b/src/timetable_gui.cpp
index 4f991323b..51cd82982 100644
--- a/src/timetable_gui.cpp
+++ b/src/timetable_gui.cpp
@@ -243,8 +243,14 @@ struct TimetableWindow : Window {
return (sel < v->GetNumOrders() * 2 && sel >= 0) ? sel : INVALID_ORDER;
}
- virtual void OnInvalidateData(int data)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
switch (data) {
case -666:
/* Autoreplace replaced the vehicle */
diff --git a/src/toolbar_gui.cpp b/src/toolbar_gui.cpp
index e57b2f101..711b73846 100644
--- a/src/toolbar_gui.cpp
+++ b/src/toolbar_gui.cpp
@@ -1482,8 +1482,14 @@ struct MainToolbarWindow : Window {
}
}
- virtual void OnInvalidateData(int data)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
if (FindWindowById(WC_MAIN_WINDOW, 0) != NULL) HandleZoomMessage(this, FindWindowById(WC_MAIN_WINDOW, 0)->viewport, TBN_ZOOMIN, TBN_ZOOMOUT);
}
@@ -1792,8 +1798,14 @@ struct ScenarioEditorToolbarWindow : Window {
}
}
- virtual void OnInvalidateData(int data)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
if (FindWindowById(WC_MAIN_WINDOW, 0) != NULL) HandleZoomMessage(this, FindWindowById(WC_MAIN_WINDOW, 0)->viewport, TBSE_ZOOMIN, TBSE_ZOOMOUT);
}
diff --git a/src/town_gui.cpp b/src/town_gui.cpp
index cbcb43f20..016399e70 100644
--- a/src/town_gui.cpp
+++ b/src/town_gui.cpp
@@ -523,8 +523,14 @@ public:
}
}
- virtual void OnInvalidateData(int data = 0)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
/* Called when setting station noise or required cargos have changed, in order to resize the window */
this->SetDirty(); // refresh display for current size. This will allow to avoid glitches when downgrading
this->ResizeWindowAsNeeded();
@@ -863,8 +869,14 @@ public:
this->vscroll->SetCapacityFromWidget(this, TDW_CENTERTOWN);
}
- virtual void OnInvalidateData(int data)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) 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. */
@@ -1165,8 +1177,14 @@ public:
this->UpdateButtons(false);
}
- virtual void OnInvalidateData(int)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
this->UpdateButtons(true);
}
};
diff --git a/src/transparency_gui.cpp b/src/transparency_gui.cpp
index cc8c399f6..cf1979e38 100644
--- a/src/transparency_gui.cpp
+++ b/src/transparency_gui.cpp
@@ -125,8 +125,14 @@ public:
return pt;
}
- virtual void OnInvalidateData(int data)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
for (uint i = TTW_WIDGET_BEGIN; i < TTW_WIDGET_END; i++) {
this->SetWidgetLoweredState(i, IsTransparencySet((TransparencyOption)(i - TTW_WIDGET_BEGIN)));
}
diff --git a/src/tree_gui.cpp b/src/tree_gui.cpp
index ebbd2d189..8623a3ff5 100644
--- a/src/tree_gui.cpp
+++ b/src/tree_gui.cpp
@@ -144,8 +144,14 @@ public:
}
}
- virtual void OnInvalidateData(int data = 0)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
this->base = _tree_base_by_landscape[_settings_game.game_creation.landscape];
this->count = _tree_count_by_landscape[_settings_game.game_creation.landscape];
}
diff --git a/src/vehicle_gui.cpp b/src/vehicle_gui.cpp
index f8ff6d5c1..26b8666a3 100644
--- a/src/vehicle_gui.cpp
+++ b/src/vehicle_gui.cpp
@@ -683,8 +683,14 @@ struct RefitWindow : public Window {
}
}
- virtual void OnInvalidateData(int data)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
switch (data) {
case -666:
/* Autoreplace replaced the vehicle.
@@ -1600,8 +1606,14 @@ public:
this->GetWidget<NWidgetCore>(VLW_WIDGET_LIST)->widget_data = (this->vscroll->GetCapacity() << MAT_ROW_START) + (1 << MAT_COL_START);
}
- virtual void OnInvalidateData(int data)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
if (HasBit(data, 31) && this->vli.type == VL_SHARED_ORDERS) {
this->vli.index = GB(data, 0, 20);
this->window_number = this->vli.Pack();
@@ -1787,8 +1799,14 @@ struct VehicleDetailsWindow : Window {
this->tab = TDW_TAB_CARGO;
}
- virtual void OnInvalidateData(int data)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
if (data == -666) {
/* Autoreplace replaced the vehicle.
* Nothing to do for this window though.
@@ -2596,8 +2614,14 @@ public:
}
}
- virtual void OnInvalidateData(int data)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
if (data == -666) {
/* Autoreplace replaced the vehicle.
* Nothing to do for this window though.
diff --git a/src/viewport_gui.cpp b/src/viewport_gui.cpp
index 1a85311b6..103b27cb2 100644
--- a/src/viewport_gui.cpp
+++ b/src/viewport_gui.cpp
@@ -148,8 +148,14 @@ public:
}
}
- virtual void OnInvalidateData(int data = 0)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
/* Only handle zoom message if intended for us (msg ZOOM_IN/ZOOM_OUT) */
HandleZoomMessage(this, this->viewport, EVW_ZOOMIN, EVW_ZOOMOUT);
}
diff --git a/src/waypoint_gui.cpp b/src/waypoint_gui.cpp
index 23c9781e3..af126f3ae 100644
--- a/src/waypoint_gui.cpp
+++ b/src/waypoint_gui.cpp
@@ -114,8 +114,14 @@ public:
}
}
- virtual void OnInvalidateData(int data)
+ /**
+ * Some data on this window has become invalid.
+ * @param data Information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
+ */
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true)
{
+ if (!gui_scope) return;
/* You can only change your own waypoints */
this->SetWidgetDisabledState(WAYPVW_RENAME, !this->wp->IsInUse() || (this->wp->owner != _local_company && this->wp->owner != OWNER_NONE));
/* Disable the widget for waypoints with no use */
diff --git a/src/window_gui.h b/src/window_gui.h
index 3254ee8c4..fc5ebeeda 100644
--- a/src/window_gui.h
+++ b/src/window_gui.h
@@ -651,9 +651,9 @@ public:
/**
* Some data on this window has become invalid.
* @param data information about the changed data.
+ * @param gui_scope Whether the call is done from GUI scope. You may not do everything when not in GUI scope. See #InvalidateWindowData() for details.
*/
- virtual void OnInvalidateData(int data = 0) {}
-
+ virtual void OnInvalidateData(int data = 0, bool gui_scope = true) {}
/**
* The user clicked some place on the map when a tile highlight mode