summaryrefslogtreecommitdiffstats
path: root/src/corelib/global/qlogging.cpp
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2012-08-03 10:38:00 +0200
committerQt by Nokia <qt-info@nokia.com>2012-08-09 03:26:17 +0200
commitc856e37c5fddec64d8635f3dae57b9cbea1aada4 (patch)
tree08233d5e1c6ee74811a1ae9e644d8b317c80818b /src/corelib/global/qlogging.cpp
parent7ef395224ea42a9a8d3469194d960077d7ff21eb (diff)
Logging: mark qt_assert()/qt_assert_x()/qFatal() as nothrow
These functions are not supposed to return, not even by exception. qt_message() _can_ throw, but we're fine with the compiler calling std::terminate() then, since the backtrace will still include the assertion location. This behaviour is ensured by a new macro, QT_TERMINATE_ON_EXCEPTION, which expands to something like try { expr; } catch(...) { std::terminate(); } if the compiler doesn't support Q_DECL_NOEXCEPT (but maybe Q_DECL_NOTHROW), and to something like just expr; otherwise (including in the QT_NO_EXCEPTION case). The real macro preserves scopes in all cases, and aims to work even if <exception> isn't included in the TU it's used in, so is a little bit more complex than that. Change-Id: Ie6a2b7776e6aa77e57bd9aea6e184e5fa1cec81c Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/corelib/global/qlogging.cpp')
-rw-r--r--src/corelib/global/qlogging.cpp4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp
index bb12807f9a..527021381a 100644
--- a/src/corelib/global/qlogging.cpp
+++ b/src/corelib/global/qlogging.cpp
@@ -240,11 +240,11 @@ QDebug QMessageLogger::critical()
#endif
#undef qFatal
-void QMessageLogger::fatal(const char *msg, ...)
+void QMessageLogger::fatal(const char *msg, ...) Q_DECL_NOTHROW
{
va_list ap;
va_start(ap, msg); // use variable arg list
- qt_message(QtFatalMsg, context, msg, ap);
+ QT_TERMINATE_ON_EXCEPTION(qt_message(QtFatalMsg, context, msg, ap));
#ifndef Q_CC_MSVC
Q_UNREACHABLE();
#endif