From c3e785eec23322cb2d8eb1cbb6460802ad0a4fe9 Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Mon, 10 Aug 2009 08:13:55 +0200 Subject: Prevent a crash when there is no QTest::logger when calling warn() Also, the info() function was modified to use an assert rather than an pointer check with an if to make it consistent with the rest of the file. Reviewed-by: jesperht --- src/testlib/qtestlog.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'src/testlib') diff --git a/src/testlib/qtestlog.cpp b/src/testlib/qtestlog.cpp index 3ca5496b69..c7b2c17872 100644 --- a/src/testlib/qtestlog.cpp +++ b/src/testlib/qtestlog.cpp @@ -297,6 +297,7 @@ void QTestLog::stopLogging() void QTestLog::warn(const char *msg) { + QTEST_ASSERT(QTest::testLogger); QTEST_ASSERT(msg); QTest::testLogger->addMessage(QAbstractTestLogger::Warn, msg); @@ -304,9 +305,10 @@ void QTestLog::warn(const char *msg) void QTestLog::info(const char *msg, const char *file, int line) { + QTEST_ASSERT(QTest::testLogger); QTEST_ASSERT(msg); + QTEST_ASSERT(file); - if (QTest::testLogger) QTest::testLogger->addMessage(QAbstractTestLogger::Info, msg, file, line); } -- cgit v1.2.3