Fix infinite recursion in UpdateUITheme() on Arch Linux

Add recursion guard (m_is_updating_theme) to prevent UpdateUITheme()
from entering an infinite loop when palette changes trigger recursive
theme updates. This eliminates the need for manual qt-config.ini edits
on Arch Linux systems.

The guard ensures that if UpdateUITheme() is already running, subsequent
calls will exit immediately, preventing stack overflow and application
freezing.

Signed-off-by: Zephyron <zephyron@citron-emu.org>
This commit is contained in:
Zephyron
2025-11-22 16:13:00 +10:00
parent e881da60ef
commit 5122b95475
2 changed files with 12 additions and 0 deletions

View File

@@ -5791,6 +5791,14 @@ static void AdjustLinkColor() {
} }
void GMainWindow::UpdateUITheme() { void GMainWindow::UpdateUITheme() {
// If the function is already running, exit immediately to prevent recursion.
if (m_is_updating_theme) {
return;
}
// Set the flag to true to indicate that a theme update is in progress.
m_is_updating_theme = true;
QString current_theme = QString::fromStdString(UISettings::values.theme); QString current_theme = QString::fromStdString(UISettings::values.theme);
const QString default_theme_name = QString::fromUtf8( const QString default_theme_name = QString::fromUtf8(
UISettings::themes[static_cast<size_t>(UISettings::default_theme)].second); UISettings::themes[static_cast<size_t>(UISettings::default_theme)].second);
@@ -5844,6 +5852,9 @@ void GMainWindow::UpdateUITheme() {
} }
emit themeChanged(); emit themeChanged();
// Once everything is done, reset the flag to false.
m_is_updating_theme = false;
} }
void GMainWindow::LoadTranslation() { void GMainWindow::LoadTranslation() {

View File

@@ -393,6 +393,7 @@ private:
bool is_amiibo_file_select_active{}; bool is_amiibo_file_select_active{};
bool is_load_file_select_active{}; bool is_load_file_select_active{};
bool is_tas_recording_dialog_active{}; bool is_tas_recording_dialog_active{};
bool m_is_updating_theme = false;
#ifdef __unix__ #ifdef __unix__
QSocketNotifier* sig_interrupt_notifier; QSocketNotifier* sig_interrupt_notifier;
static std::array<int, 3> sig_interrupt_fds; static std::array<int, 3> sig_interrupt_fds;