From 1dd4790aeef17f056840bfea6c438075adbaaa03 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Wed, 12 Sep 2012 10:42:25 +0200 Subject: Autotests: Use qInstallMessageHandler qInstallMsgHandler got deprecated in Qt 5. Change-Id: Ib36983e66b3a8090b99f14e3fd4e210602a3f018 Reviewed-by: Qt Doc Bot Reviewed-by: Thiago Macieira --- .../other/qvariant_common/tst_qvariant_common.h | 22 ++++++++++------------ 1 file changed, 10 insertions(+), 12 deletions(-) (limited to 'tests/auto/other/qvariant_common') diff --git a/tests/auto/other/qvariant_common/tst_qvariant_common.h b/tests/auto/other/qvariant_common/tst_qvariant_common.h index 63d236dfde..0e1b453ca1 100644 --- a/tests/auto/other/qvariant_common/tst_qvariant_common.h +++ b/tests/auto/other/qvariant_common/tst_qvariant_common.h @@ -47,22 +47,21 @@ struct MessageHandlerInvalidType { MessageHandlerInvalidType() - : oldMsgHandler(qInstallMsgHandler(handler)) + : oldMsgHandler(qInstallMessageHandler(handler)) { ok = false; } ~MessageHandlerInvalidType() { - qInstallMsgHandler(oldMsgHandler); + qInstallMessageHandler(oldMsgHandler); } - QtMsgHandler oldMsgHandler; + QtMessageHandler oldMsgHandler; - static void handler(QtMsgType type, const char *txt) + static void handler(QtMsgType type, const QMessageLogContext & /*ctxt*/, const QString &msg) { Q_UNUSED(type); - QString msg = QString::fromLatin1(txt); // uint(-1) can be platform dependent so we check only beginning of the message. ok = msg.startsWith("Trying to construct an instance of an invalid type, type id:"); QVERIFY2(ok, (QString::fromLatin1("Message is not started correctly: '") + msg + '\'').toLatin1().constData()); @@ -74,15 +73,15 @@ bool MessageHandlerInvalidType::ok; class MessageHandler { public: - MessageHandler(const int typeId, QtMsgHandler msgHandler = handler) - : oldMsgHandler(qInstallMsgHandler(msgHandler)) + MessageHandler(const int typeId, QtMessageHandler msgHandler = handler) + : oldMsgHandler(qInstallMessageHandler(msgHandler)) { currentId = typeId; } ~MessageHandler() { - qInstallMsgHandler(oldMsgHandler); + qInstallMessageHandler(oldMsgHandler); } bool testPassed() const @@ -90,9 +89,8 @@ public: return ok; } protected: - static void handler(QtMsgType, const char *txt) + static void handler(QtMsgType, const QMessageLogContext &, const QString &msg) { - QString msg = QString::fromLatin1(txt); // Format itself is not important, but basic data as a type name should be included in the output ok = msg.startsWith("QVariant("); QVERIFY2(ok, (QString::fromLatin1("Message is not started correctly: '") + msg + '\'').toLatin1().constData()); @@ -114,7 +112,7 @@ protected: } - QtMsgHandler oldMsgHandler; + QtMessageHandler oldMsgHandler; static int currentId; static bool ok; }; @@ -224,4 +222,4 @@ int MessageHandler::currentId; QCOMPARE(val.canConvert(QVariant::ULongLong), ULongLongCast); -#endif \ No newline at end of file +#endif -- cgit v1.2.3