summaryrefslogtreecommitdiffstats
path: root/src/corelib/global
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2018-02-08 12:37:22 +0100
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2018-02-11 03:32:25 +0000
commit3cee4308dc87b58918ad2594918d1cda574428d0 (patch)
tree4299754abfa4a3bd9610aac5e107025d5a594f6d /src/corelib/global
parentc94ef51f0ccafb4edf714c45d399dd48fb6b7b1b (diff)
logging: Break out QMessagePattern error reporting into standalone function
Makes for a less awkward logic without any if (0) etc. Change-Id: I3db0984c5a0bbf1615c2feb2ebef59b4ec16e9ae Reviewed-by: Simon Hausmann <simon.hausmann@qt.io> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/global')
-rw-r--r--src/corelib/global/qlogging.cpp34
1 files changed, 20 insertions, 14 deletions
diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp
index 48d0cac10e..7e4425bd34 100644
--- a/src/corelib/global/qlogging.cpp
+++ b/src/corelib/global/qlogging.cpp
@@ -155,6 +155,7 @@ Q_NORETURN
#endif
static void qt_message_fatal(QtMsgType, const QMessageLogContext &context, const QString &message);
static void qt_message_print(QtMsgType, const QMessageLogContext &context, const QString &message);
+static void qt_message_print(const QString &message);
static int checked_var_value(const char *varname)
{
@@ -1214,20 +1215,10 @@ void QMessagePattern::setPattern(const QString &pattern)
error += QLatin1String("QT_MESSAGE_PATTERN: %{if-*} cannot be nested\n");
else if (inIf)
error += QLatin1String("QT_MESSAGE_PATTERN: missing %{endif}\n");
- if (!error.isEmpty()) {
-#if defined(Q_OS_WINRT)
- OutputDebugString(reinterpret_cast<const wchar_t*>(error.utf16()));
- if (0)
-#elif defined(Q_OS_WIN) && !defined(QT_BOOTSTRAPPED)
- if (!qt_logging_to_console()) {
- OutputDebugString(reinterpret_cast<const wchar_t*>(error.utf16()));
- } else
-#endif
- {
- fprintf(stderr, "%s", error.toLocal8Bit().constData());
- fflush(stderr);
- }
- }
+
+ if (!error.isEmpty())
+ qt_message_print(error);
+
literals = new const char*[literalsVar.size() + 1];
literals[literalsVar.size()] = 0;
memcpy(literals, literalsVar.constData(), literalsVar.size() * sizeof(const char*));
@@ -1743,6 +1734,21 @@ static void qt_message_print(QtMsgType msgType, const QMessageLogContext &contex
}
}
+static void qt_message_print(const QString &message)
+{
+#if defined(Q_OS_WINRT)
+ OutputDebugString(reinterpret_cast<const wchar_t*>(message.utf16()));
+ return;
+#elif defined(Q_OS_WIN) && !defined(QT_BOOTSTRAPPED)
+ if (!qt_logging_to_console()) {
+ OutputDebugString(reinterpret_cast<const wchar_t*>(message.utf16()));
+ return;
+ }
+#endif
+ fprintf(stderr, "%s", message.toLocal8Bit().constData());
+ fflush(stderr);
+}
+
static void qt_message_fatal(QtMsgType, const QMessageLogContext &context, const QString &message)
{
#if defined(Q_CC_MSVC) && defined(QT_DEBUG) && defined(_DEBUG) && defined(_CRT_ERROR)