vcl/unx/gtk3/gtkinst.cxx | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+)
New commits: commit 9480ac658ec8ddb445f629b4db66fce07649feab Author: Caolán McNamara <caol...@redhat.com> AuthorDate: Wed Aug 10 13:11:05 2022 +0100 Commit: Xisco Fauli <xiscofa...@libreoffice.org> CommitDate: Thu Aug 11 11:50:40 2022 +0200 gtk3: silence 'invalid cast from 'GtkWindow' to 'GtkMenuShell' warning from the sidebar tab due to the accelerators in there its a bogus check in gtk3 in this case of a menu attached to a MenuButton Change-Id: Ie5216e749993f3d44bfc2e4560cd3b2f49aa8aec Reviewed-on: https://gerrit.libreoffice.org/c/core/+/138114 Reviewed-by: Michael Stahl <michael.st...@allotropia.de> Tested-by: Jenkins diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx index 9529668c5639..ca997a5193c3 100644 --- a/vcl/unx/gtk3/gtkinst.cxx +++ b/vcl/unx/gtk3/gtkinst.cxx @@ -22441,16 +22441,44 @@ bool IsAllowedBuiltInIcon(std::u16string_view iconName) namespace { +#if !GTK_CHECK_VERSION(4, 0, 0) +void silence_gwarning(const gchar* /*log_domain*/, + GLogLevelFlags /*log_level*/, + const gchar* /*message*/, + gpointer /*user_data*/) +{ +} +#endif + void load_ui_file(GtkBuilder* pBuilder, const OUString& rUri) { #if GTK_CHECK_VERSION(4, 0, 0) builder_add_from_gtk3_file(pBuilder, rUri); #else + guint nLogHandlerId = 0; + GLogLevelFlags nFatalMask(static_cast<GLogLevelFlags>(G_LOG_FLAG_RECURSION|G_LOG_LEVEL_ERROR)); + if (rUri.endsWith("sfx/ui/tabbarcontents.ui")) + { + // gtk unhelpfully has a bogus warning for the accelerator in this .ui because it assumes menus with accelerators + // if attached to something are attached to a MenuShell, but it's a MenuButton in this case. Turn off warnings, and + // in the case of fatal-warnings temp disable fatal warnings, for this case. + nLogHandlerId = g_log_set_handler("GLib-GObject", + static_cast<GLogLevelFlags>(G_LOG_LEVEL_MASK | G_LOG_FLAG_FATAL | G_LOG_FLAG_RECURSION), + silence_gwarning, nullptr); + nFatalMask = g_log_set_always_fatal(nFatalMask); + } + OUString aPath; osl::FileBase::getSystemPathFromFileURL(rUri, aPath); GError *err = nullptr; auto rc = gtk_builder_add_from_file(pBuilder, OUStringToOString(aPath, RTL_TEXTENCODING_UTF8).getStr(), &err); + if (nLogHandlerId) + { + g_log_remove_handler("GLib-GObject", nLogHandlerId); + g_log_set_always_fatal(nFatalMask); + } + if (!rc) { SAL_WARN( "vcl.gtk", "GtkInstanceBuilder: error when calling gtk_builder_add_from_file: " << err->message);