Skip to content

Commit

Permalink
Add a workaround for the lager issue with lenses
Browse files Browse the repository at this point in the history
  • Loading branch information
dimula73 committed Nov 22, 2022
1 parent 3c5cee1 commit 3477105
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 8 deletions.
4 changes: 2 additions & 2 deletions libs/global/KisZug.h
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ template <typename Derived, typename Base,
typename = std::enable_if_t<
std::is_base_of_v<Base, Derived>>>
auto to_base2 = lager::lenses::getset(
[] (const Derived &value) { return static_cast<Base>(value); },
[] (const Derived &value) -> Base { return static_cast<const Base&>(value); },
[] (Derived src, const Base &value) { static_cast<Base&>(src) = value; return src; }
);

Expand All @@ -136,7 +136,7 @@ auto to_base2 = lager::lenses::getset(
*/
template <typename Base>
auto to_base = lager::lenses::getset(
[] (const auto &value) { return static_cast<Base>(value); },
[] (const auto &value) -> Base { return static_cast<const Base&>(value); },
[] (auto src, const Base &value) { static_cast<Base&>(src) = value; return src; }
);

Expand Down
4 changes: 2 additions & 2 deletions plugins/paintops/libpaintop/KisCurveOptionModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
#include <KisZug.h>

auto activeCurveLens = lager::lenses::getset(
[](std::tuple<KisCurveOptionData, QString> data) -> QString {
[](const std::tuple<KisCurveOptionData, QString> &data) -> QString {
QString activeCurve;
const bool useSameCurve = std::get<0>(data).useSameCurve;

Expand All @@ -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<KisSensorData*> srcSensors = std::get<0>(data).sensors();
std::vector<const KisSensorData*> srcSensors = std::get<0>(data).sensors();
auto it =
std::find_if(srcSensors.begin(), srcSensors.end(),
[activeSensorId] (const KisSensorData *sensor) {
Expand Down
6 changes: 3 additions & 3 deletions plugins/paintops/libpaintop/KisMultiSensorsSelector2.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,13 @@ struct KisMultiSensorsSelector2::Private {
};

auto sensorsLens = lager::lenses::getset(
[](KisCurveOptionData data) -> KisMultiSensorsModel2::MultiSensorData {
std::vector<KisSensorData*> srcSensors = data.sensors();
[](const KisCurveOptionData &data) -> KisMultiSensorsModel2::MultiSensorData {
std::vector<const KisSensorData*> 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;
Expand Down
2 changes: 1 addition & 1 deletion plugins/paintops/libpaintop/KisPredefinedBrushModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
namespace {

auto brushSizeLens = lager::lenses::getset(
[](std::tuple<QSize, qreal> x) -> qreal { return std::get<0>(x).width() * std::get<1>(x); },
[](const std::tuple<QSize, qreal> &x) -> qreal { return std::get<0>(x).width() * std::get<1>(x); },
[](std::tuple<QSize, qreal> x, qreal brushSize) -> std::tuple<QSize, qreal> {
return std::make_tuple(std::get<0>(x), brushSize / std::get<0>(x).width());
});
Expand Down

0 comments on commit 3477105

Please sign in to comment.