From da38f163200eec92a7ecaabc181df5b2b8c03015 Mon Sep 17 00:00:00 2001 From: wmayer Date: Thu, 16 Mar 2023 15:19:18 +0100 Subject: [PATCH] Gui: set-up a logging category filter to suppress the most annoying Qt warnings --- src/Gui/Application.cpp | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/src/Gui/Application.cpp b/src/Gui/Application.cpp index 077af9fafb..b3685d4a35 100644 --- a/src/Gui/Application.cpp +++ b/src/Gui/Application.cpp @@ -41,6 +41,8 @@ # include #endif +#include + #include #include #include @@ -1670,6 +1672,18 @@ Gui::PreferencePackManager* Application::prefPackManager() //************************************************************************** // Init, Destruct and singleton +namespace { +void setCategoryFilterRules() +{ + QString filter; + QTextStream stream(&filter); + stream << "qt.qpa.xcb.warning=false\n"; + stream << "qt.qpa.mime.warning=false\n"; + stream.flush(); + QLoggingCategory::setFilterRules(filter); +} +} + using _qt_msg_handler_old = void (*)(QtMsgType, const QMessageLogContext &, const QString &); _qt_msg_handler_old old_qtmsg_handler = nullptr; @@ -1755,6 +1769,7 @@ void Application::initApplication() initTypes(); new Base::ScriptProducer( "FreeCADGuiInit", FreeCADGuiInit ); init_resources(); + setCategoryFilterRules(); old_qtmsg_handler = qInstallMessageHandler(messageHandler); init = true; }