suppress: gtk_style_context_add_provider: assertion 'GTK_IS_STYLE_CONTEXT (context)' failed

This commit is contained in:
SoftFever
2026-03-26 16:22:07 +08:00
parent 6148ba16b3
commit fe55b260b4

View File

@@ -2708,11 +2708,15 @@ bool GUI_App::on_init_inner()
#if defined(__WXGTK20__) || defined(__WXGTK3__)
// Suppress harmless GTK critical warnings from the GTK3/wxWidgets interaction.
// These include widget allocation on hidden widgets and events on unrealized widgets.
// These include widget allocation on hidden widgets, events on unrealized widgets,
// and style context operations during widget construction (SetBackgroundColour
// before GTK widget realization).
g_log_set_handler("Gtk", G_LOG_LEVEL_CRITICAL,
[](const gchar *log_domain, GLogLevelFlags log_level, const gchar *message, gpointer user_data) {
if (message && (strstr(message, "gtk_widget_set_allocation") ||
strstr(message, "WIDGET_REALIZED_FOR_EVENT")))
strstr(message, "WIDGET_REALIZED_FOR_EVENT") ||
strstr(message, "gtk_widget_get_style_context") ||
strstr(message, "gtk_style_context_add_provider")))
return;
g_log_default_handler(log_domain, log_level, message, user_data);
}, nullptr);