[PATCH 1/7] windows.gaming.input: Make QueryInterface implementations consistent.

Rémi Bernon rbernon at codeweavers.com
Mon Mar 7 03:40:23 CST 2022


When COM aggregation is involved it is important to add a reference to
the returned iface and not to the inner object.

Signed-off-by: Rémi Bernon <rbernon at codeweavers.com>
---

The series also supsersedes 229017 in PATCH 5, with some fixups for the
missing attributes and incorrect method case.

 dlls/windows.gaming.input/controller.c | 6 ++----
 dlls/windows.gaming.input/gamepad.c    | 6 ++----
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/dlls/windows.gaming.input/controller.c b/dlls/windows.gaming.input/controller.c
index 654d0795eac..75ead342004 100644
--- a/dlls/windows.gaming.input/controller.c
+++ b/dlls/windows.gaming.input/controller.c
@@ -46,15 +46,13 @@ static HRESULT WINAPI factory_QueryInterface( IActivationFactory *iface, REFIID
         IsEqualGUID( iid, &IID_IAgileObject ) ||
         IsEqualGUID( iid, &IID_IActivationFactory ))
     {
-        IUnknown_AddRef( iface );
-        *out = iface;
+        IInspectable_AddRef( (*out = &impl->IActivationFactory_iface) );
         return S_OK;
     }
 
     if (IsEqualGUID( iid, &IID_IRawGameControllerStatics ))
     {
-        IUnknown_AddRef( iface );
-        *out = &impl->IRawGameControllerStatics_iface;
+        IInspectable_AddRef( (*out = &impl->IRawGameControllerStatics_iface) );
         return S_OK;
     }
 
diff --git a/dlls/windows.gaming.input/gamepad.c b/dlls/windows.gaming.input/gamepad.c
index 231e923b5e8..ab95b4c8d89 100644
--- a/dlls/windows.gaming.input/gamepad.c
+++ b/dlls/windows.gaming.input/gamepad.c
@@ -46,15 +46,13 @@ static HRESULT WINAPI factory_QueryInterface( IActivationFactory *iface, REFIID
         IsEqualGUID( iid, &IID_IAgileObject ) ||
         IsEqualGUID( iid, &IID_IActivationFactory ))
     {
-        IUnknown_AddRef( iface );
-        *out = iface;
+        IInspectable_AddRef( (*out = &impl->IActivationFactory_iface) );
         return S_OK;
     }
 
     if (IsEqualGUID( iid, &IID_IGamepadStatics ))
     {
-        IUnknown_AddRef( iface );
-        *out = &impl->IGamepadStatics_iface;
+        IInspectable_AddRef( (*out = &impl->IGamepadStatics_iface) );
         return S_OK;
     }
 
-- 
2.34.1




More information about the wine-devel mailing list