From a92e3cf3010d2d72829ab4f8954951049fb66681 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B8ger=20Hanseg=C3=A5rd?= Date: Mon, 24 Jun 2024 17:48:09 +0200 Subject: [PATCH] Add missing release in QWindowsUiaMainProvider::QueryInterface If QWindowsUiaMainProvider::QueryInterface does not return an interface after successfully calling QComObject::QueryInterface, it must reduce the refcount because no client will do it on its behalf. This reduces slightly the leak rate of QWindowsUiaMainProvider instances when no Narrator application is running. The patch also fixes an issue where the returned pointer was still pointing to a valid object even if E_NOINTERFACE was returned. Task-number: QTBUG-126530 Change-Id: I96c4f6e8cfcee41e80e49f3fc874e2e0cdfa55c1 Reviewed-by: Oliver Wolff (cherry picked from commit a9561e15e86d65e732da7f07d712325c8f16d7c9) Reviewed-by: Qt Cherry-pick Bot --- .../platforms/windows/uiautomation/qwindowsuiamainprovider.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp index fd7af9ce83..bf44795fe7 100644 --- a/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp +++ b/src/plugins/platforms/windows/uiautomation/qwindowsuiamainprovider.cpp @@ -235,8 +235,9 @@ HRESULT STDMETHODCALLTYPE QWindowsUiaMainProvider::QueryInterface(REFIID iid, LP if (accessible && hwndForAccessible(accessible)) { result = S_OK; } else { + Release(); result = E_NOINTERFACE; - iface = nullptr; + *iface = nullptr; } }