summaryrefslogtreecommitdiffstats
path: root/src/corelib/global/qlogging.cpp
diff options
context:
space:
mode:
authorThiago Macieira <thiago.macieira@intel.com>2023-08-28 19:32:27 -0700
committerThiago Macieira <thiago.macieira@intel.com>2023-09-09 11:55:41 -0700
commitb24630ce028847e52dfcf23769f5d19fb1c33c03 (patch)
treeeef662b35b128b1cc19f89f5dacce00add0bf338 /src/corelib/global/qlogging.cpp
parent62b53011d351ddc97a923900c2bfeb0b13b8264b (diff)
QLogging: attempt to free memory in qt_message() before abort()
Just so memory leak checkers won't complain. Pick-to: 6.6 Change-Id: I2b24e1d3cad44897906efffd177fb9ddf0eb0a2a Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Diffstat (limited to 'src/corelib/global/qlogging.cpp')
-rw-r--r--src/corelib/global/qlogging.cpp12
1 files changed, 8 insertions, 4 deletions
diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp
index 1585538b3bb..5e4d538bb3e 100644
--- a/src/corelib/global/qlogging.cpp
+++ b/src/corelib/global/qlogging.cpp
@@ -162,10 +162,11 @@ Q_TRACE_POINT(qtcore, qt_message_print, int type, const char *category, const ch
\snippet code/src_corelib_global_qglobal.cpp 4
*/
+template <typename String>
#if !defined(Q_CC_MSVC_ONLY)
Q_NORETURN
#endif
-static void qt_message_fatal(QtMsgType, const QMessageLogContext &context, const QString &message);
+static void qt_message_fatal(QtMsgType, const QMessageLogContext &context, String &&message);
static void qt_message_print(QtMsgType, const QMessageLogContext &context, const QString &message);
static void qt_message_print(const QString &message);
@@ -1996,7 +1997,8 @@ static void qt_message_print(const QString &message)
fflush(stderr);
}
-static void qt_message_fatal(QtMsgType, const QMessageLogContext &context, const QString &message)
+template <typename String>
+static void qt_message_fatal(QtMsgType, const QMessageLogContext &context, String &&message)
{
#if defined(Q_CC_MSVC_ONLY) && defined(QT_DEBUG) && defined(_DEBUG) && defined(_CRT_ERROR)
wchar_t contextFileL[256];
@@ -2017,13 +2019,15 @@ static void qt_message_fatal(QtMsgType, const QMessageLogContext &context, const
_CrtDbgBreak();
#else
Q_UNUSED(context);
- Q_UNUSED(message);
#endif
+ if constexpr (std::is_class_v<String> && !std::is_const_v<String>)
+ message.clear();
+ else
+ Q_UNUSED(message);
qAbort();
}
-
/*!
\internal
*/