summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorRobert Griebl <robert.griebl@nokia.com>2010-07-06 11:39:41 (GMT)
committerRobert Griebl <robert.griebl@nokia.com>2010-07-06 11:39:41 (GMT)
commite6b2fb8df994a4cb3de2f9896aea64858eb3d238 (patch)
tree3a97b87bf4fb2bf9df650187e2d5496d7dc0b3b7 /tools
parentf62f6effab8d1551d8e5e5843dc478addee96de1 (diff)
downloadQt-e6b2fb8df994a4cb3de2f9896aea64858eb3d238.zip
Qt-e6b2fb8df994a4cb3de2f9896aea64858eb3d238.tar.gz
Qt-e6b2fb8df994a4cb3de2f9896aea64858eb3d238.tar.bz2
Prevent a recursive debug output loop when writing to the logger widget.
(On Maemo5 the input method may generate a qWarning when someone clicks into the logger widget, which leads to an endless output recursion) Reviewed-by: Harald Fernengel
Diffstat (limited to 'tools')
-rw-r--r--tools/qml/main.cpp15
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);
}
}