From bbb4c20c8aed7ba6e151cbb76e01476551d2fba0 Mon Sep 17 00:00:00 2001 From: Aleix Pol Date: Tue, 26 Jul 2022 18:46:05 +0200 Subject: [PATCH] libinput: Make sure config values get deleted Switches to a shared pointer rather than a raw one. It would leak, which in general is not a big problem but it would flood the output when running tests with ASAN. Also it's the right thing to do. --- src/backends/libinput/device.cpp | 40 ++++++++++++++++---------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/backends/libinput/device.cpp b/src/backends/libinput/device.cpp index c2bb38b601..e503091825 100644 --- a/src/backends/libinput/device.cpp +++ b/src/backends/libinput/device.cpp @@ -184,26 +184,26 @@ struct ConfigData : public ConfigDataBase } }; -static const QMap s_configData{ - {ConfigKey::Enabled, new ConfigData(QByteArrayLiteral("Enabled"), &Device::setEnabled, &Device::isEnabledByDefault)}, - {ConfigKey::LeftHanded, new ConfigData(QByteArrayLiteral("LeftHanded"), &Device::setLeftHanded, &Device::leftHandedEnabledByDefault)}, - {ConfigKey::DisableWhileTyping, new ConfigData(QByteArrayLiteral("DisableWhileTyping"), &Device::setDisableWhileTyping, &Device::disableWhileTypingEnabledByDefault)}, - {ConfigKey::PointerAcceleration, new ConfigData(QByteArrayLiteral("PointerAcceleration"), &Device::setPointerAccelerationFromString, &Device::defaultPointerAccelerationToString)}, - {ConfigKey::PointerAccelerationProfile, new ConfigData(QByteArrayLiteral("PointerAccelerationProfile"), &Device::setPointerAccelerationProfileFromInt, &Device::defaultPointerAccelerationProfileToInt)}, - {ConfigKey::TapToClick, new ConfigData(QByteArrayLiteral("TapToClick"), &Device::setTapToClick, &Device::tapToClickEnabledByDefault)}, - {ConfigKey::TapAndDrag, new ConfigData(QByteArrayLiteral("TapAndDrag"), &Device::setTapAndDrag, &Device::tapAndDragEnabledByDefault)}, - {ConfigKey::TapDragLock, new ConfigData(QByteArrayLiteral("TapDragLock"), &Device::setTapDragLock, &Device::tapDragLockEnabledByDefault)}, - {ConfigKey::MiddleButtonEmulation, new ConfigData(QByteArrayLiteral("MiddleButtonEmulation"), &Device::setMiddleEmulation, &Device::middleEmulationEnabledByDefault)}, - {ConfigKey::LmrTapButtonMap, new ConfigData(QByteArrayLiteral("LmrTapButtonMap"), &Device::setLmrTapButtonMap, &Device::lmrTapButtonMapEnabledByDefault)}, - {ConfigKey::NaturalScroll, new ConfigData(QByteArrayLiteral("NaturalScroll"), &Device::setNaturalScroll, &Device::naturalScrollEnabledByDefault)}, - {ConfigKey::ScrollMethod, new ConfigData(QByteArrayLiteral("ScrollMethod"), &Device::activateScrollMethodFromInt, &Device::defaultScrollMethodToInt)}, - {ConfigKey::ScrollButton, new ConfigData(QByteArrayLiteral("ScrollButton"), &Device::setScrollButton, &Device::defaultScrollButton)}, - {ConfigKey::ClickMethod, new ConfigData(QByteArrayLiteral("ClickMethod"), &Device::setClickMethodFromInt, &Device::defaultClickMethodToInt)}, - {ConfigKey::ScrollFactor, new ConfigData(QByteArrayLiteral("ScrollFactor"), &Device::setScrollFactor, &Device::scrollFactorDefault)}, - {ConfigKey::Orientation, new ConfigData{}}, - {ConfigKey::Calibration, new ConfigData{}}, - {ConfigKey::OutputName, new ConfigData(QByteArrayLiteral("OutputName"), &Device::setOutputName, &Device::defaultOutputName)}, - {ConfigKey::OutputArea, new ConfigData(QByteArrayLiteral("OutputArea"), &Device::setOutputArea, &Device::defaultOutputArea)}, +static const QMap> s_configData{ + {ConfigKey::Enabled, std::make_shared>(QByteArrayLiteral("Enabled"), &Device::setEnabled, &Device::isEnabledByDefault)}, + {ConfigKey::LeftHanded, std::make_shared>(QByteArrayLiteral("LeftHanded"), &Device::setLeftHanded, &Device::leftHandedEnabledByDefault)}, + {ConfigKey::DisableWhileTyping, std::make_shared>(QByteArrayLiteral("DisableWhileTyping"), &Device::setDisableWhileTyping, &Device::disableWhileTypingEnabledByDefault)}, + {ConfigKey::PointerAcceleration, std::make_shared>(QByteArrayLiteral("PointerAcceleration"), &Device::setPointerAccelerationFromString, &Device::defaultPointerAccelerationToString)}, + {ConfigKey::PointerAccelerationProfile, std::make_shared>(QByteArrayLiteral("PointerAccelerationProfile"), &Device::setPointerAccelerationProfileFromInt, &Device::defaultPointerAccelerationProfileToInt)}, + {ConfigKey::TapToClick, std::make_shared>(QByteArrayLiteral("TapToClick"), &Device::setTapToClick, &Device::tapToClickEnabledByDefault)}, + {ConfigKey::TapAndDrag, std::make_shared>(QByteArrayLiteral("TapAndDrag"), &Device::setTapAndDrag, &Device::tapAndDragEnabledByDefault)}, + {ConfigKey::TapDragLock, std::make_shared>(QByteArrayLiteral("TapDragLock"), &Device::setTapDragLock, &Device::tapDragLockEnabledByDefault)}, + {ConfigKey::MiddleButtonEmulation, std::make_shared>(QByteArrayLiteral("MiddleButtonEmulation"), &Device::setMiddleEmulation, &Device::middleEmulationEnabledByDefault)}, + {ConfigKey::LmrTapButtonMap, std::make_shared>(QByteArrayLiteral("LmrTapButtonMap"), &Device::setLmrTapButtonMap, &Device::lmrTapButtonMapEnabledByDefault)}, + {ConfigKey::NaturalScroll, std::make_shared>(QByteArrayLiteral("NaturalScroll"), &Device::setNaturalScroll, &Device::naturalScrollEnabledByDefault)}, + {ConfigKey::ScrollMethod, std::make_shared>(QByteArrayLiteral("ScrollMethod"), &Device::activateScrollMethodFromInt, &Device::defaultScrollMethodToInt)}, + {ConfigKey::ScrollButton, std::make_shared>(QByteArrayLiteral("ScrollButton"), &Device::setScrollButton, &Device::defaultScrollButton)}, + {ConfigKey::ClickMethod, std::make_shared>(QByteArrayLiteral("ClickMethod"), &Device::setClickMethodFromInt, &Device::defaultClickMethodToInt)}, + {ConfigKey::ScrollFactor, std::make_shared>(QByteArrayLiteral("ScrollFactor"), &Device::setScrollFactor, &Device::scrollFactorDefault)}, + {ConfigKey::Orientation, std::make_shared>()}, + {ConfigKey::Calibration, std::make_shared>()}, + {ConfigKey::OutputName, std::make_shared>(QByteArrayLiteral("OutputName"), &Device::setOutputName, &Device::defaultOutputName)}, + {ConfigKey::OutputArea, std::make_shared>(QByteArrayLiteral("OutputArea"), &Device::setOutputArea, &Device::defaultOutputArea)}, }; namespace