Hello Alistair,
I don't know for sure why creating the effect failed (and I can't check either, because the issues are seemingly gone after a reboot), but I can only assume that it is/was something in SetParameters, since the only occasion where something can fail without printing a log message is there.
Tim
On 19.05.19 13:21, Alistair Leslie-Hughes wrote:
Hi Tim,
Thanks. After looking at it again, your solution is OK.
Do you know why an effect is failing to create?
Regards
Alistair.
On 19/5/19 8:55 pm, Tim Schumacher wrote:
Hello Alistair,
I thought about fixing the problem that way (since it would be the cleaner solution), but the length of the effects array is determined by the num_effects value (which the destroy loop depends on as well), and that value isn't affected by effects failing to be created.
Therefore, we are going to end up with some empty fields, no matter what we do, so I thought this would be the best solution (unless decrementing num_effects when a failure occurs and moving the null fields to the end of the array (hoping that nothing ever accesses them) is an acceptable solution).
Tim
On 19.05.19 10:49, Alistair Leslie-Hughes wrote:
Hi Tim,
It would be better to stop the adding of NULL effects.
function ff_effects_callback
hr = IDirectInputDevice2_CreateEffect( joystick->device, &pdei->guid, &dieffect, &joystick->effects[joystick->cur_effect].effect, NULL);
/* hr is assigned but never checked. */
Best Regards
Alistair.
On 19/5/19 5:02 am, Tim Schumacher wrote:
Since IDirectInputEffect_Release(obj) is just a macro for (obj)->Release(), the program crashes if the effect we are trying to release is null. This mostly happens when the effect failed to allocate in the first place.
Signed-off-by: Tim Schumacher timschumi@gmx.de
dlls/joy.cpl/main.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/dlls/joy.cpl/main.c b/dlls/joy.cpl/main.c index 9768917641..06084f3166 100644 --- a/dlls/joy.cpl/main.c +++ b/dlls/joy.cpl/main.c @@ -137,7 +137,8 @@ static void destroy_joysticks(struct JoystickData *data) if (data->joysticks[i].forcefeedback && data->joysticks[i].num_effects > 0) { for (j = 0; j < data->joysticks[i].num_effects; j++)
IDirectInputEffect_Release(data->joysticks[i].effects[j].effect);
if (data->joysticks[i].effects[j].effect)
IDirectInputEffect_Release(data->joysticks[i].effects[j].effect); HeapFree(GetProcessHeap(), 0, data->joysticks[i].effects); }
-- 2.21.0