1
0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-14 17:15:21 +02:00

Reload font manager in main thread to avoid a crash (#15900)

This commit is contained in:
Deve
2025-03-16 17:55:39 +01:00
committed by GitHub
parent 4b85062caf
commit c07499ccfc
4 changed files with 24 additions and 4 deletions

View File

@@ -18,10 +18,9 @@
/** reference to access font engine, has to be initialized by main */
FontEngine *g_fontengine = nullptr;
/** callback to be used on change of font size setting */
static void font_setting_changed(const std::string &name, void *userdata)
void FontEngine::fontSettingChanged(const std::string &name, void *userdata)
{
static_cast<FontEngine *>(userdata)->readSettings();
((FontEngine *)userdata)->m_needs_reload = true;
}
static const char *settings[] = {
@@ -49,7 +48,7 @@ FontEngine::FontEngine(gui::IGUIEnvironment* env) :
readSettings();
for (auto name : settings)
g_settings->registerChangedCallback(name, font_setting_changed, this);
g_settings->registerChangedCallback(name, fontSettingChanged, this);
}
FontEngine::~FontEngine()
@@ -162,6 +161,15 @@ void FontEngine::readSettings()
refresh();
}
void FontEngine::handleReload()
{
if (!m_needs_reload)
return;
m_needs_reload = false;
readSettings();
}
void FontEngine::updateSkin()
{
gui::IGUIFont *font = getFont();