From 3477105a8c9cac503849479288408a4360a6959d Mon Sep 17 00:00:00 2001 From: Dmitry Kazakov Date: Thu, 13 Oct 2022 16:38:42 +0300 Subject: [PATCH] Add a workaround for the lager issue with lenses https://github.com/arximboldi/lager/issues/160 --- libs/global/KisZug.h | 4 ++-- plugins/paintops/libpaintop/KisCurveOptionModel.cpp | 4 ++-- plugins/paintops/libpaintop/KisMultiSensorsSelector2.cpp | 6 +++--- plugins/paintops/libpaintop/KisPredefinedBrushModel.cpp | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/libs/global/KisZug.h b/libs/global/KisZug.h index 3e648425fb7..2366c8497e6 100644 --- a/libs/global/KisZug.h +++ b/libs/global/KisZug.h @@ -122,7 +122,7 @@ template >> auto to_base2 = lager::lenses::getset( - [] (const Derived &value) { return static_cast(value); }, + [] (const Derived &value) -> Base { return static_cast(value); }, [] (Derived src, const Base &value) { static_cast(src) = value; return src; } ); @@ -136,7 +136,7 @@ auto to_base2 = lager::lenses::getset( */ template auto to_base = lager::lenses::getset( - [] (const auto &value) { return static_cast(value); }, + [] (const auto &value) -> Base { return static_cast(value); }, [] (auto src, const Base &value) { static_cast(src) = value; return src; } ); diff --git a/plugins/paintops/libpaintop/KisCurveOptionModel.cpp b/plugins/paintops/libpaintop/KisCurveOptionModel.cpp index 23c5e5d592c..887da0ec221 100644 --- a/plugins/paintops/libpaintop/KisCurveOptionModel.cpp +++ b/plugins/paintops/libpaintop/KisCurveOptionModel.cpp @@ -9,7 +9,7 @@ #include auto activeCurveLens = lager::lenses::getset( - [](std::tuple data) -> QString { + [](const std::tuple &data) -> QString { QString activeCurve; const bool useSameCurve = std::get<0>(data).useSameCurve; @@ -18,7 +18,7 @@ auto activeCurveLens = lager::lenses::getset( } else { const QString activeSensorId = std::get<1>(data); KIS_SAFE_ASSERT_RECOVER_RETURN_VALUE(!activeSensorId.isEmpty(), activeCurve); - std::vector srcSensors = std::get<0>(data).sensors(); + std::vector srcSensors = std::get<0>(data).sensors(); auto it = std::find_if(srcSensors.begin(), srcSensors.end(), [activeSensorId] (const KisSensorData *sensor) { diff --git a/plugins/paintops/libpaintop/KisMultiSensorsSelector2.cpp b/plugins/paintops/libpaintop/KisMultiSensorsSelector2.cpp index 5275a40a63e..34549238db4 100644 --- a/plugins/paintops/libpaintop/KisMultiSensorsSelector2.cpp +++ b/plugins/paintops/libpaintop/KisMultiSensorsSelector2.cpp @@ -21,13 +21,13 @@ struct KisMultiSensorsSelector2::Private { }; auto sensorsLens = lager::lenses::getset( - [](KisCurveOptionData data) -> KisMultiSensorsModel2::MultiSensorData { - std::vector srcSensors = data.sensors(); + [](const KisCurveOptionData &data) -> KisMultiSensorsModel2::MultiSensorData { + std::vector srcSensors = data.sensors(); KisMultiSensorsModel2::MultiSensorData sensors; sensors.reserve(srcSensors.size()); - Q_FOREACH(KisSensorData* srcSensor, srcSensors) { + Q_FOREACH(const KisSensorData* srcSensor, srcSensors) { sensors.emplace_back(srcSensor->id, srcSensor->isActive); } return sensors; diff --git a/plugins/paintops/libpaintop/KisPredefinedBrushModel.cpp b/plugins/paintops/libpaintop/KisPredefinedBrushModel.cpp index 7c7cce2c022..aca11d4e7fd 100644 --- a/plugins/paintops/libpaintop/KisPredefinedBrushModel.cpp +++ b/plugins/paintops/libpaintop/KisPredefinedBrushModel.cpp @@ -8,7 +8,7 @@ namespace { auto brushSizeLens = lager::lenses::getset( - [](std::tuple x) -> qreal { return std::get<0>(x).width() * std::get<1>(x); }, + [](const std::tuple &x) -> qreal { return std::get<0>(x).width() * std::get<1>(x); }, [](std::tuple x, qreal brushSize) -> std::tuple { return std::make_tuple(std::get<0>(x), brushSize / std::get<0>(x).width()); });