diff options
author | Kai Koehne <kai.koehne@nokia.com> | 2012-09-13 14:47:47 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-09-14 14:51:39 +0200 |
commit | aa6d27f043f0367ea4c16bb255f65b2a6abb5921 (patch) | |
tree | 663c468830121f3cd3abc8a85a9cae3a2b7a8311 /tools | |
parent | cf5b6c3ef72df623117678de01fd5557861ba73b (diff) |
Use qInstallMessageHandler
qInstallMsgHandler got deprecated in Qt 5.
Change-Id: I87f5f8d5b28afcbcf8a9c613d1d4b1199f5f4254
Reviewed-by: Martin Jones <martin.r.jones@gmail.com>
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qml/main.cpp | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp index 1ac52f08..a108ec5f 100644 --- a/tools/qml/main.cpp +++ b/tools/qml/main.cpp @@ -59,7 +59,7 @@ QT_USE_NAMESPACE -QtMsgHandler systemMsgOutput = 0; +QtMessageHandler systemMsgOutput = 0; static QDeclarativeViewer *openFile(const QString &fileName); static void showViewer(QDeclarativeViewer *viewer); @@ -80,26 +80,24 @@ void exitApp(int i) QPointer<LoggerWidget> logger; static QAtomicInt recursiveLock(0); -void myMessageOutput(QtMsgType type, const char *msg) +void myMessageOutput(QtMsgType type, const QMessageLogContext &ctxt, const QString &msg) { - QString strMsg = QString::fromLatin1(msg); - if (!QCoreApplication::closingDown()) { if (!logger.isNull()) { if (recursiveLock.testAndSetOrdered(0, 1)) { - QMetaObject::invokeMethod(logger.data(), "append", Q_ARG(QString, strMsg)); + QMetaObject::invokeMethod(logger.data(), "append", Q_ARG(QString, msg)); recursiveLock = 0; } } else { - warnings += strMsg; + warnings += msg; warnings += QLatin1Char('\n'); } } if (systemMsgOutput) { - systemMsgOutput(type, msg); + systemMsgOutput(type, ctxt, msg); } else { // Unix - fprintf(stderr, "%s\n", msg); + fprintf(stderr, "%s\n", msg.toLocal8Bit().constData()); fflush(stderr); } } @@ -538,7 +536,7 @@ static bool checkVersion(const QString &fileName) int main(int argc, char ** argv) { - systemMsgOutput = qInstallMsgHandler(myMessageOutput); + systemMsgOutput = qInstallMessageHandler(myMessageOutput); Application app(argc, argv); app.setApplicationName(QLatin1String("QtQmlViewer")); |