From 466d226a4acc66fc1c1c4faf8d9da68e6c84fbda Mon Sep 17 00:00:00 2001 From: bruvzg <7645683+bruvzg@users.noreply.github.com> Date: Tue, 21 Feb 2023 09:43:54 +0200 Subject: [PATCH] [TextServer] Ensure ICU data is initialised only one and cleaned only at exit. (cherry picked from commit 7f24433e15081044aa8bcc3a646ded5129048bf5) --- modules/text_server_adv/text_server_adv.cpp | 5 ++++- modules/text_server_adv/text_server_adv.h | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/modules/text_server_adv/text_server_adv.cpp b/modules/text_server_adv/text_server_adv.cpp index 22652daa24a..007f439a895 100644 --- a/modules/text_server_adv/text_server_adv.cpp +++ b/modules/text_server_adv/text_server_adv.cpp @@ -334,6 +334,8 @@ _FORCE_INLINE_ bool is_connected_to_prev(char32_t p_chr, char32_t p_pchr) { /*************************************************************************/ +bool TextServerAdvanced::icu_data_loaded = false; + bool TextServerAdvanced::_has_feature(Feature p_feature) const { switch (p_feature) { case FEATURE_SIMPLE_LAYOUT: @@ -6599,5 +6601,6 @@ TextServerAdvanced::~TextServerAdvanced() { uset_close(allowed); allowed = nullptr; } - u_cleanup(); + + std::atexit(u_cleanup); } diff --git a/modules/text_server_adv/text_server_adv.h b/modules/text_server_adv/text_server_adv.h index 02244a294ee..f092fa8ccab 100644 --- a/modules/text_server_adv/text_server_adv.h +++ b/modules/text_server_adv/text_server_adv.h @@ -158,7 +158,7 @@ class TextServerAdvanced : public TextServerExtension { // ICU support data. - bool icu_data_loaded = false; + static bool icu_data_loaded; mutable USet *allowed = nullptr; mutable USpoofChecker *sc_spoof = nullptr; mutable USpoofChecker *sc_conf = nullptr;