Skip to content

Commit

Permalink
Fix OpenRCT2#22316: Always recreate the window when changing drawing …
Browse files Browse the repository at this point in the history
…engine
  • Loading branch information
ZehMatt authored and Sadret committed Sep 7, 2024
1 parent 26ff3b9 commit 461249d
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 17 deletions.
1 change: 1 addition & 0 deletions distribution/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
- Change: [#22491] Scrollbars are now hidden if the scrollable widget is not actually overflowing.
- Fix: [#21908] Errors showing up when placing/moving track design previews.
- Fix: [#22307] Hover tooltips in financial charts are not invalidated properly.
- Fix: [#22316] Potential crash when switching the drawing engine while the game is running.
- Fix: [#22395, #22396] Misaligned tick marks in financial and guest count graphs (original bug).

0.4.13 (2024-08-04)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,14 @@ class HardwareDisplayDrawingEngine final : public X8DrawingEngine

~HardwareDisplayDrawingEngine() override
{
if (_screenTexture != nullptr)
{
SDL_DestroyTexture(_screenTexture);
}
if (_scaledScreenTexture != nullptr)
{
SDL_DestroyTexture(_scaledScreenTexture);
}
SDL_FreeFormat(_screenTextureFormat);
SDL_DestroyRenderer(_sdlRenderer);
}
Expand Down
5 changes: 1 addition & 4 deletions src/openrct2-ui/windows/Options.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -714,7 +714,6 @@ static Widget *window_options_page_widgets[] = {
break;
case WIDX_MINIMIZE_FOCUS_LOSS:
Config::Get().general.MinimizeFullscreenFocusLoss ^= 1;
RefreshVideo(false);
Config::Save();
Invalidate();
break;
Expand Down Expand Up @@ -853,12 +852,10 @@ static Widget *window_options_page_widgets[] = {
case WIDX_DRAWING_ENGINE_DROPDOWN:
if (dropdownIndex != EnumValue(Config::Get().general.DrawingEngine))
{
DrawingEngine srcEngine = drawing_engine_get_type();
DrawingEngine dstEngine = static_cast<DrawingEngine>(dropdownIndex);

Config::Get().general.DrawingEngine = dstEngine;
bool recreate_window = DrawingEngineRequiresNewWindow(srcEngine, dstEngine);
RefreshVideo(recreate_window);
RefreshVideo();
Config::Save();
Invalidate();
}
Expand Down
14 changes: 2 additions & 12 deletions src/openrct2/drawing/Drawing.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1124,19 +1124,9 @@ void UpdatePaletteEffects()
}
}

void RefreshVideo(bool recreateWindow)
void RefreshVideo()
{
if (recreateWindow)
{
ContextRecreateWindow();
}
else
{
DrawingEngineDispose();
DrawingEngineInit();
DrawingEngineResize();
}

ContextRecreateWindow();
DrawingEngineSetPalette(gPalette);
GfxInvalidateScreen();
}
Expand Down
2 changes: 1 addition & 1 deletion src/openrct2/drawing/Drawing.h
Original file line number Diff line number Diff line change
Expand Up @@ -630,7 +630,7 @@ std::optional<PaletteMap> GetPaletteMapForColour(colour_t paletteId);
void UpdatePalette(const uint8_t* colours, int32_t start_index, int32_t num_colours);
void UpdatePaletteEffects();

void RefreshVideo(bool recreateWindow);
void RefreshVideo();
void ToggleWindowedMode();

#include "NewDrawing.h"

0 comments on commit 461249d

Please sign in to comment.