mirror of
https://github.com/OpenRCT2/OpenRCT2
synced 2026-01-21 22:13:07 +01:00
Fix: Crash on opening scenery window after removing tabs
The crash occurred because gWindowSceneryTabSelections did not get cleared when the window is not open, yet this is a global variable that needs clearing. The function that handles this (WindowSceneryResetSelectedSceneryItems) gets called with the `INTENT_ACTION_REFRESH_SCENERY` intent.
This commit is contained in:
@@ -730,12 +730,6 @@ public:
|
||||
OnMouseDown(WIDX_SCENERY_TAB_1 + tabId);
|
||||
}
|
||||
|
||||
// Used after removing objects, in order to avoid crashes.
|
||||
void ResetSelectedSceneryItems()
|
||||
{
|
||||
gWindowSceneryTabSelections.clear();
|
||||
}
|
||||
|
||||
void Init()
|
||||
{
|
||||
_tabEntries.clear();
|
||||
@@ -1383,11 +1377,8 @@ void WindowScenerySetSelectedTab(const ObjectEntryIndex sceneryGroupIndex)
|
||||
// Used after removing objects, in order to avoid crashes.
|
||||
void WindowSceneryResetSelectedSceneryItems()
|
||||
{
|
||||
auto* w = static_cast<SceneryWindow*>(window_find_by_class(WC_SCENERY));
|
||||
if (w != nullptr)
|
||||
{
|
||||
w->ResetSelectedSceneryItems();
|
||||
}
|
||||
gWindowSceneryTabSelections.clear();
|
||||
gWindowSceneryActiveTabIndex = 0;
|
||||
}
|
||||
|
||||
void WindowScenerySetDefaultPlacementConfiguration()
|
||||
@@ -1397,8 +1388,7 @@ void WindowScenerySetDefaultPlacementConfiguration()
|
||||
gWindowScenerySecondaryColour = COLOUR_YELLOW;
|
||||
gWindowSceneryTertiaryColour = COLOUR_DARK_BROWN;
|
||||
|
||||
gWindowSceneryTabSelections.clear();
|
||||
gWindowSceneryActiveTabIndex = 0;
|
||||
WindowSceneryResetSelectedSceneryItems();
|
||||
}
|
||||
|
||||
void WindowSceneryInit()
|
||||
|
||||
Reference in New Issue
Block a user