Logging: Remove mutex for OutputDebugString
authorKai Koehne <kai.koehne@nokia.com>
Tue, 28 Aug 2012 07:22:06 +0000 (09:22 +0200)
committerQt by Nokia <qt-info@nokia.com>
Thu, 30 Aug 2012 04:22:45 +0000 (06:22 +0200)
OutputDebugString seems indeed to be thread safe, at least according
to http://www.unixwiz.net/techtips/outputdebugstring.html . I also didn't
manage to run into any deadlocks on Windows 7 ...

The comment + code was already there (in qcoreapplication_win.cpp) in
the first git commit that imported Qt.

Change-Id: I442e22575558958ef21ab8c6b4cc8b03aee906b2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
src/corelib/global/qlogging.cpp
src/testlib/qplaintestlogger.cpp

index ca85ad2..64bc3b2 100644 (file)
@@ -710,9 +710,6 @@ static void qDefaultMessageHandler(QtMsgType type, const QMessageLogContext &con
     if (usingWinMain)
 #endif
     {
-        // OutputDebugString is not threadsafe.
-        static QBasicMutex outputDebugStringMutex;
-        QMutexLocker locker(&outputDebugStringMutex);
         OutputDebugString(reinterpret_cast<const wchar_t *>(logMessage.utf16()));
         return;
     }
index 5a451b3..e4c636c 100644 (file)
@@ -66,10 +66,6 @@ QT_BEGIN_NAMESPACE
 
 namespace QTest {
 
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
-    static CRITICAL_SECTION outputCriticalSection;
-#endif
-
     static const char *incidentType2String(QAbstractTestLogger::IncidentTypes type)
     {
         switch (type) {
@@ -209,10 +205,7 @@ void QPlainTestLogger::outputMessage(const char *str)
     } while (!strUtf16.isEmpty());
     if (stream != stdout)
 #elif defined(Q_OS_WIN)
-    EnterCriticalSection(&QTest::outputCriticalSection);
-    // OutputDebugString is not threadsafe
     OutputDebugStringA(str);
-    LeaveCriticalSection(&QTest::outputCriticalSection);
 #endif
     outputString(str);
 }
@@ -310,16 +303,10 @@ void QPlainTestLogger::printBenchmarkResult(const QBenchmarkResult &result)
 QPlainTestLogger::QPlainTestLogger(const char *filename)
     : QAbstractTestLogger(filename)
 {
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
-    InitializeCriticalSection(&QTest::outputCriticalSection);
-#endif
 }
 
 QPlainTestLogger::~QPlainTestLogger()
 {
-#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
-       DeleteCriticalSection(&QTest::outputCriticalSection);
-#endif
 }
 
 void QPlainTestLogger::startLogging()