Description
In order to stop widgets sharing state from multiple windows of the same type we have to copy the widget definition and not assign a pointer. However before we change the pointer into a vector, so that each window will have a copy of the widget we have to first ensure the access to the data is correct.
There is some code the needs corrections, any code that directly accesses the definition rather than what is assigned to the windows has to be changed.
Example:
The variable widgets is assigned here:
Access to the static can be seen here:
OpenRCT2/src/openrct2-ui/windows/CustomCurrency.cpp
Lines 211 to 223 in 4b25980
Instead of accessing window_custom_currency_widgets
it should access the data from widgets
stored in WindowBase
.
After this we can turn the widgets
member into std::vector and copy the widget definition instead of sharing the memory. This will also eliminate the need of having a special widget type that annotates the end of the array.