aboutsummaryrefslogtreecommitdiffstats
path: root/src/quicktemplates2/qquickcontrol.cpp
diff options
context:
space:
mode:
authorJ-P Nurmi <jpnurmi@qt.io>2017-08-30 15:58:42 +0200
committerJ-P Nurmi <jpnurmi@qt.io>2017-08-31 13:20:51 +0000
commitf40583bb6400d4ed67f83bc6e22e88049a314e06 (patch)
tree78257dcf0854ef4c0b2edc11805afea5fe63221d /src/quicktemplates2/qquickcontrol.cpp
parentf0697c622ab087faa19679725250c0ac7f79372d (diff)
Fix accessibility-related performance regressions
Before 089dd16f, we had a QQuickControlPrivate::accessibleAttached member that indicated whether accessibility was active. Since 4be38ab in qtdeclarative, it was possible to access QQuickAccessibleAttached:: attachedProperties() directly, but we ended up accidentally accessing it even when accessibility was not active, which added noticeable overhead. This improves those qmlbench test cases that call accessibility-aware setters such as QQuickAbstractButton::setChecked() a lot. For example, the test cases for CheckBox and RadioButton create large amounts of controls with a "checked: index % 2" binding. - CheckBox: 84 => 93 frames - RadioButton: 98 => 113 frames QAccessible::setActive(true) only notifies the observers, but does not really make accessibility active in the sense that the consequent calls to QAccessible::isActive() still return false. tst_accessible had to be changed to use QPlatformAccessible::setActive() instead. Change-Id: I8fd0fe2dddfd5633ce22a080bcda459f2d6e443e Reviewed-by: Liang Qi <liang.qi@qt.io>
Diffstat (limited to 'src/quicktemplates2/qquickcontrol.cpp')
-rw-r--r--src/quicktemplates2/qquickcontrol.cpp17
1 files changed, 13 insertions, 4 deletions
diff --git a/src/quicktemplates2/qquickcontrol.cpp b/src/quicktemplates2/qquickcontrol.cpp
index 4b85e444..646ba7ea 100644
--- a/src/quicktemplates2/qquickcontrol.cpp
+++ b/src/quicktemplates2/qquickcontrol.cpp
@@ -315,6 +315,13 @@ QAccessible::Role QQuickControlPrivate::accessibleRole() const
Q_Q(const QQuickControl);
return q->accessibleRole();
}
+
+QQuickAccessibleAttached *QQuickControlPrivate::accessibleAttached(const QObject *object)
+{
+ if (!QAccessible::isActive())
+ return nullptr;
+ return QQuickAccessibleAttached::attachedProperties(object);
+}
#endif
/*!
@@ -1613,7 +1620,7 @@ void QQuickControl::accessibilityActiveChanged(bool active)
QString QQuickControl::accessibleName() const
{
#if QT_CONFIG(accessibility)
- if (QQuickAccessibleAttached *accessibleAttached = QQuickAccessibleAttached::attachedProperties(this))
+ if (QQuickAccessibleAttached *accessibleAttached = QQuickControlPrivate::accessibleAttached(this))
return accessibleAttached->name();
#endif
return QString();
@@ -1622,7 +1629,7 @@ QString QQuickControl::accessibleName() const
void QQuickControl::setAccessibleName(const QString &name)
{
#if QT_CONFIG(accessibility)
- if (QQuickAccessibleAttached *accessibleAttached = QQuickAccessibleAttached::attachedProperties(this))
+ if (QQuickAccessibleAttached *accessibleAttached = QQuickControlPrivate::accessibleAttached(this))
accessibleAttached->setName(name);
#else
Q_UNUSED(name)
@@ -1632,7 +1639,8 @@ void QQuickControl::setAccessibleName(const QString &name)
QVariant QQuickControl::accessibleProperty(const char *propertyName)
{
#if QT_CONFIG(accessibility)
- return QQuickAccessibleAttached::property(this, propertyName);
+ if (QAccessible::isActive())
+ return QQuickAccessibleAttached::property(this, propertyName);
#endif
Q_UNUSED(propertyName)
return QVariant();
@@ -1641,7 +1649,8 @@ QVariant QQuickControl::accessibleProperty(const char *propertyName)
bool QQuickControl::setAccessibleProperty(const char *propertyName, const QVariant &value)
{
#if QT_CONFIG(accessibility)
- return QQuickAccessibleAttached::setProperty(this, propertyName, value);
+ if (QAccessible::isActive())
+ return QQuickAccessibleAttached::setProperty(this, propertyName, value);
#endif
Q_UNUSED(propertyName)
Q_UNUSED(value)