On 1 September 2015 at 00:27, Józef Kucia jkucia@codeweavers.com wrote:
- else if (IsEqualGUID(riid, &IID_ID3D10Texture3D)
|| IsEqualGUID(riid, &IID_ID3D10Resource)
|| IsEqualGUID(riid, &IID_ID3D10DeviceChild))
- {
IUnknown_AddRef(iface);
*object = &texture->ID3D10Texture3D_iface;
For what it's worth, this works here because the d3d10 and d3d11 interfaces share the reference count, but in general you should AddRef() the actual interface you're returning.
On Tue, Sep 1, 2015 at 3:53 PM, Henri Verbeet hverbeet@gmail.com wrote:
On 1 September 2015 at 00:27, Józef Kucia jkucia@codeweavers.com wrote:
- else if (IsEqualGUID(riid, &IID_ID3D10Texture3D)
|| IsEqualGUID(riid, &IID_ID3D10Resource)
|| IsEqualGUID(riid, &IID_ID3D10DeviceChild))
- {
IUnknown_AddRef(iface);
*object = &texture->ID3D10Texture3D_iface;
For what it's worth, this works here because the d3d10 and d3d11 interfaces share the reference count, but in general you should AddRef() the actual interface you're returning.
IMHO, this is somehow clearer than IUnknown_AddRef((IUnknown *)*object). On the other hand, it seems suspicious when AddRef() is called on other interface than the one returned.
On 1 September 2015 at 18:56, Józef Kucia joseph.kucia@gmail.com wrote:
IMHO, this is somehow clearer than IUnknown_AddRef((IUnknown *)*object). On the other hand, it seems suspicious when AddRef() is called on other interface than the one returned.
You're mixing styles a bit. One way is to first assign *out/*object and then have a common IUnknown_AddRef() at the end of QueryInterface(). The advantage is mostly that you're saving some code duplication for the AddRef() and return, although at the cost of introducing a cast. E.g. d3d10_device_inner_QueryInterface(). The other style is to AddRef() with the correct interface and return immediately, e.g. ddraw_surface7_QueryInterface(). I.e., in this case you'd use "ID3D10Texture3D_AddRef(&texture->ID3D10Texture3D_iface);". Note that the "else" is redundant if you return.