On 07/12/2015 01:19 PM, Stefan Dösinger wrote:
Hi,
You aren't returning the version 1 interface from QueryInterface.
Am 2015-07-11 um 14:40 schrieb Aaryaman Vasishta:
if (IsEqualGUID(riid, &IID_IDirect3DRMDevice3)) *out = (IUnknown*)&object->IDirect3DRMDevice3_iface; - else + else if (IsEqualGUID(riid, &IID_IDirect3DRMDevice2)) *out = (IUnknown*)&object->IDirect3DRMDevice2_iface; + else + *out = (IUnknown*)&object->IDirect3DRMDevice_iface;
You can call QueryInterface instead of doing GUID checks like this. Just initialize ref = 0, then call QI and you'll return a ref = 1 device.
Actually ref should be initialized with 1. To not leak objects when requesting the wrong interface the pattern is like this:
ref = 1; ... hres = QueryInterface(main, riid, ppv); Release(main);
return hres;
Another option, if you like this better, is to always return e.g. a IDirect3DRMDevice3 from Direct3DRMDevice_create, remove the riid parameter and do the QueryInterface in the caller. In this case init the refcount to 1 and call device3_Release in the caller after calling QI to obtain the right interface.
The first 3 patches look good to me. I'll ack them tomorrow.
bye michael