[Mac] Fixed exception in HIDInput.Dispose()
HIDInput.Dispose() would remove elements from a DeviceCollection during iteration. This results in an exception. We are now using a plain for-loop instead.
This commit is contained in:
parent
747d86bafb
commit
383cea7e82
1 changed files with 15 additions and 6 deletions
|
@ -1704,19 +1704,28 @@ namespace OpenTK.Platform.MacOS
|
||||||
NativeMethods.IOHIDManagerUnscheduleFromRunLoop(
|
NativeMethods.IOHIDManagerUnscheduleFromRunLoop(
|
||||||
hidmanager, RunLoop, InputLoopMode);
|
hidmanager, RunLoop, InputLoopMode);
|
||||||
|
|
||||||
foreach (var device in MouseDevices)
|
for (int i = 0; i < Math.Max(MouseDevices.Count, 4); i++)
|
||||||
{
|
{
|
||||||
DeviceRemoved(IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, device.Id);
|
if (MouseDevices[i] != null)
|
||||||
|
{
|
||||||
|
DeviceRemoved(IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, MouseDevices[i].Id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var device in KeyboardDevices)
|
for (int i = 0; i < Math.Max(KeyboardDevices.Count, 4); i++)
|
||||||
{
|
{
|
||||||
DeviceRemoved(IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, device.Id);
|
if (KeyboardDevices[i] != null)
|
||||||
|
{
|
||||||
|
DeviceRemoved(IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, KeyboardDevices[i].Id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
foreach (var device in JoystickDevices)
|
for (int i = 0; i < Math.Max(JoystickDevices.Count, 4); i++)
|
||||||
{
|
{
|
||||||
DeviceRemoved(IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, device.Id);
|
if (JoystickDevices[i] != null)
|
||||||
|
{
|
||||||
|
DeviceRemoved(IntPtr.Zero, IntPtr.Zero, IntPtr.Zero, JoystickDevices[i].Id);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (hidmanager != IntPtr.Zero)
|
if (hidmanager != IntPtr.Zero)
|
||||||
|
|
Loading…
Reference in a new issue