summaryrefslogtreecommitdiffstats
path: root/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@qt.io>2022-08-25 10:15:16 +0200
committerTor Arne Vestbø <tor.arne.vestbo@qt.io>2022-08-29 15:39:34 +0200
commit1bc7e9e77b2d6b03b995f376b622d4c8c97dd51c (patch)
tree23aabcab8feb2489a144d5229a6c8ee40b05bd56 /tests/auto/other/qaccessibility/tst_qaccessibility.cpp
parent49f9cadb52b5ef29e527b60c3881cb15a69c1625 (diff)
Add QComHelper class for dealing with COM on Windows
Unifies our approach to calling CoInitializeEx and CoUninitialize, removing a lot of boilerplate in the process, and also fixes a few bugs where we would incorrectly balance our calls to CoInitializeEx and CoUninitialize. The optimistic approach of qfilesystemengine_win.cpp of calling CoCreateInstance without initializing the COM library explicitly has been removed, as calling CoInitializeEx should be a noop in the situation where it's already been loaded. Change-Id: I9e2ec101678c2ebb9946504b5e8034e58f1bb56a Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Diffstat (limited to 'tests/auto/other/qaccessibility/tst_qaccessibility.cpp')
-rw-r--r--tests/auto/other/qaccessibility/tst_qaccessibility.cpp8
1 files changed, 4 insertions, 4 deletions
diff --git a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
index 90f1647567..97ca35453b 100644
--- a/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
+++ b/tests/auto/other/qaccessibility/tst_qaccessibility.cpp
@@ -18,6 +18,7 @@
#include <qpa/qplatformnativeinterface.h>
#include <qpa/qplatformintegration.h>
#include <qpa/qplatformaccessibility.h>
+#include <QtCore/private/qfunctions_win_p.h>
#include <QtGui/private/qguiapplication_p.h>
#include <QtGui/private/qhighdpiscaling_p.h>
@@ -3846,14 +3847,14 @@ void tst_QAccessibility::bridgeTest()
POINT pt{nativePos.x(), nativePos.y()};
// Initialize COM stuff.
- HRESULT hr = CoInitializeEx(nullptr, COINIT_APARTMENTTHREADED | COINIT_DISABLE_OLE1DDE);
- QVERIFY(SUCCEEDED(hr));
+ QComHelper comHelper;
+ QVERIFY(comHelper.isValid());
// Get UI Automation interface.
const GUID CLSID_CUIAutomation_test{0xff48dba4, 0x60ef, 0x4201,
{0xaa,0x87, 0x54,0x10,0x3e,0xef,0x59,0x4e}};
IUIAutomation *automation = nullptr;
- hr = CoCreateInstance(CLSID_CUIAutomation_test, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&automation));
+ HRESULT hr = CoCreateInstance(CLSID_CUIAutomation_test, nullptr, CLSCTX_INPROC_SERVER, IID_PPV_ARGS(&automation));
QVERIFY(SUCCEEDED(hr));
// Get button element from UI Automation using point.
@@ -3956,7 +3957,6 @@ void tst_QAccessibility::bridgeTest()
controlWalker->Release();
windowElement->Release();
automation->Release();
- CoUninitialize();
QTestAccessibility::clearEvents();
#endif