diff options
author | Liang Qi <liang.qi@qt.io> | 2017-07-06 13:52:42 +0200 |
---|---|---|
committer | Liang Qi <liang.qi@qt.io> | 2017-07-06 13:54:25 +0200 |
commit | 7f269a5db8b88fbb14ee741f78e726b1a46c7d4d (patch) | |
tree | fa63387e6f70187e656dd9e6c4f1cd1b1f96c263 /src/corelib/global | |
parent | 9ca3443a37284bedaf74475c26af173b00757178 (diff) | |
parent | 03b4838cb51513bd5d2edf76dccc4bc4a1181681 (diff) |
Merge remote-tracking branch 'origin/5.9' into dev
Conflicts:
.qmake.conf
Change-Id: I43531e087bb810889d5c1fbfcdffb29b78804839
Diffstat (limited to 'src/corelib/global')
-rw-r--r-- | src/corelib/global/qglobal.cpp | 27 | ||||
-rw-r--r-- | src/corelib/global/qglobal.h | 2 |
2 files changed, 21 insertions, 8 deletions
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 9c05b9650c..0e99daeb56 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -96,6 +96,12 @@ #include "archdetect.cpp" +#ifdef qFatal +// the qFatal in this file are just redirections from elsewhere, so +// don't capture any context again +# undef qFatal +#endif + QT_BEGIN_NAMESPACE #if !QT_DEPRECATED_SINCE(5, 0) @@ -3056,13 +3062,20 @@ QString QSysInfo::machineHostName() If this macro is used outside a function, the behavior is undefined. */ -/* - The Q_CHECK_PTR macro calls this function if an allocation check - fails. +/*! + \internal + The Q_CHECK_PTR macro calls this function if an allocation check + fails. */ -void qt_check_pointer(const char *n, int l) +void qt_check_pointer(const char *n, int l) Q_DECL_NOTHROW { - qFatal("In file %s, line %d: Out of memory", n, l); + // make separate printing calls so that the first one may flush; + // the second one could want to allocate memory (fputs prints a + // newline and stderr auto-flushes). + fputs("Out of memory", stderr); + fprintf(stderr, " in %s, line %d\n", n, l); + + std::terminate(); } /* @@ -3092,7 +3105,7 @@ Q_NORETURN void qTerminate() Q_DECL_NOTHROW */ void qt_assert(const char *assertion, const char *file, int line) Q_DECL_NOTHROW { - qFatal("ASSERT: \"%s\" in file %s, line %d", assertion, file, line); + QMessageLogger(file, line, nullptr).fatal("ASSERT: \"%s\" in file %s, line %d", assertion, file, line); } /* @@ -3100,7 +3113,7 @@ void qt_assert(const char *assertion, const char *file, int line) Q_DECL_NOTHROW */ void qt_assert_x(const char *where, const char *what, const char *file, int line) Q_DECL_NOTHROW { - qFatal("ASSERT failure in %s: \"%s\", file %s, line %d", where, what, file, line); + QMessageLogger(file, line, nullptr).fatal("ASSERT failure in %s: \"%s\", file %s, line %d", where, what, file, line); } diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index dccbe52ab3..429cd63ab6 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -771,7 +771,7 @@ template <> class QStaticAssertFailure<true> {}; #define Q_STATIC_ASSERT_X(Condition, Message) Q_STATIC_ASSERT(Condition) #endif -Q_CORE_EXPORT void qt_check_pointer(const char *, int); +Q_NORETURN Q_CORE_EXPORT void qt_check_pointer(const char *, int) Q_DECL_NOTHROW; Q_CORE_EXPORT void qBadAlloc(); #ifdef QT_NO_EXCEPTIONS |