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.
This commit is contained in:
Vadim Zeitlin 2020-07-13 14:23:42 +02:00
parent f9618ebe5b
commit 325648136c

View File

@ -843,7 +843,13 @@ bool wxTopLevelWindowGTK::Create( wxWindow *parent,
gtk_widget_set_size_request(m_widget, w, h); 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); G_CALLBACK(notify_gtk_theme_name), this);
return true; return true;