mirror of
https://github.com/PixlOne/logiops.git
synced 2025-07-14 05:12:34 +08:00
Fix memory error with gesture configs
This commit is contained in:
parent
9efd121387
commit
6b2207d412
@ -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());
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user