From 325648136ca63619056ed998e976e59bbfedbf54 Mon Sep 17 00:00:00 2001 From: Vadim Zeitlin Date: Mon, 13 Jul 2020 14:23:42 +0200 Subject: [PATCH] Fix system colours in wxGTK wxSysColourChangedEvent handlers Using wxSystemSettings::GetColour() in wxSysColourChangedEvent handler in wxGTK could return the old colour value, before the change, because the callback for notify::gtk-theme-name signal defined in wxTLW, which generates wxSysColourChangedEvent, could be invoked before the callback for the same signal in wxSystemSettings, which invalidated its cache. Fix this by registering the former using g_signal_connect_after() and thus ensuring that wxSystemSettings callback runs before it, and the cache is cleared before wxSysColourChangedEvent handlers can use it. Closes #18818. --- src/gtk/toplevel.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/gtk/toplevel.cpp b/src/gtk/toplevel.cpp index 74c6ed2e1b..2bbdb79e9c 100644 --- a/src/gtk/toplevel.cpp +++ b/src/gtk/toplevel.cpp @@ -843,7 +843,13 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent, gtk_widget_set_size_request(m_widget, w, h); } - g_signal_connect(gtk_settings_get_default(), "notify::gtk-theme-name", + // Note that we need to connect after this signal in order to let the + // normal g_signal_connect() in wxSystemSettings code to run before our + // handler: this ensures that system settings cache is cleared before the + // user-defined wxSysColourChangedEvent handlers using wxSystemSettings + // methods are executed, which is important as otherwise they would use the + // old colours etc. + g_signal_connect_after(gtk_settings_get_default(), "notify::gtk-theme-name", G_CALLBACK(notify_gtk_theme_name), this); return true;