summaryrefslogtreecommitdiff
path: root/share/qtcreator/qml/qmldump
diff options
context:
space:
mode:
authorChristian Kamm <christian.d.kamm@nokia.com>2011-01-12 13:15:09 +0100
committerChristian Kamm <christian.d.kamm@nokia.com>2011-01-12 13:16:07 +0100
commit18f9031ba61f20ae24302fb1ebcdbe5bfa7c6c2e (patch)
tree2800589572490c08d27c377e7e27c320d3aaaa25 /share/qtcreator/qml/qmldump
parent6dd55aa471ceab549eb83ebe2c82b0972fd7ef9e (diff)
downloadqt-creator-18f9031ba61f20ae24302fb1ebcdbe5bfa7c6c2e.tar.gz
qmldump: Add signal handler to catch segvs.
Reviewed-by: aep
Diffstat (limited to 'share/qtcreator/qml/qmldump')
-rw-r--r--share/qtcreator/qml/qmldump/main.cpp27
1 files changed, 27 insertions, 0 deletions
diff --git a/share/qtcreator/qml/qmldump/main.cpp b/share/qtcreator/qml/qmldump/main.cpp
index 7f78567ef7..019c07859d 100644
--- a/share/qtcreator/qml/qmldump/main.cpp
+++ b/share/qtcreator/qml/qmldump/main.cpp
@@ -17,9 +17,13 @@
#ifdef QT_SIMULATOR
#include <QtGui/private/qsimulatorconnection_p.h>
#endif
+#ifdef Q_OS_UNIX
+#include <signal.h>
+#endif
static QHash<QByteArray, QList<const QDeclarativeType *> > qmlTypesByCppName;
static QHash<QByteArray, QByteArray> cppToId;
+QString currentProperty;
QByteArray convertToId(const QByteArray &cppName)
{
@@ -73,9 +77,11 @@ void processObject(QObject *object, QSet<const QMetaObject *> *metas)
QMetaProperty prop = meta->property(index);
if (QDeclarativeMetaType::isQObject(prop.userType())) {
qDebug() << " Processing property" << prop.name();
+ currentProperty = QString("%1::%2").arg(meta->className(), prop.name());
QObject *oo = QDeclarativeMetaType::toQObject(prop.read(object));
if (oo && !metas->contains(oo->metaObject()))
processObject(oo, metas);
+ currentProperty.clear();
}
}
}
@@ -259,8 +265,29 @@ void writeEasingCurve(QXmlStreamWriter *xml)
xml->writeEndElement();
}
+#ifdef Q_OS_UNIX
+void sigSegvHandler(int) {
+ fprintf(stderr, "Error: qmldump SEGV\n");
+ if (!currentProperty.isEmpty())
+ fprintf(stderr, "While processing the property '%s', which probably has uninitialized data.\n", currentProperty.toLatin1().constData());
+ exit(EXIT_FAILURE);
+}
+#endif
+
int main(int argc, char *argv[])
{
+#ifdef Q_OS_UNIX
+ // qmldump may crash, but we don't want any crash handlers to pop up
+ // therefore we intercept the segfault and just exit() ourselves
+ struct sigaction action;
+
+ sigemptyset(&action.sa_mask);
+ action.sa_handler = &sigSegvHandler;
+ action.sa_flags = 0;
+
+ sigaction(SIGSEGV, &action, 0);
+#endif
+
#ifdef QT_SIMULATOR
QtSimulatorPrivate::SimulatorConnection::createStubInstance();
#endif