summaryrefslogtreecommitdiffstats
path: root/src/plugins/platforms/winrt/uiautomation/qwinrtuiamainprovider.h
diff options
context:
space:
mode:
authorMarc Mutz <marc.mutz@kdab.com>2019-09-04 23:44:16 +0200
committerMarc Mutz <marc.mutz@kdab.com>2019-09-10 12:51:51 +0200
commitb1698e9bc2ca0668f5b5f0e7af2274eb2a0cb7e0 (patch)
tree461d51568b599e46b2dcd9f6b5678ac08599281d /src/plugins/platforms/winrt/uiautomation/qwinrtuiamainprovider.h
parentc0b3c06a7d4f6a2f90742e8dc81c898082a70416 (diff)
QWinRTUia*: remove anti-pattern passing new'ed QSharedPointer into lambdas
QSharedPointer is made for passing around by value. It is unclear why in so many repeated cases a QSharedPointer is created on the stack, then a copy of it is new'ed up, passed into a lambda to be deleted inside it. First, it requires an additional heap allocation. Because it's passed as a raw pointer to QSharedPointer, however, there's also always the danger that it's leaked by seemingly-innocuous changes such as adding an early return from the lambda (and some of them could really use one, with the ifs nesting several levels deep). All this is not needed, though. It's perfectly ok to store a copy of a QSharedPointer, by value, in a lambda, and keep one copy outside it. Poor man's std::future, if you will. So, do away with all that, just pass the shared pointer by value into the lambda, and, as a drive-by, replace some ephemeral QLists with QVLAs. In one case, replace a QPair<int, int> with a struct to make the code using that type more accessible ('first' and 'second' are really, really bad variable names if they, in fact, represent 'startOffset' and 'endOffset'). Also port directly to shared_ptr / make_shared. Saves one memory allocation each, due to the co-allocation of payload and control block, and even though there's QSharedPointer::create, which does this, too, std::shared_ptr is simply much lighter on the use of atomics (copying a QSP ups two ref counts, copying a std::shared_ptr just one). Since these variables live behind the API boundary, there's no reason not to prefer the more efficient alternative. Change-Id: I4b9fe30e56df5106fc2ab7a0b55b2b8316cca5fe Reviewed-by: Oliver Wolff <oliver.wolff@qt.io> Reviewed-by: MÃ¥rten Nordheim <marten.nordheim@qt.io>
Diffstat (limited to 'src/plugins/platforms/winrt/uiautomation/qwinrtuiamainprovider.h')
-rw-r--r--src/plugins/platforms/winrt/uiautomation/qwinrtuiamainprovider.h2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/plugins/platforms/winrt/uiautomation/qwinrtuiamainprovider.h b/src/plugins/platforms/winrt/uiautomation/qwinrtuiamainprovider.h
index 384a166cf7..23a6e56ae7 100644
--- a/src/plugins/platforms/winrt/uiautomation/qwinrtuiamainprovider.h
+++ b/src/plugins/platforms/winrt/uiautomation/qwinrtuiamainprovider.h
@@ -69,7 +69,7 @@ public:
virtual ~QWinRTUiaMainProvider();
static QWinRTUiaMainProvider *providerForAccessibleId(QAccessible::Id id);
static HRESULT rawProviderForAccessibleId(QAccessible::Id elementId, ABI::Windows::UI::Xaml::Automation::Provider::IIRawElementProviderSimple **returnValue);
- static HRESULT rawProviderArrayForAccessibleIdList(const QList<QAccessible::Id> &elementIds, UINT32 *returnValueSize, ABI::Windows::UI::Xaml::Automation::Provider::IIRawElementProviderSimple ***returnValue);
+ static HRESULT rawProviderArrayForAccessibleIdList(const QVarLengthArray<QAccessible::Id> &elementIds, UINT32 *returnValueSize, ABI::Windows::UI::Xaml::Automation::Provider::IIRawElementProviderSimple ***returnValue);
static void notifyFocusChange(QAccessibleEvent *event);
static void notifyVisibilityChange(QAccessibleEvent *event);
static void notifyStateChange(QAccessibleStateChangeEvent *event);