From 6c493fddd9a72c580471ebeace2c488d13272f24 Mon Sep 17 00:00:00 2001 From: Max Paperno Date: Mon, 6 Mar 2017 06:28:33 -0500 Subject: [PATCH] [Companion][Simulator] Misc. minor fixes: Fix Qt < 5.3 compat. issue in DebugOutput; AppDebugMessageHandler: Filter out verbose QPainter warnings on Linux Qt < 5.3; Do not return any instance if disabled entirely; Fix style sheet for simulator radio background. --- companion/src/appdebugmessagehandler.cpp | 12 +++++++++--- companion/src/simulation/debugoutput.cpp | 7 ++++++- companion/src/themes/default/style.css | 4 ++-- 3 files changed, 17 insertions(+), 6 deletions(-) diff --git a/companion/src/appdebugmessagehandler.cpp b/companion/src/appdebugmessagehandler.cpp index bf817191c..816ad2057 100644 --- a/companion/src/appdebugmessagehandler.cpp +++ b/companion/src/appdebugmessagehandler.cpp @@ -33,8 +33,10 @@ AppDebugMessageHandler::AppDebugMessageHandler(QObject * parent) : AppDebugMessageHandler * AppDebugMessageHandler::instance() { static AppDebugMessageHandler * _instance = NULL; +#if APP_DBG_HANDLER_ENABLE if(_instance == NULL && !qApp->closingDown()) _instance = new AppDebugMessageHandler(qApp); // Ensure this object is cleaned up when the QApplication exits. +#endif return _instance; } @@ -55,9 +57,7 @@ void AppDebugMessageHandler::setShowFunctionDeclarations(bool showFunctionDeclar void AppDebugMessageHandler::installAppMessageHandler() { -#if APP_DBG_HANDLER_ENABLE m_defaultHandler = qInstallMessageHandler(g_appDebugMessageHandler); -#endif } void AppDebugMessageHandler::messageHandler(QtMsgType type, const QMessageLogContext & context, const QString & msg) @@ -73,6 +73,12 @@ void AppDebugMessageHandler::messageHandler(QtMsgType type, const QMessageLogCon if (lvl < m_appDebugOutputLevel && type != QtFatalMsg) return; +#if defined(Q_OS_LINUX) && (QT_VERSION < QT_VERSION_CHECK(5, 3, 0)) + // Filter out lots of QPainter warnings from undocked QDockWidgets... hackish but effective (only workaround found so far) + if (lvl == 2 && QString(context.function).contains("QPainter::")) + return; +#endif + QString msgPattern = QString("[%1] ").arg(symbols[type]); if (m_showSourcePath) { @@ -101,7 +107,7 @@ void AppDebugMessageHandler::messageHandler(QtMsgType type, const QMessageLogCon msgPattern.replace("%{message}", msg); if (!m_showFunctionDeclarations) { QString func = context.function; - msgPattern.replace(QString("%{function}"), func.replace(m_functionFilter, "\\1)")); + msgPattern.replace("%{function}", func.replace(m_functionFilter, "\\1)")); } #endif diff --git a/companion/src/simulation/debugoutput.cpp b/companion/src/simulation/debugoutput.cpp index 1bd08b936..80013b527 100644 --- a/companion/src/simulation/debugoutput.cpp +++ b/companion/src/simulation/debugoutput.cpp @@ -101,8 +101,13 @@ DebugOutput::DebugOutput(QWidget * parent, SimulatorInterface *simulator): connect(ui->actionToggleFilter, &QAction::toggled, this, &DebugOutput::onFilterToggled); connect(ui->filterText, &QComboBox::currentTextChanged, this, &DebugOutput::onFilterTextChanged); - if (AppDebugMessageHandler::instance()) + if (AppDebugMessageHandler::instance()) { +#if (QT_VERSION < QT_VERSION_CHECK(5, 3, 0)) // https://bugreports.qt.io/browse/QTBUG-36119 + connect(AppDebugMessageHandler::instance(), SIGNAL(messageOutput(quint8,QString,QMessageLogContext)), this, SLOT(onAppDebugMessage(quint8,QString,QMessageLogContext))); +#else connect(AppDebugMessageHandler::instance(), &AppDebugMessageHandler::messageOutput, this, &DebugOutput::onAppDebugMessage); +#endif + } // send firmware TRACE events to our data collector m_simulator->installTraceHook(firmwareTraceCb); diff --git a/companion/src/themes/default/style.css b/companion/src/themes/default/style.css index 2236a6973..c7548a661 100644 --- a/companion/src/themes/default/style.css +++ b/companion/src/themes/default/style.css @@ -52,11 +52,11 @@ QSplitter::handle:hover { */ /* default radio "case" background */ -SimulatorDialog > QWidget { +SimulatorWidget > QWidget { background-color: qlineargradient(spread:reflect, x1:0, y1:0, x2:0, y2:1, stop:0 rgba(242, 242, 242, 255), stop:0.757062 rgba(222, 220, 220, 255), stop:1 rgba(232, 230, 230, 255)); } /* radio LCD/controls area under "case" */ -SimulatorDialog #radioUiWidget { +SimulatorWidget #radioUiWidget { background-color: qlineargradient(spread:reflect, x1:0.22, y1:0, x2:0.55065, y2:0.54, stop:0 rgba(7, 7, 7, 250), stop:0.864407 rgba(66, 66, 66, 255)); margin: 0; padding: 0;