From 390291047e73fedb7340bd2596cb83c7aed092a3 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Mon, 7 May 2012 10:03:49 +0200 Subject: Logging: Show pattern warning also on Windows GUI apps Change-Id: Ibbeb606469e7cec5aa68525b05714453151ee066 Reviewed-by: Andreas Holzammer Reviewed-by: Thiago Macieira --- src/corelib/global/qlogging.cpp | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) (limited to 'src/corelib/global/qlogging.cpp') diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index cc6ff4d3cd..b3ffeab0b8 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -88,6 +88,11 @@ QT_BEGIN_NAMESPACE \sa QMessageLogContext, qDebug(), qWarning(), qCritical(), qFatal() */ +#if defined(Q_OS_WIN) && defined(QT_BUILD_CORE_LIB) +// defined in qcoreapplication_win.cpp +extern bool usingWinMain; +#endif + #if !defined(QT_NO_EXCEPTIONS) /*! \internal @@ -509,11 +514,22 @@ void QMessagePattern::setPattern(const QString &pattern) else if (lexeme == QLatin1String(threadidTokenC)) tokens[i] = threadidTokenC; else { - fprintf(stderr, "%s\n", - QString::fromLatin1("QT_MESSAGE_PATTERN: Unknown placeholder %1\n" - ).arg(lexeme).toLatin1().constData()); - fflush(stderr); tokens[i] = emptyTokenC; + + QString error = QStringLiteral("QT_MESSAGE_PATTERN: Unknown placeholder %1\n") + .arg(lexeme); + +#if defined(Q_OS_WINCE) + OutputDebugString(reinterpret_cast(error.utf16())); + continue; +#elif defined(Q_OS_WIN) && defined(QT_BUILD_CORE_LIB) + if (usingWinMain) { + OutputDebugString(reinterpret_cast(error.utf16())); + continue; + } +#endif + fprintf(stderr, "%s", error.toLocal8Bit().constData()); + fflush(stderr); } } else { char *literal = new char[lexeme.size() + 1]; @@ -717,7 +733,6 @@ void qErrnoWarning(int code, const char *msg, ...) } #if defined(Q_OS_WIN) && defined(QT_BUILD_CORE_LIB) -extern bool usingWinMain; extern Q_CORE_EXPORT void qWinMsgHandler(QtMsgType t, const char *str); extern Q_CORE_EXPORT void qWinMessageHandler(QtMsgType t, const QMessageLogContext &context, const QString &str); -- cgit v1.2.3