diff --git a/src/app/puzzle/layout/vppiece.cpp b/src/app/puzzle/layout/vppiece.cpp index c1549b87e..11c5b8af1 100644 --- a/src/app/puzzle/layout/vppiece.cpp +++ b/src/app/puzzle/layout/vppiece.cpp @@ -27,8 +27,6 @@ *************************************************************************/ #include "vppiece.h" -#include - #include "../vgeometry/vlayoutplacelabel.h" #include "../vlayout/vlayoutpiecepath.h" #include "../vlayout/vtextmanager.h" @@ -42,6 +40,9 @@ #include #include #include +#include +#include +#include #if QT_VERSION < QT_VERSION_CHECK(6, 4, 0) #include "../vmisc/compatibility.h" @@ -439,35 +440,36 @@ auto VPPiece::PrepareStickyPath(const QVector &path) -> QVector &path1, const QVector &path2) -> QLineF { - return QtConcurrent::blockingMappedReduced( - path1, - [path2](const QPointF &p1) - { - qreal minLocalDistance = std::numeric_limits::max(); - QLineF localClosestDistance; + std::function const DistanceFunc = [path2](const QPointF &p1) + { + qreal minLocalDistance = std::numeric_limits::max(); + QLineF localClosestDistance; - for (const auto &p2 : path2) - { - QLineF const d(p1, p2); - qreal const length = d.length(); - if (length < minLocalDistance) - { - minLocalDistance = length; - localClosestDistance = d; - } - } - - return localClosestDistance; - }, - [](QLineF &result, const QLineF &next) + for (const auto &p2 : path2) { - qreal const dist1 = result.length(); - qreal const dist2 = next.length(); - if (result.isNull() || dist2 < dist1) + QLineF const d(p1, p2); + qreal const length = d.length(); + if (length < minLocalDistance) { - result = next; + minLocalDistance = length; + localClosestDistance = d; } - }); + } + + return localClosestDistance; + }; + + std::function const ReduceFunc = [](QLineF &result, const QLineF &next) + { + qreal const dist1 = result.length(); + qreal const dist2 = next.length(); + if (result.isNull() || dist2 < dist1) + { + result = next; + } + }; + + return QtConcurrent::blockingMappedReduced(path1, DistanceFunc, ReduceFunc); } //---------------------------------------------------------------------------------------------------------------------