summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/testlib/qtestcase.h5
1 files changed, 3 insertions, 2 deletions
diff --git a/src/testlib/qtestcase.h b/src/testlib/qtestcase.h
index bd65c0ecab3..95a1d9160a6 100644
--- a/src/testlib/qtestcase.h
+++ b/src/testlib/qtestcase.h
@@ -315,16 +315,17 @@ namespace QTest
template <typename T> // Fallback; for built-in types debug streaming must be possible
inline typename std::enable_if<!QtPrivate::IsQEnumHelper<T>::Value && !std::is_enum_v<T>, char *>::type toString(const T &t)
{
+ char *result = nullptr;
#ifndef QT_NO_DEBUG_STREAM
if constexpr (QTypeTraits::has_ostream_operator_v<QDebug, T>) {
- return qstrdup(QDebug::toString(t).toUtf8().constData());
+ result = qstrdup(QDebug::toString(t).toUtf8().constData());
} else {
static_assert(!QMetaTypeId2<T>::IsBuiltIn,
"Built-in type must implement debug streaming operator "
"or provide QTest::toString specialization");
}
#endif
- return nullptr;
+ return result;
}
template<typename F> // Output QFlags of registered enumerations