Commit 63637f24 authored by Rémi Bernon's avatar Rémi Bernon Committed by Alexandre Julliard

dinput: Return error from SetActionMap if SetDataFormat fails.

parent c6a922c1
......@@ -2013,14 +2013,13 @@ static HRESULT WINAPI dinput_device_SetActionMap( IDirectInputDevice8W *iface, D
int i, index, action = 0, num_actions = 0;
unsigned int offset = 0;
ActionMap *action_map;
HRESULT hr;
FIXME( "iface %p, format %p, username %s, flags %#lx stub!\n", iface, format,
debugstr_w(username), flags );
if (!format) return DIERR_INVALIDPARAM;
if (impl->status == STATUS_ACQUIRED) return DIERR_ACQUIRED;
/* Count the actions */
for (i = 0; i < format->dwNumActions; i++)
if (IsEqualGUID( &impl->guid, &format->rgoAction[i].guidInstance ))
......@@ -2046,13 +2045,15 @@ static HRESULT WINAPI dinput_device_SetActionMap( IDirectInputDevice8W *iface, D
data_format.dwNumObjs++;
}
IDirectInputDevice8_SetDataFormat( iface, &data_format );
EnterCriticalSection( &impl->crit );
if (FAILED(hr = IDirectInputDevice8_SetDataFormat( iface, &data_format )))
WARN( "Failed to set data format from action map, hr %#lx\n", hr );
else
{
impl->action_map = action_map;
impl->num_actions = num_actions;
free( data_format.rgodf );
if (format->lAxisMin != format->lAxisMax)
{
prop_range.lMin = format->lAxisMin;
......@@ -2071,8 +2072,13 @@ static HRESULT WINAPI dinput_device_SetActionMap( IDirectInputDevice8W *iface, D
dinput_device_set_username( impl, &prop_username );
save_mapping_settings( iface, format, username_buf );
}
return DI_OK;
LeaveCriticalSection( &impl->crit );
if (FAILED(hr)) free( action_map );
free( data_format.rgodf );
return hr;
}
static HRESULT WINAPI dinput_device_GetImageInfo( IDirectInputDevice8W *iface, DIDEVICEIMAGEINFOHEADERW *header )
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment