summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2017-06-14 14:46:33 -0700
committerThiago Macieira <thiago.macieira@intel.com>2017-07-03 16:01:10 +0000
commit2b991efc476c7d50ee606dd4ddb7d15777bbfe8e (patch)
tree129e18eeb8e41c820b5aa095bc4f04613652496c /src
parentfb046c932f0d1c54a2baf3633de26926c939082b (diff)
Use QMessageLogger context properly in qglobal.cpp redirects
qt_assert and qt_check_pointer get the function name and line number from the caller (the functions are called from the Q_ASSERT and Q_CHECK_PTR macros, respectively), so we don't need to capture the context from those two functions. Instead, pass the context to QMessageLogger for proper logging. I've left the file name and line number in the assertions, for users who did not add them to their message log pattern, but I've removed from the almost never used qt_check_pointer function. Note: how useful is it that we allocate memory in response to failing to allocate memory? Change-Id: Ia53158e207a94bf49489fffd14c81b359c5b6537 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io> Reviewed-by: Kai Koehne <kai.koehne@qt.io>
Diffstat (limited to 'src')
-rw-r--r--src/corelib/global/qglobal.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 5b57e1ad61..4f0110dca4 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -97,6 +97,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)
@@ -3016,7 +3022,7 @@ QString QSysInfo::machineHostName()
*/
void qt_check_pointer(const char *n, int l)
{
- qFatal("In file %s, line %d: Out of memory", n, l);
+ QMessageLogger(n, l, nullptr).fatal("Out of memory");
}
/*
@@ -3046,7 +3052,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);
}
/*
@@ -3054,7 +3060,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);
}