summaryrefslogtreecommitdiffhomepage
path: root/opentrack/win32-joystick.cpp
diff options
context:
space:
mode:
authorStanislaw Halik <sthalik@misaki.pl>2015-12-03 22:27:01 +0100
committerStanislaw Halik <sthalik@misaki.pl>2015-12-03 22:27:01 +0100
commitdd67c2971d4f41267d4d08ebd8c5aefdb675c6e5 (patch)
tree251b9f6938c59f144737146e2a05d025db4efe9f /opentrack/win32-joystick.cpp
parent3883936fb476ef6e13ee808374c64c226f4fdf8c (diff)
api/joy: fix race
erase from iterator referenced the wrong 'joys' variable
Diffstat (limited to 'opentrack/win32-joystick.cpp')
-rw-r--r--opentrack/win32-joystick.cpp8
1 files changed, 5 insertions, 3 deletions
diff --git a/opentrack/win32-joystick.cpp b/opentrack/win32-joystick.cpp
index 6e64355c..0f8a08f8 100644
--- a/opentrack/win32-joystick.cpp
+++ b/opentrack/win32-joystick.cpp
@@ -222,7 +222,7 @@ win32_joy_ctx::enum_state::enum_state(std::unordered_map<QString, std::shared_pt
QMutexLocker l(&mtx);
this->joys = joys;
}
-
+
if(FAILED(hr = di->EnumDevices(DI8DEVCLASS_GAMECTRL,
EnumJoysticksCallback,
this,
@@ -232,10 +232,12 @@ win32_joy_ctx::enum_state::enum_state(std::unordered_map<QString, std::shared_pt
return;
}
- for (auto it = this->joys.begin(); it != this->joys.end(); )
+ auto& js = this->joys;
+
+ for (auto it = js.begin(); it != js.end(); )
{
if (std::find_if(all.cbegin(), all.cend(), [&](const QString& guid2) -> bool { return it->second->guid == guid2; }) == all.cend())
- it = joys.erase(it);
+ it = js.erase(it);
else
it++;
}