From aa6d27f043f0367ea4c16bb255f65b2a6abb5921 Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Thu, 13 Sep 2012 14:47:47 +0200 Subject: Use qInstallMessageHandler qInstallMsgHandler got deprecated in Qt 5. Change-Id: I87f5f8d5b28afcbcf8a9c613d1d4b1199f5f4254 Reviewed-by: Martin Jones --- tests/auto/declarative/examples/tst_examples.cpp | 6 ++--- .../tst_qdeclarativeecmascript.cpp | 26 +++++++++++----------- .../qdeclarativeengine/tst_qdeclarativeengine.cpp | 12 +++++----- .../qdeclarativeimage/tst_qdeclarativeimage.cpp | 6 ++--- .../tst_qdeclarativeinstruction.cpp | 8 +++---- .../tst_qdeclarativepositioners.cpp | 6 ++--- .../qdeclarativeview/tst_qdeclarativeview.cpp | 6 ++--- .../qdeclarativeviewer/tst_qdeclarativeviewer.cpp | 6 ++--- .../tst_qdeclarativeworkerscript.cpp | 12 +++++----- 9 files changed, 44 insertions(+), 44 deletions(-) (limited to 'tests/auto/declarative') diff --git a/tests/auto/declarative/examples/tst_examples.cpp b/tests/auto/declarative/examples/tst_examples.cpp index 06070525..7fec0852 100644 --- a/tests/auto/declarative/examples/tst_examples.cpp +++ b/tests/auto/declarative/examples/tst_examples.cpp @@ -187,7 +187,7 @@ void tst_examples::examples_data() QTest::newRow(qPrintable(file)) << file; } -static void silentErrorsMsgHandler(QtMsgType, const char *) +static void silentErrorsMsgHandler(QtMsgType, const QMessageLogContext &, const QString &) { } @@ -197,9 +197,9 @@ void tst_examples::examples() QDeclarativeViewer viewer; - QtMsgHandler old = qInstallMsgHandler(silentErrorsMsgHandler); + QtMessageHandler old = qInstallMessageHandler(silentErrorsMsgHandler); QVERIFY(viewer.open(file)); - qInstallMsgHandler(old); + qInstallMessageHandler(old); if (viewer.view()->status() == QDeclarativeView::Error) qWarning() << viewer.view()->errors(); diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index 61d04985..c7751237 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -1210,7 +1210,7 @@ void tst_qdeclarativeecmascript::exceptionBindingProducesWarning() } static int transientErrorsMsgCount = 0; -static void transientErrorsMsgHandler(QtMsgType, const char *) +static void transientErrorsMsgHandler(QtMsgType, const QMessageLogContext &, const QString &) { ++transientErrorsMsgCount; } @@ -1222,12 +1222,12 @@ void tst_qdeclarativeecmascript::transientErrors() QDeclarativeComponent component(&engine, testFileUrl("transientErrors.qml")); transientErrorsMsgCount = 0; - QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler); + QtMessageHandler old = qInstallMessageHandler(transientErrorsMsgHandler); QObject *object = component.create(); QVERIFY(object != 0); - qInstallMsgHandler(old); + qInstallMessageHandler(old); QCOMPARE(transientErrorsMsgCount, 0); } @@ -1237,12 +1237,12 @@ void tst_qdeclarativeecmascript::transientErrors() QDeclarativeComponent component(&engine, testFileUrl("transientErrors.2.qml")); transientErrorsMsgCount = 0; - QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler); + QtMessageHandler old = qInstallMessageHandler(transientErrorsMsgHandler); QObject *object = component.create(); QVERIFY(object != 0); - qInstallMsgHandler(old); + qInstallMessageHandler(old); QCOMPARE(transientErrorsMsgCount, 0); } @@ -1256,11 +1256,11 @@ void tst_qdeclarativeecmascript::shutdownErrors() QVERIFY(object != 0); transientErrorsMsgCount = 0; - QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler); + QtMessageHandler old = qInstallMessageHandler(transientErrorsMsgHandler); delete object; - qInstallMsgHandler(old); + qInstallMessageHandler(old); QCOMPARE(transientErrorsMsgCount, 0); } @@ -2457,11 +2457,11 @@ void tst_qdeclarativeecmascript::qtbug_9792() delete context; transientErrorsMsgCount = 0; - QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler); + QtMessageHandler old = qInstallMessageHandler(transientErrorsMsgHandler); object->basicSignal(); - qInstallMsgHandler(old); + qInstallMessageHandler(old); QCOMPARE(transientErrorsMsgCount, 0); @@ -2498,11 +2498,11 @@ void tst_qdeclarativeecmascript::noSpuriousWarningsAtShutdown() QObject *o = component.create(); transientErrorsMsgCount = 0; - QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler); + QtMessageHandler old = qInstallMessageHandler(transientErrorsMsgHandler); delete o; - qInstallMsgHandler(old); + qInstallMessageHandler(old); QCOMPARE(transientErrorsMsgCount, 0); } @@ -2514,11 +2514,11 @@ void tst_qdeclarativeecmascript::noSpuriousWarningsAtShutdown() QObject *o = component.create(); transientErrorsMsgCount = 0; - QtMsgHandler old = qInstallMsgHandler(transientErrorsMsgHandler); + QtMessageHandler old = qInstallMessageHandler(transientErrorsMsgHandler); delete o; - qInstallMsgHandler(old); + qInstallMessageHandler(old); QCOMPARE(transientErrorsMsgCount, 0); } diff --git a/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp b/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp index cc8dac40..554d0b92 100644 --- a/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp +++ b/tests/auto/declarative/qdeclarativeengine/tst_qdeclarativeengine.cpp @@ -244,9 +244,9 @@ void tst_qdeclarativeengine::clearComponentCache() } static QStringList warnings; -static void msgHandler(QtMsgType, const char *warning) +static void msgHandler(QtMsgType, const QMessageLogContext &, const QString &warning) { - warnings << QString::fromUtf8(warning); + warnings << warning; } void tst_qdeclarativeengine::outputWarningsToStandardError() @@ -261,11 +261,11 @@ void tst_qdeclarativeengine::outputWarningsToStandardError() QVERIFY(c.isReady() == true); warnings.clear(); - QtMsgHandler old = qInstallMsgHandler(msgHandler); + QtMessageHandler old = qInstallMessageHandler(msgHandler); QObject *o = c.create(); - qInstallMsgHandler(old); + qInstallMessageHandler(old); QVERIFY(o != 0); delete o; @@ -279,11 +279,11 @@ void tst_qdeclarativeengine::outputWarningsToStandardError() QCOMPARE(engine.outputWarningsToStandardError(), false); - old = qInstallMsgHandler(msgHandler); + old = qInstallMessageHandler(msgHandler); o = c.create(); - qInstallMsgHandler(old); + qInstallMessageHandler(old); QVERIFY(o != 0); delete o; diff --git a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp index f05d5390..3668e899 100644 --- a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp +++ b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp @@ -686,7 +686,7 @@ void tst_qdeclarativeimage::sourceSize_QTBUG_16389() } static int numberOfWarnings = 0; -static void checkWarnings(QtMsgType, const char *) +static void checkWarnings(QtMsgType, const QMessageLogContext &, const QString &) { numberOfWarnings++; } @@ -702,14 +702,14 @@ void tst_qdeclarativeimage::nullPixmapPaint() QTRY_VERIFY(image != 0); - QtMsgHandler previousMsgHandler = qInstallMsgHandler(checkWarnings); + QtMessageHandler previousMsgHandler = qInstallMessageHandler(checkWarnings); QPixmap pm(100, 100); QPainter p(&pm); // used to print "QTransform::translate with NaN called" image->paint(&p, 0, 0); - qInstallMsgHandler(previousMsgHandler); + qInstallMessageHandler(previousMsgHandler); QVERIFY(numberOfWarnings == 0); delete image; } diff --git a/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp b/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp index 92f98faf..9ece0be9 100644 --- a/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp +++ b/tests/auto/declarative/qdeclarativeinstruction/tst_qdeclarativeinstruction.cpp @@ -58,9 +58,9 @@ private slots: }; static QStringList messages; -static void msgHandler(QtMsgType, const char *msg) +static void msgHandler(QtMsgType, const QMessageLogContext &, const QString &msg) { - messages << QLatin1String(msg); + messages << msg; } void tst_qdeclarativeinstruction::dump() @@ -592,9 +592,9 @@ void tst_qdeclarativeinstruction::dump() << "-------------------------------------------------------------------------------"; messages = QStringList(); - QtMsgHandler old = qInstallMsgHandler(msgHandler); + QtMessageHandler old = qInstallMessageHandler(msgHandler); data->dumpInstructions(); - qInstallMsgHandler(old); + qInstallMessageHandler(old); QCOMPARE(messages.count(), expect.count()); for (int ii = 0; ii < messages.count(); ++ii) { diff --git a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp index 23eb3f0d..ea6aaa34 100644 --- a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp +++ b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp @@ -1089,7 +1089,7 @@ void tst_QDeclarativePositioners::test_flow_implicit_resize() QString warningMessage; -void interceptWarnings(QtMsgType type, const char *msg) +void interceptWarnings(QtMsgType type, const QMessageLogContext &, const QString &msg) { Q_UNUSED( type ); warningMessage = msg; @@ -1097,7 +1097,7 @@ void interceptWarnings(QtMsgType type, const char *msg) void tst_QDeclarativePositioners::test_conflictinganchors() { - QtMsgHandler oldMsgHandler = qInstallMsgHandler(interceptWarnings); + QtMessageHandler oldMsgHandler = qInstallMessageHandler(interceptWarnings); QDeclarativeEngine engine; QDeclarativeComponent component(&engine); @@ -1178,7 +1178,7 @@ void tst_QDeclarativePositioners::test_conflictinganchors() item = qobject_cast(component.create()); QVERIFY(item); QCOMPARE(warningMessage, QString("file::2:1: QML Flow: Cannot specify anchors for items inside Flow")); - qInstallMsgHandler(oldMsgHandler); + qInstallMessageHandler(oldMsgHandler); } void tst_QDeclarativePositioners::test_vertical_qgraphicswidget() diff --git a/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp b/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp index 4562ea3f..8308cd52 100644 --- a/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp +++ b/tests/auto/declarative/qdeclarativeview/tst_qdeclarativeview.cpp @@ -276,7 +276,7 @@ void tst_QDeclarativeView::resizemodegraphicswidget() delete canvas; } -static void silentErrorsMsgHandler(QtMsgType, const char *) +static void silentErrorsMsgHandler(QtMsgType, const QMessageLogContext &, const QString &) { } @@ -284,9 +284,9 @@ void tst_QDeclarativeView::errors() { QDeclarativeView *canvas = new QDeclarativeView; QVERIFY(canvas); - QtMsgHandler old = qInstallMsgHandler(silentErrorsMsgHandler); + QtMessageHandler old = qInstallMessageHandler(silentErrorsMsgHandler); canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/error1.qml")); - qInstallMsgHandler(old); + qInstallMessageHandler(old); QVERIFY(canvas->status() == QDeclarativeView::Error); QVERIFY(canvas->errors().count() == 1); delete canvas; diff --git a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp index 35d2a24f..23e6dd95 100644 --- a/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp +++ b/tests/auto/declarative/qdeclarativeviewer/tst_qdeclarativeviewer.cpp @@ -239,21 +239,21 @@ void tst_QDeclarativeViewer::loading() } static int numberOfWarnings = 0; -static void checkWarnings(QtMsgType, const char *) +static void checkWarnings(QtMsgType, const QMessageLogContext &, const QString &) { numberOfWarnings++; } void tst_QDeclarativeViewer::fileBrowser() { - QtMsgHandler previousMsgHandler = qInstallMsgHandler(checkWarnings); + QtMessageHandler previousMsgHandler = qInstallMessageHandler(checkWarnings); QDeclarativeViewer *viewer = new QDeclarativeViewer(); QVERIFY(viewer); viewer->setUseNativeFileBrowser(false); viewer->openFile(); viewer->show(); QCoreApplication::processEvents(); - qInstallMsgHandler(previousMsgHandler); + qInstallMessageHandler(previousMsgHandler); // QTBUG-15720 QVERIFY(numberOfWarnings == 0); diff --git a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp index b11564cd..209da67f 100644 --- a/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp +++ b/tests/auto/declarative/qdeclarativeworkerscript/tst_qdeclarativeworkerscript.cpp @@ -234,24 +234,24 @@ void tst_QDeclarativeWorkerScript::script_included() } static QString qdeclarativeworkerscript_lastWarning; -static void qdeclarativeworkerscript_warningsHandler(QtMsgType type, const char *msg) +static void qdeclarativeworkerscript_warningsHandler(QtMsgType type, const QMessageLogContext &, const QString &msg) { if (type == QtWarningMsg) - qdeclarativeworkerscript_lastWarning = QString::fromUtf8(msg); + qdeclarativeworkerscript_lastWarning = msg; } void tst_QDeclarativeWorkerScript::scriptError_onLoad() { QDeclarativeComponent component(&m_engine, testFileUrl("worker_error_onLoad.qml")); - QtMsgHandler previousMsgHandler = qInstallMsgHandler(qdeclarativeworkerscript_warningsHandler); + QtMessageHandler previousMsgHandler = qInstallMessageHandler(qdeclarativeworkerscript_warningsHandler); QDeclarativeWorkerScript *worker = qobject_cast(component.create()); QVERIFY(worker != 0); QTRY_COMPARE(qdeclarativeworkerscript_lastWarning, testFileUrl("script_error_onLoad.js").toString() + QLatin1String(":3: SyntaxError: Parse error")); - qInstallMsgHandler(previousMsgHandler); + qInstallMessageHandler(previousMsgHandler); qApp->processEvents(); delete worker; } @@ -262,14 +262,14 @@ void tst_QDeclarativeWorkerScript::scriptError_onCall() QDeclarativeWorkerScript *worker = qobject_cast(component.create()); QVERIFY(worker != 0); - QtMsgHandler previousMsgHandler = qInstallMsgHandler(qdeclarativeworkerscript_warningsHandler); + QtMessageHandler previousMsgHandler = qInstallMessageHandler(qdeclarativeworkerscript_warningsHandler); QVariant value; QVERIFY(QMetaObject::invokeMethod(worker, "testSend", Q_ARG(QVariant, value))); QTRY_COMPARE(qdeclarativeworkerscript_lastWarning, testFileUrl("script_error_onCall.js").toString() + QLatin1String(":4: ReferenceError: Can't find variable: getData")); - qInstallMsgHandler(previousMsgHandler); + qInstallMessageHandler(previousMsgHandler); qApp->processEvents(); delete worker; } -- cgit v1.2.3