From 00bea4d274b3249f053252e0f8da904407e44ddd Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Tue, 5 May 2015 11:05:28 -0700 Subject: [PATCH 1/3] fix crash for NULL deviceProxy --- interface/src/ui/UserInputMapper.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/interface/src/ui/UserInputMapper.cpp b/interface/src/ui/UserInputMapper.cpp index 892ab6a9b6..259d08b4b7 100755 --- a/interface/src/ui/UserInputMapper.cpp +++ b/interface/src/ui/UserInputMapper.cpp @@ -90,7 +90,7 @@ void UserInputMapper::update(float deltaTime) { bool isActiveModifier = false; for (auto& modifier : modifiersIt->second) { auto deviceProxy = getDeviceProxy(modifier); - if (deviceProxy->getButton(modifier, currentTimestamp)) { + if (deviceProxy && deviceProxy->getButton(modifier, currentTimestamp)) { validModifiers.push_back(modifier); isActiveModifier |= (modifier.getID() == inputMapping._modifier.getID()); } @@ -99,8 +99,8 @@ void UserInputMapper::update(float deltaTime) { } // if enabled: default input or all modifiers on - if (enabled) { - auto deviceProxy = getDeviceProxy(inputID); + auto deviceProxy = getDeviceProxy(inputID); + if (enabled && deviceProxy) { switch (inputMapping._input.getType()) { case ChannelType::BUTTON: { _actionStates[channelInput.first] += inputMapping._scale * float(deviceProxy->getButton(inputID, currentTimestamp));// * deltaTime; // weight the impulse by the deltaTime From 0d4d5d024e30ad5370a5660929b84705469225b9 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Tue, 5 May 2015 14:59:22 -0700 Subject: [PATCH 2/3] revert last change (fix for invalid DeviceProxy) --- interface/src/ui/UserInputMapper.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/interface/src/ui/UserInputMapper.cpp b/interface/src/ui/UserInputMapper.cpp index 259d08b4b7..892ab6a9b6 100755 --- a/interface/src/ui/UserInputMapper.cpp +++ b/interface/src/ui/UserInputMapper.cpp @@ -90,7 +90,7 @@ void UserInputMapper::update(float deltaTime) { bool isActiveModifier = false; for (auto& modifier : modifiersIt->second) { auto deviceProxy = getDeviceProxy(modifier); - if (deviceProxy && deviceProxy->getButton(modifier, currentTimestamp)) { + if (deviceProxy->getButton(modifier, currentTimestamp)) { validModifiers.push_back(modifier); isActiveModifier |= (modifier.getID() == inputMapping._modifier.getID()); } @@ -99,8 +99,8 @@ void UserInputMapper::update(float deltaTime) { } // if enabled: default input or all modifiers on - auto deviceProxy = getDeviceProxy(inputID); - if (enabled && deviceProxy) { + if (enabled) { + auto deviceProxy = getDeviceProxy(inputID); switch (inputMapping._input.getType()) { case ChannelType::BUTTON: { _actionStates[channelInput.first] += inputMapping._scale * float(deviceProxy->getButton(inputID, currentTimestamp));// * deltaTime; // weight the impulse by the deltaTime From 419cfee7758c3d1126eac3d96abfed169b6c2405 Mon Sep 17 00:00:00 2001 From: Andrew Meadows Date: Tue, 5 May 2015 15:06:51 -0700 Subject: [PATCH 3/3] more correct fix for invalid DeviceProxy crash bug --- interface/src/ui/UserInputMapper.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/interface/src/ui/UserInputMapper.h b/interface/src/ui/UserInputMapper.h index 32a1782419..ab63bdbef7 100755 --- a/interface/src/ui/UserInputMapper.h +++ b/interface/src/ui/UserInputMapper.h @@ -57,7 +57,9 @@ public: bool isAxis() const { return getType() == ChannelType::AXIS; } bool isJoint() const { return getType() == ChannelType::JOINT; } - explicit Input() {} + // WORKAROUND: the explicit initializer here avoids a bug in GCC-4.8.2 (but not found in 4.9.2) + // where the default initializer (a C++-11ism) for the union data above is not applied. + explicit Input() : _id(0) {} explicit Input(uint32 id) : _id(id) {} explicit Input(uint16 device, uint16 channel, ChannelType type) : _device(device), _channel(channel), _type(uint16(type)) {} Input(const Input& src) : _id(src._id) {}