diff options
author | Jan Arve Sæther <jan-arve.saether@qt.io> | 2021-01-13 14:33:55 +0100 |
---|---|---|
committer | Qt Cherry-pick Bot <cherrypick_bot@qt-project.org> | 2021-02-03 11:30:12 +0000 |
commit | b02de0d64e6784a9b0804e8672ab74a0c5b19102 (patch) | |
tree | 13b106e23f079fcf8565b6525b22b66ac3c57baa /src | |
parent | 0247193233710c32fddb9706112d15bb2cb3a457 (diff) |
a11y: Do not cache classes that don't have a factory plugin
For Qt Widgets we thought it was a good idea to also store in the cache
if a class didn't have a factory plugin. This worked fine there, since
the number of QWidget classnames is quite limited (so the factory plugin
cache will soon reach a limit)
In QML however, classes are often suffixed with e.g. Button_QMLTYPE_123,
Button_QMLTYPE_124 etc.
This number suffix is just increased continuously. This could lead to that
the factory plugin cache will grow ad infinitum, which will cause
"memory leaks" in addition to a performance penalty.
Fixes: QTBUG-75106
Change-Id: I9ba189f989f0b90ab62a2c54a2e9230236a998d8
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
(cherry picked from commit 583668005d4d6399fc16d165dcb6a5af2b94323d)
Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/accessible/qaccessible.cpp | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/src/gui/accessible/qaccessible.cpp b/src/gui/accessible/qaccessible.cpp index cd6a529a83..b2cc9d23f0 100644 --- a/src/gui/accessible/qaccessible.cpp +++ b/src/gui/accessible/qaccessible.cpp @@ -696,15 +696,14 @@ QAccessibleInterface *QAccessible::queryAccessibleInterface(QObject *object) // Find a QAccessiblePlugin (factory) for the class name. If there's // no entry in the cache try to create it using the plugin loader. if (!qAccessiblePlugins()->contains(cn)) { - QAccessiblePlugin *factory = nullptr; // 0 means "no plugin found". This is cached as well. const int index = loader()->indexOf(cn); - if (index != -1) - factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index)); - qAccessiblePlugins()->insert(cn, factory); + if (index != -1) { + QAccessiblePlugin *factory = qobject_cast<QAccessiblePlugin *>(loader()->instance(index)); + qAccessiblePlugins()->insert(cn, factory); + } } // At this point the cache should contain a valid factory pointer or 0: - Q_ASSERT(qAccessiblePlugins()->contains(cn)); QAccessiblePlugin *factory = qAccessiblePlugins()->value(cn); if (factory) { QAccessibleInterface *result = factory->create(cn, object); |