diff options
author | Kai Koehne <kai.koehne@nokia.com> | 2012-07-13 13:31:45 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-07-21 16:24:43 +0200 |
commit | e6558184ebda127ca10b4db97d98c328aa3d7be9 (patch) | |
tree | eccaadd6f1237811fccfd070c558181f34a81944 /src/corelib/kernel/qcoreapplication_win.cpp | |
parent | fa3cc59868488120e8b1bced792b26bbea380966 (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/kernel/qcoreapplication_win.cpp')
-rw-r--r-- | src/corelib/kernel/qcoreapplication_win.cpp | 43 |
1 files changed, 0 insertions, 43 deletions
diff --git a/src/corelib/kernel/qcoreapplication_win.cpp b/src/corelib/kernel/qcoreapplication_win.cpp index 9d92f83b04..e42411917f 100644 --- a/src/corelib/kernel/qcoreapplication_win.cpp +++ b/src/corelib/kernel/qcoreapplication_win.cpp @@ -125,46 +125,6 @@ QString QCoreApplicationPrivate::appName() const return QFileInfo(qAppFileName()).baseName(); } -class QWinMsgHandlerCriticalSection -{ - CRITICAL_SECTION cs; -public: - QWinMsgHandlerCriticalSection() - { InitializeCriticalSection(&cs); } - ~QWinMsgHandlerCriticalSection() - { DeleteCriticalSection(&cs); } - - void lock() - { EnterCriticalSection(&cs); } - void unlock() - { LeaveCriticalSection(&cs); } -}; - -// defined in qlogging.cpp -extern Q_CORE_EXPORT QString qMessageFormatString(QtMsgType type, - const QMessageLogContext &context, - const QString &str); - -Q_CORE_EXPORT void qWinMessageHandler(QtMsgType t, const QMessageLogContext &context, const QString &str) -{ - // cannot use QMutex here, because qWarning()s in the QMutex - // implementation may cause this function to recurse - static QWinMsgHandlerCriticalSection staticCriticalSection; - - QString message = qMessageFormatString(t, context, str); - - // OutputDebugString is not threadsafe. - staticCriticalSection.lock(); - OutputDebugString((wchar_t*)message.utf16()); - staticCriticalSection.unlock(); -} - -Q_CORE_EXPORT void qWinMsgHandler(QtMsgType t, const char *str) -{ - QMessageLogContext emptyContext; - qWinMessageHandler(t, emptyContext, QString::fromLocal8Bit(str)); -} - /***************************************************************************** qWinMain() - Initializes Windows. Called from WinMain() in qtmain_win.cpp *****************************************************************************/ @@ -187,9 +147,6 @@ void qWinMain(HINSTANCE instance, HINSTANCE prevInstance, LPSTR cmdParam, already_called = true; usingWinMain = true; - // Install default debug handler - qInstallMessageHandler(qWinMessageHandler); - // Create command line argv = qWinCmdLine<char>(cmdParam, int(strlen(cmdParam)), argc); |