From 94297b4ca50439d27dd5c3de6ff225185647cc46 Mon Sep 17 00:00:00 2001 From: Jan Arve Saether Date: Tue, 28 Oct 2014 09:59:23 +0100 Subject: Do not crash QML apps on startup This started crashing because of 8f6436f125faae91eb472ddddbbae06dba5da671 Task-number: QTBUG-42227 Change-Id: I9e4862f6008c6ad6ec54469f2b39dd6be583e422 Reviewed-by: Friedemann Kleint Reviewed-by: Frederik Gladhorn --- src/quick/items/qquickaccessibleattached.cpp | 17 ++++++++++++----- src/quick/items/qquickaccessibleattached_p.h | 8 ++++---- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/src/quick/items/qquickaccessibleattached.cpp b/src/quick/items/qquickaccessibleattached.cpp index 38b26a53d0..abb763c2eb 100644 --- a/src/quick/items/qquickaccessibleattached.cpp +++ b/src/quick/items/qquickaccessibleattached.cpp @@ -292,10 +292,10 @@ QT_BEGIN_NAMESPACE The corresponding handler is \c onDecreaseAction. */ -const QMetaMethod QQuickAccessibleAttached::sigPress = QMetaMethod::fromSignal(&QQuickAccessibleAttached::pressAction); -const QMetaMethod QQuickAccessibleAttached::sigToggle = QMetaMethod::fromSignal(&QQuickAccessibleAttached::toggleAction); -const QMetaMethod QQuickAccessibleAttached::sigIncrease = QMetaMethod::fromSignal(&QQuickAccessibleAttached::increaseAction); -const QMetaMethod QQuickAccessibleAttached::sigDecrease = QMetaMethod::fromSignal(&QQuickAccessibleAttached::decreaseAction); +QMetaMethod QQuickAccessibleAttached::sigPress; +QMetaMethod QQuickAccessibleAttached::sigToggle; +QMetaMethod QQuickAccessibleAttached::sigIncrease; +QMetaMethod QQuickAccessibleAttached::sigDecrease; QQuickAccessibleAttached::QQuickAccessibleAttached(QObject *parent) : QObject(parent), m_role(QAccessible::NoRole) @@ -317,6 +317,13 @@ QQuickAccessibleAttached::QQuickAccessibleAttached(QObject *parent) if (!parent->property("cursorPosition").isNull()) { connect(parent, SIGNAL(cursorPositionChanged()), this, SLOT(cursorPositionChanged())); } + + if (!sigPress.isValid()) { + sigPress = QMetaMethod::fromSignal(&QQuickAccessibleAttached::pressAction); + sigToggle = QMetaMethod::fromSignal(&QQuickAccessibleAttached::toggleAction); + sigIncrease = QMetaMethod::fromSignal(&QQuickAccessibleAttached::increaseAction); + sigDecrease = QMetaMethod::fromSignal(&QQuickAccessibleAttached::decreaseAction); + } } QQuickAccessibleAttached::~QQuickAccessibleAttached() @@ -343,7 +350,7 @@ void QQuickAccessibleAttached::setIgnored(bool ignored) bool QQuickAccessibleAttached::doAction(const QString &actionName) { - const QMetaMethod *sig = 0; + QMetaMethod *sig = 0; if (actionName == QAccessibleActionInterface::pressAction()) sig = &sigPress; else if (actionName == QAccessibleActionInterface::toggleAction()) diff --git a/src/quick/items/qquickaccessibleattached_p.h b/src/quick/items/qquickaccessibleattached_p.h index 53b1d2954d..ad6165f936 100644 --- a/src/quick/items/qquickaccessibleattached_p.h +++ b/src/quick/items/qquickaccessibleattached_p.h @@ -221,10 +221,10 @@ private: QString m_name; QString m_description; - static const QMetaMethod sigPress; - static const QMetaMethod sigToggle; - static const QMetaMethod sigIncrease; - static const QMetaMethod sigDecrease; + static QMetaMethod sigPress; + static QMetaMethod sigToggle; + static QMetaMethod sigIncrease; + static QMetaMethod sigDecrease; public: using QObject::property; -- cgit v1.2.3