diff options
Diffstat (limited to 'tools')
-rw-r--r-- | tools/qml/main.cpp | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/tools/qml/main.cpp b/tools/qml/main.cpp index d0817bc..d5ad9ad 100644 --- a/tools/qml/main.cpp +++ b/tools/qml/main.cpp @@ -49,6 +49,7 @@ #include <QTranslator> #include <QDebug> #include <QMessageBox> +#include <QAtomicInt> #include "qdeclarativetester.h" QT_USE_NAMESPACE @@ -89,19 +90,25 @@ void showWarnings() } } +static QAtomicInt recursiveLock(0); + void myMessageOutput(QtMsgType type, const char *msg) { + QString strMsg = QString::fromLatin1(msg); + if (!logger.isNull() && !QCoreApplication::closingDown()) { - QString strMsg = QString::fromAscii(msg); - QMetaObject::invokeMethod(logger.data(), "append", Q_ARG(QString, strMsg)); + if (recursiveLock.testAndSetOrdered(0, 1)) { + QMetaObject::invokeMethod(logger.data(), "append", Q_ARG(QString, strMsg)); + recursiveLock = 0; + } } else { - warnings += msg; + warnings += strMsg; warnings += QLatin1Char('\n'); } if (systemMsgOutput) { // Windows systemMsgOutput(type, msg); } else { // Unix - fprintf(stderr, "%s\n",msg); + fprintf(stderr, "%s\n", msg); fflush(stderr); } } |