QWinRTUiaValueProvider: optimize SetValue()
The code followed a pattern used elsewhere whereby a return value is transmitted out of a task executed on a separate thread by way of shared ownership of the value using QSharedPointer. In the present case, however, the pattern was applied to an argument of the task, not its return value, so remove all the sharing machinery and just copy the argument (a QString) into the task (a lambda). Change-Id: Ib997322ed70201781b6012c7e4f945b124b05868 Reviewed-by: Edward Welbourne <edward.welbourne@qt.io> Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
This commit is contained in:
parent
6eaa1d07e1
commit
29e40c1f6f
@ -96,24 +96,22 @@ HRESULT STDMETHODCALLTYPE QWinRTUiaValueProvider::SetValue(HSTRING value)
|
||||
qCDebug(lcQpaUiAutomation) << __FUNCTION__;
|
||||
|
||||
auto accid = id();
|
||||
auto tmpValue = QSharedPointer<QString>(new QString);
|
||||
auto ptrValue = new QSharedPointer<QString>(tmpValue);
|
||||
|
||||
*tmpValue = hStrToQStr(value);
|
||||
QString tmpValue = hStrToQStr(value);
|
||||
|
||||
QEventDispatcherWinRT::runOnMainThread([accid, ptrValue]() {
|
||||
QEventDispatcherWinRT::runOnMainThread([accid, tmpValue]() {
|
||||
|
||||
if (QAccessibleInterface *accessible = accessibleForId(accid)) {
|
||||
|
||||
// First sets the value as a text.
|
||||
accessible->setText(QAccessible::Value, **ptrValue);
|
||||
accessible->setText(QAccessible::Value, tmpValue);
|
||||
|
||||
// Then, if the control supports the value interface (range value)
|
||||
// and the supplied text can be converted to a number, and that number
|
||||
// lies within the min/max limits, sets it as the control's current (numeric) value.
|
||||
if (QAccessibleValueInterface *valueInterface = accessible->valueInterface()) {
|
||||
bool ok = false;
|
||||
double numval = (*ptrValue)->toDouble(&ok);
|
||||
double numval = tmpValue.toDouble(&ok);
|
||||
if (ok) {
|
||||
double minimum = valueInterface->minimumValue().toDouble();
|
||||
double maximum = valueInterface->maximumValue().toDouble();
|
||||
@ -124,7 +122,6 @@ HRESULT STDMETHODCALLTYPE QWinRTUiaValueProvider::SetValue(HSTRING value)
|
||||
}
|
||||
}
|
||||
QWinRTUiaMetadataCache::instance()->load(accid);
|
||||
delete ptrValue;
|
||||
return S_OK;
|
||||
}, 0);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user