diff options
author | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2014-02-06 14:21:16 +0100 |
---|---|---|
committer | Frederik Gladhorn <frederik.gladhorn@digia.com> | 2014-02-07 13:07:25 +0100 |
commit | a1fe728fa5bd6cb9e50cf317a58efcf4eea4de2c (patch) | |
tree | 0798ae897d111147238544826c79243b6f9a48a4 /src/corelib/global | |
parent | 57fe9bd2c6a361cf979d17d962abed5db17a1457 (diff) | |
parent | 65bd80ebfc1be81a196a861ade40ff874a3554f0 (diff) |
Merge remote-tracking branch 'origin/stable' into dev
Conflicts:
src/gui/kernel/qguiapplication.cpp
src/plugins/platforms/android/androidjnimain.cpp
src/plugins/platforms/android/qandroidplatformintegration.cpp
src/plugins/platforms/android/qandroidplatformintegration.h
src/plugins/platforms/android/qandroidplatformopenglcontext.cpp
src/plugins/platforms/cocoa/qcocoawindow.h
src/plugins/platforms/cocoa/qcocoawindow.mm
src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
src/sql/doc/src/sql-driver.qdoc
src/widgets/widgets/qtoolbararealayout.cpp
Change-Id: Ifd7e58760c3cb6bd8a7d1dd32ef83b7ec190d41e
Diffstat (limited to 'src/corelib/global')
-rw-r--r-- | src/corelib/global/qglobal.cpp | 8 | ||||
-rw-r--r-- | src/corelib/global/qglobal.h | 8 | ||||
-rw-r--r-- | src/corelib/global/qlogging.cpp | 43 |
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()); } } |