summaryrefslogtreecommitdiffstats
path: root/src/corelib/global/qlogging.cpp
diff options
context:
space:
mode:
authorKai Koehne <kai.koehne@nokia.com>2012-07-13 13:31:45 +0200
committerQt by Nokia <qt-info@nokia.com>2012-07-21 16:24:43 +0200
commite6558184ebda127ca10b4db97d98c328aa3d7be9 (patch)
treeeccaadd6f1237811fccfd070c558181f34a81944 /src/corelib/global/qlogging.cpp
parentfa3cc59868488120e8b1bced792b26bbea380966 (diff)
Logging: Simplify message handler logic for windows
Incorporate the functionality of qWinMessageHandler in qDefaultMessageHandler. Change-Id: Iec5b19e187c0d2e3d8d0874280ba57f6fb21d7b4 Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
Diffstat (limited to 'src/corelib/global/qlogging.cpp')
-rw-r--r--src/corelib/global/qlogging.cpp37
1 files changed, 13 insertions, 24 deletions
diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp
index b0afc5af7e..c567d339fd 100644
--- a/src/corelib/global/qlogging.cpp
+++ b/src/corelib/global/qlogging.cpp
@@ -633,12 +633,21 @@ static void qDefaultMessageHandler(QtMsgType type, const QMessageLogContext &con
const QString &buf)
{
QString logMessage = qMessageFormatString(type, context, buf);
-#if defined(Q_OS_WINCE)
- OutputDebugString(reinterpret_cast<const wchar_t *> (logMessage.utf16()));
-#else
+
+#if defined(Q_OS_WIN) && defined(QT_BUILD_CORE_LIB)
+#if !defined(Q_OS_WINCE)
+ if (usingWinMain)
+#endif
+ {
+ // OutputDebugString is not threadsafe.
+ static QBasicMutex outputDebugStringMutex;
+ QMutexLocker locker(&outputDebugStringMutex);
+ OutputDebugString(reinterpret_cast<const wchar_t *>(logMessage.utf16()));
+ return;
+ }
+#endif // Q_OS_WIN
fprintf(stderr, "%s", logMessage.toLocal8Bit().constData());
fflush(stderr);
-#endif
}
/*!
@@ -728,18 +737,6 @@ void qErrnoWarning(int code, const char *msg, ...)
qt_message_output(QtCriticalMsg, context, buf);
}
-#if defined(Q_OS_WIN) && defined(QT_BUILD_CORE_LIB)
-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);
-
-void qWinMessageHandler2(QtMsgType t, const QMessageLogContext &context,
- const char *str)
-{
- qWinMessageHandler(t, context, QString::fromLocal8Bit(str));
-}
-#endif
-
/*!
\typedef QtMsgHandler
\relates <QtGlobal>
@@ -852,10 +849,6 @@ QtMessageHandler qInstallMessageHandler(QtMessageHandler h)
messageHandler = qDefaultMessageHandler;
QtMessageHandler old = messageHandler;
messageHandler = h;
-#if defined(Q_OS_WIN) && defined(QT_BUILD_CORE_LIB)
- if (!messageHandler && usingWinMain)
- messageHandler = qWinMessageHandler;
-#endif
return old;
}
@@ -867,10 +860,6 @@ QtMsgHandler qInstallMsgHandler(QtMsgHandler h)
msgHandler = qDefaultMsgHandler;
QtMsgHandler old = msgHandler;
msgHandler = h;
-#if defined(Q_OS_WIN) && defined(QT_BUILD_CORE_LIB)
- if (!msgHandler && usingWinMain)
- msgHandler = qWinMsgHandler;
-#endif
return old;
}