summaryrefslogtreecommitdiff
path: root/vcl/unx/gtk3
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2022-08-10 13:11:05 +0100
committerCaolán McNamara <caolanm@redhat.com>2022-08-11 12:43:19 +0200
commit600780e9904958bf91585d5e232e0cfa0c95827a (patch)
treebb27cd727eeeca2234d353894c7e1bb8f4474932 /vcl/unx/gtk3
parentd3625d968901eb93a9680db8d1165f70de3fd64e (diff)
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/+/138086 Tested-by: Jenkins Reviewed-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/unx/gtk3')
-rw-r--r--vcl/unx/gtk3/gtkinst.cxx28
1 files changed, 28 insertions, 0 deletions
diff --git a/vcl/unx/gtk3/gtkinst.cxx b/vcl/unx/gtk3/gtkinst.cxx
index 31e021140a0f..c434996c9552 100644
--- a/vcl/unx/gtk3/gtkinst.cxx
+++ b/vcl/unx/gtk3/gtkinst.cxx
@@ -23008,16 +23008,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);