Ensure TTF system is torn down in correct order (#21707)

`TTFDispose` uses `gCurrentTTFFontSet` to deallocate internal resources.
Having the function called after global variable got changed meant it
tried to deallocate incorrect font and would subsequently call
`FT_Done_Face` on a struct having internal data set to nullptr.

Reproduction is fairly easy:
1. launch the game in Korean (I made sure to have all the indexes primed
   for this language beforehand - i.e. launch it twice),
2. switch to Japanese,
3. switch back to Korean

Fixes #21664
This commit is contained in:
Michał Janiszewski 2024-04-02 00:52:40 +02:00 committed by GitHub
parent 6ea091841f
commit dfcb527ada
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 3 additions and 1 deletions

View File

@ -29,6 +29,7 @@
- Fix: [#21652] Dialog window to confirm overwriting files does not apply the theme colours correctly.
- Fix: [#21654] No sound effects when using RCT Classic as an asset base.
- Fix: [#21654] Extraneous reports of an object conflict between `rct2.audio.base` and `rct2.audio.base.rctc`.
- Fix: [#21664] Crash when switching between languages that use TTF.
- Fix: [#21668] Crash when on null ride in Guest::UpdateRideLeaveExit.
- Fix: [#21691] Crash when validating rides which can't contain banked track.
- Fix: [objects#290] “Haunted Mansion” cars have a non-functional third remap colour.

View File

@ -117,10 +117,11 @@ static void LoadSpriteFont(LocalisationService& localisationService)
#ifndef NO_TTF
static bool LoadFont(LocalisationService& localisationService, TTFFontSetDescriptor* font)
{
TTFDispose();
localisationService.UseTrueTypeFont(true);
gCurrentTTFFontSet = font;
TTFDispose();
bool fontInitialised = TTFInitialise();
return fontInitialised;
}