Fix memory error with gesture configs

This commit is contained in:
pixl 2023-04-27 18:39:34 -04:00
parent 9efd121387
commit 6b2207d412
No known key found for this signature in database
GPG Key ID: 1866C148CD593B6E
3 changed files with 10 additions and 14 deletions

View File

@ -77,8 +77,7 @@ GestureAction::GestureAction(Device* dev, config::GestureAction& config,
Action(dev, interface_name,
{
{
{"SetGesture", {this, &GestureAction::setGesture,
{"direction", "type"}}}
{"SetGesture", {this, &GestureAction::setGesture, {"direction", "type"}}}
},
{},
{}
@ -86,14 +85,13 @@ GestureAction::GestureAction(Device* dev, config::GestureAction& config,
_node(parent->make_child("gestures")), _config(config) {
if (_config.gestures.has_value()) {
auto& gestures = _config.gestures.value();
for (auto& x: gestures) {
for (auto&& x: gestures) {
try {
auto direction = toDirection(x.first);
_gestures.emplace(direction,
Gesture::makeGesture(
dev, x.second,
_node->make_child(
fromDirection(direction))));
_gestures.emplace(
direction,Gesture::makeGesture(
dev, x.second,
_node->make_child(fromDirection(direction))));
} catch (std::invalid_argument& e) {
logPrintf(WARN, "%s is not a direction", x.first.c_str());
}

View File

@ -50,10 +50,10 @@ namespace {
template<typename T>
std::shared_ptr<Gesture> _makeGesture(
Device* device, T gesture,
Device* device, T& gesture,
const std::shared_ptr<ipcgull::node>& parent) {
return parent->make_interface<typename gesture_type<T>::type>(
device, gesture, parent);
device, std::forward<T&>(gesture), parent);
}
}

View File

@ -112,11 +112,9 @@ void HiresScroll::_makeAction(std::shared_ptr<actions::Gesture>& gesture,
gesture = actions::Gesture::makeGesture(_device, config.value(),
_node->make_child(direction));
try {
auto axis = std::dynamic_pointer_cast<actions::AxisGesture>(
gesture);
auto axis = std::dynamic_pointer_cast<actions::AxisGesture>(gesture);
if (axis)
axis->setHiresMultiplier(
_hires_scroll->getCapabilities().multiplier);
axis->setHiresMultiplier(_hires_scroll->getCapabilities().multiplier);
} catch (std::bad_cast& e) {}
if (gesture)
gesture->press(true);