--- a/tools/qml/main.cpp Tue Jul 06 15:10:48 2010 +0300
+++ b/tools/qml/main.cpp Wed Aug 18 10:37:55 2010 +0300
@@ -49,12 +49,15 @@
#include <QTranslator>
#include <QDebug>
#include <QMessageBox>
+#include <QAtomicInt>
#include "qdeclarativetester.h"
QT_USE_NAMESPACE
QtMsgHandler systemMsgOutput = 0;
+
+
#if defined (Q_OS_SYMBIAN)
#include <unistd.h>
#include <sys/types.h>
@@ -89,19 +92,25 @@
}
}
+static QAtomicInt recursiveLock(0);
+
void myMessageOutput(QtMsgType type, const char *msg)
{
- if (!logger.isNull()) {
- QString strMsg = QString::fromAscii(msg);
- QMetaObject::invokeMethod(logger.data(), "append", Q_ARG(QString, strMsg));
+ QString strMsg = QString::fromLatin1(msg);
+
+ if (!logger.isNull() && !QCoreApplication::closingDown()) {
+ 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);
}
}
@@ -119,7 +128,7 @@
qWarning(" -fullscreen............................... run fullscreen");
qWarning(" -stayontop................................ keep viewer window on top");
qWarning(" -sizeviewtorootobject .................... the view resizes to the changes in the content");
- qWarning(" -sizerootobjecttoview .................... the content resizes to the changes in the view");
+ qWarning(" -sizerootobjecttoview .................... the content resizes to the changes in the view (default)");
qWarning(" -qmlbrowser .............................. use a QML-based file browser");
qWarning(" -warnings [show|hide]..................... show warnings in a separate log window");
qWarning(" -recordfile <output> ..................... set video recording file");
@@ -200,6 +209,8 @@
app.setOrganizationName("Nokia");
app.setOrganizationDomain("nokia.com");
+
+
QDeclarativeViewer::registerTypes();
QDeclarativeTester::registerTypes();
@@ -347,8 +358,9 @@
wflags |= Qt::WindowStaysOnTopHint;
QDeclarativeViewer *viewer = new QDeclarativeViewer(0, wflags);
+ viewer->setAttribute(Qt::WA_DeleteOnClose, true);
if (!scriptopts.isEmpty()) {
- QStringList options =
+ QStringList options =
scriptopts.split(QLatin1Char(','), QString::SkipEmptyParts);
QDeclarativeViewer::ScriptOptions scriptOptions = 0;
@@ -451,7 +463,5 @@
viewer->setUseGL(useGL);
viewer->raise();
- int rv = app.exec();
- delete viewer;
- exit(rv);
+ return app.exec();
}