Don't let windowstates manual test eat log messages

Having logging in the test's log widget is nice, but we don't want
to silence the normal logging, as that might confuse someone who
expects to see normal log messages, not knowing there's a dedicated
log widget in the test.

Pick-to: 6.2
Change-Id: I7828f740cfb8cc2eae8da98b9b8facd4a57fa37b
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
This commit is contained in:
Tor Arne Vestbø 2021-09-14 23:04:39 +02:00
parent 088b364e4b
commit 5c880e30c7

View File

@ -289,19 +289,15 @@ private:
LogWidget *LogWidget::m_instance = 0;
#if QT_VERSION >= 0x050000
static void qt5MessageHandler(QtMsgType, const QMessageLogContext &, const QString &text)
static QtMessageHandler originalMessageHandler = nullptr;
static void messageHandler(QtMsgType type, const QMessageLogContext &context, const QString &text)
{
if (LogWidget *lw = LogWidget::instance())
lw->appendText(text);
originalMessageHandler(type, context, text);
}
#else // Qt 5
static void qt4MessageHandler(QtMsgType, const char *text)
{
if (LogWidget *lw = LogWidget::instance())
lw->appendText(QString::fromLocal8Bit(text));
}
#endif // Qt 4
LogWidget::LogWidget(QWidget *parent)
: QPlainTextEdit(parent)
@ -318,7 +314,7 @@ LogWidget::~LogWidget()
void LogWidget::install()
{
qInstallMessageHandler(qt5MessageHandler);
originalMessageHandler = qInstallMessageHandler(messageHandler);
}
QString LogWidget::startupMessage()