summaryrefslogtreecommitdiffstats
path: root/src/corelib/global
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib/global')
-rw-r--r--src/corelib/global/qglobal.cpp8
-rw-r--r--src/corelib/global/qglobal.h8
-rw-r--r--src/corelib/global/qlogging.cpp43
3 files changed, 48 insertions, 11 deletions
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index e84c31eecf..fe10c493a7 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -1988,7 +1988,7 @@ const QSysInfo::WinVersion QSysInfo::WindowsVersion = QSysInfo::windowsVersion()
conditions that it would not otherwise know about. However, there is no
guarantee that the compiler will actually use those hints.
- This macro could be considered a "lighter" version of \l{Q_ASSERT}. While
+ This macro could be considered a "lighter" version of \l{Q_ASSERT()}. While
Q_ASSERT will abort the program's execution if the condition is false,
Q_ASSUME will tell the compiler not to generate code for those conditions.
Therefore, it is important that the assumptions always hold, otherwise
@@ -3359,7 +3359,7 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters)
If you need C++11 noexcept semantics, don't use this macro, use
Q_DECL_NOEXCEPT/Q_DECL_NOEXCEPT_EXPR instead.
- \sa Q_DECL_NOEXCEPT, Q_DECL_NOEXCEPT_EXPR
+ \sa Q_DECL_NOEXCEPT, Q_DECL_NOEXCEPT_EXPR()
*/
/*!
@@ -3413,7 +3413,7 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters)
function can't possibly throw, don't use this macro, use
Q_DECL_NOTHROW instead.
- \sa Q_DECL_NOTHROW, Q_DECL_NOEXCEPT_EXPR
+ \sa Q_DECL_NOTHROW, Q_DECL_NOEXCEPT_EXPR()
*/
/*!
@@ -3435,7 +3435,7 @@ bool QInternal::activateCallbacks(Callback cb, void **parameters)
function can't possibly throw, don't use this macro, use
Q_DECL_NOTHROW instead.
- \sa Q_DECL_NOTHROW, Q_DECL_NOEXCEPT_EXPR
+ \sa Q_DECL_NOTHROW, Q_DECL_NOEXCEPT
*/
/*!
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index 1e9b20757d..6a6656a6f6 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -838,9 +838,13 @@ Q_CORE_EXPORT void qFreeAligned(void *ptr);
# pragma warning(disable: 4800) /* 'type' : forcing value to bool 'true' or 'false' (performance warning) */
# pragma warning(disable: 4097) /* typedef-name 'identifier1' used as synonym for class-name 'identifier2' */
# pragma warning(disable: 4706) /* assignment within conditional expression */
-# pragma warning(disable: 4786) /* 'identifier' : identifier was truncated to 'number' characters in the debug information */
+# if _MSC_VER <= 1310 // MSVC 2003
+# pragma warning(disable: 4786) /* 'identifier' : identifier was truncated to 'number' characters in the debug information */
+# endif
# pragma warning(disable: 4355) /* 'this' : used in base member initializer list */
-# pragma warning(disable: 4231) /* nonstandard extension used : 'identifier' before template explicit instantiation */
+# if _MSC_VER < 1800 // MSVC 2013
+# pragma warning(disable: 4231) /* nonstandard extension used : 'identifier' before template explicit instantiation */
+# endif
# pragma warning(disable: 4710) /* function not inlined */
# pragma warning(disable: 4530) /* C++ exception handler used, but unwind semantics are not enabled. Specify /EHsc */
# elif defined(Q_CC_BOR)
diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp
index dbe28da120..10b0d63fb0 100644
--- a/src/corelib/global/qlogging.cpp
+++ b/src/corelib/global/qlogging.cpp
@@ -1244,6 +1244,32 @@ static void qDefaultMsgHandler(QtMsgType type, const char *buf)
qDefaultMessageHandler(type, emptyContext, QString::fromLocal8Bit(buf));
}
+#if defined(Q_COMPILER_THREAD_LOCAL) || (defined(Q_CC_MSVC) && !defined(Q_OS_WINCE))
+#if defined(Q_CC_MSVC)
+static __declspec(thread) bool msgHandlerGrabbed = false;
+#else
+static thread_local bool msgHandlerGrabbed = false;
+#endif
+
+static bool grabMessageHandler()
+{
+ if (msgHandlerGrabbed)
+ return false;
+
+ msgHandlerGrabbed = true;
+ return true;
+}
+
+static void ungrabMessageHandler()
+{
+ msgHandlerGrabbed = false;
+}
+
+#else
+static bool grabMessageHandler() { return true; }
+static void ungrabMessageHandler() { }
+#endif // (Q_COMPILER_THREAD_LOCAL) || ((Q_CC_MSVC) && !(Q_OS_WINCE))
+
static void qt_message_print(QtMsgType msgType, const QMessageLogContext &context, const QString &message)
{
#ifndef QT_BOOTSTRAPPED
@@ -1261,12 +1287,19 @@ static void qt_message_print(QtMsgType msgType, const QMessageLogContext &contex
if (!messageHandler)
messageHandler = qDefaultMessageHandler;
- // prefer new message handler over the old one
- if (msgHandler == qDefaultMsgHandler
- || messageHandler != qDefaultMessageHandler) {
- (*messageHandler)(msgType, context, message);
+ // prevent recursion in case the message handler generates messages
+ // itself, e.g. by using Qt API
+ if (grabMessageHandler()) {
+ // prefer new message handler over the old one
+ if (msgHandler == qDefaultMsgHandler
+ || messageHandler != qDefaultMessageHandler) {
+ (*messageHandler)(msgType, context, message);
+ } else {
+ (*msgHandler)(msgType, message.toLocal8Bit().constData());
+ }
+ ungrabMessageHandler();
} else {
- (*msgHandler)(msgType, message.toLocal8Bit().constData());
+ fprintf(stderr, "%s", message.toLocal8Bit().constData());
}
}