summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@woboq.com>2014-08-02 20:15:33 +0200
committerOlivier Goffart <ogoffart@woboq.com>2014-08-05 16:52:34 +0200
commit27b67c5399bc068b4bff34dc53b07b0f6b277617 (patch)
tree7b5c432f1fdc8d80721a1b88501444cbc9a845a2
parentdecb88693c8a7f0c073889b91151f01a850e3adf (diff)
Logging: use the known function when the first frame of the backtrace is unknown
Change-Id: Ia591805c82e7bf77dc7af04f1054c7daca58eb6a Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
-rw-r--r--src/corelib/global/qlogging.cpp10
-rw-r--r--tests/auto/corelib/global/qlogging/tst_qlogging.cpp3
2 files changed, 9 insertions, 4 deletions
diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp
index 013efec3d5..465e2a4b45 100644
--- a/src/corelib/global/qlogging.cpp
+++ b/src/corelib/global/qlogging.cpp
@@ -1161,10 +1161,14 @@ QString qFormatLogMessage(QtMsgType type, const QMessageLogContext &context, con
if (numberPrinted > 0)
message.append(pattern->backtraceSeparator);
- if (function.isEmpty())
- message += QLatin1Char('?') + library + QLatin1Char('?');
- else
+ if (function.isEmpty()) {
+ if (numberPrinted == 0 && context.function)
+ message += QString::fromUtf8(qCleanupFuncinfo(context.function));
+ else
+ message += QLatin1Char('?') + library + QLatin1Char('?');
+ } else {
message += function;
+ }
} else {
if (numberPrinted == 0)
diff --git a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp
index 1df5404995..ccf0d2d4a8 100644
--- a/tests/auto/corelib/global/qlogging/tst_qlogging.cpp
+++ b/tests/auto/corelib/global/qlogging/tst_qlogging.cpp
@@ -720,7 +720,8 @@ void tst_qmessagehandler::qMessagePattern_data()
#endif
QTest::newRow("backtrace depth,separator") << "[%{backtrace depth=2 separator=\"\n\"}] %{message}" << true << (QList<QByteArray>()
- << "[MyClass::myFunction\nMyClass::mySlot1] from_a_function 34");
+ << "[MyClass::myFunction\nMyClass::mySlot1] from_a_function 34"
+ << "[T::T\n");
#endif
}