From 5122b9547501b08d4147d6ea1aa95324a3b8c9bd Mon Sep 17 00:00:00 2001 From: Zephyron Date: Sat, 22 Nov 2025 16:13:00 +1000 Subject: [PATCH] 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 --- src/citron/main.cpp | 11 +++++++++++ src/citron/main.h | 1 + 2 files changed, 12 insertions(+) diff --git a/src/citron/main.cpp b/src/citron/main.cpp index d274a02ef..df241b5f1 100644 --- a/src/citron/main.cpp +++ b/src/citron/main.cpp @@ -5791,6 +5791,14 @@ static void AdjustLinkColor() { } 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); const QString default_theme_name = QString::fromUtf8( UISettings::themes[static_cast(UISettings::default_theme)].second); @@ -5844,6 +5852,9 @@ void GMainWindow::UpdateUITheme() { } emit themeChanged(); + + // Once everything is done, reset the flag to false. + m_is_updating_theme = false; } void GMainWindow::LoadTranslation() { diff --git a/src/citron/main.h b/src/citron/main.h index 3372447e7..cf70bce79 100644 --- a/src/citron/main.h +++ b/src/citron/main.h @@ -393,6 +393,7 @@ private: bool is_amiibo_file_select_active{}; bool is_load_file_select_active{}; bool is_tas_recording_dialog_active{}; + bool m_is_updating_theme = false; #ifdef __unix__ QSocketNotifier* sig_interrupt_notifier; static std::array sig_interrupt_fds;