diff options
Diffstat (limited to 'src/corelib/global')
-rw-r--r-- | src/corelib/global/qglobal.cpp | 17 | ||||
-rw-r--r-- | src/corelib/global/qglobal.h | 2 |
2 files changed, 13 insertions, 6 deletions
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 4f0110dca4..9b76c72c0d 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -3016,13 +3016,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 { - QMessageLogger(n, l, nullptr).fatal("Out of memory"); + // 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(); } /* diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index f2f28343c6..0c74ed4a3e 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -753,7 +753,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 |