diff options
author | Kai Koehne <kai.koehne@nokia.com> | 2012-05-07 10:03:49 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-05-11 10:38:25 +0200 |
commit | 390291047e73fedb7340bd2596cb83c7aed092a3 (patch) | |
tree | 8208c91ac29a3f0c609d595c69d5bcb071b1185e | |
parent | 3247f2ece90ab73dcb3d927e3683137890a916a4 (diff) |
Logging: Show pattern warning also on Windows GUI apps
Change-Id: Ibbeb606469e7cec5aa68525b05714453151ee066
Reviewed-by: Andreas Holzammer <andreas.holzammer@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
-rw-r--r-- | src/corelib/global/qlogging.cpp | 25 |
1 files changed, 20 insertions, 5 deletions
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<const wchar_t*>(error.utf16())); + continue; +#elif defined(Q_OS_WIN) && defined(QT_BUILD_CORE_LIB) + if (usingWinMain) { + OutputDebugString(reinterpret_cast<const wchar_t*>(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); |