QtConcurrent::run signature was switched up.

Switching to using lambdas instead of binding the methods.
This commit is contained in:
Roman Telezhynskyi 2023-02-09 15:35:38 +02:00
parent 734e5d0d11
commit 404f870069
6 changed files with 42 additions and 32 deletions

View File

@ -2692,7 +2692,7 @@ auto MainWindow::FullParsePattern() -> bool
{
if (VAbstractValApplication::VApp()->getOpeningPattern())
{
futureTestUniqueId = QtConcurrent::run(static_cast<VDomDocument *>(doc), &VDomDocument::TestUniqueId); // clazy:exclude=unneeded-cast
futureTestUniqueId = QtConcurrent::run([this](){doc->TestUniqueId();});
}
SetEnabledGUI(true);

View File

@ -1025,9 +1025,12 @@ void VPattern::ParseDetailInternals(const QDomElement &domElement, VPiece &detai
// TODO. Delete if minimal supported version is 0.4.0
Q_STATIC_ASSERT_X(VPatternConverter::PatternMinVer < FormatVersion(0, 4, 0),
"Time to refactor the code.");
const bool closed = GetParametrUInt(domElement, AttrClosed, QChar('1'));
const qreal width = GetParametrDouble(domElement, AttrWidth, QStringLiteral("0.0"));
futurePathV1 = QtConcurrent::run(this, &VPattern::ParseDetailNodes, element, width, closed);
futurePathV1 = QtConcurrent::run([this, domElement, element]()
{
const bool closed = GetParametrUInt(domElement, AttrClosed, QChar('1'));
const qreal width = GetParametrDouble(domElement, AttrWidth, QStringLiteral("0.0"));
return ParseDetailNodes(element, width, closed);
});
}
else
{
@ -1035,16 +1038,22 @@ void VPattern::ParseDetailInternals(const QDomElement &domElement, VPiece &detai
}
break;
case 1:// TagData
futurePPData = QtConcurrent::run(this, &VPattern::ParsePieceDataTag, element,
detail.GetPieceLabelData());
futurePPData = QtConcurrent::run([this, element, detail]()
{
return ParsePieceDataTag(element, detail.GetPieceLabelData());
});
break;
case 2:// TagPatternInfo
futurePatternInfo = QtConcurrent::run(this, &VPattern::ParsePiecePatternInfo, element,
detail.GetPatternLabelData());
futurePatternInfo = QtConcurrent::run([this, element, detail]()
{
return ParsePiecePatternInfo(element, detail.GetPatternLabelData());
});
break;
case 3:// TagGrainline
futureGGeometry = QtConcurrent::run(this, &VPattern::ParsePieceGrainline, element,
detail.GetGrainlineGeometry());
futureGGeometry = QtConcurrent::run([this, element, detail]()
{
return ParsePieceGrainline(element, detail.GetGrainlineGeometry());
});
break;
case 4:// VToolSeamAllowance::TagCSA
futureRecords = QtConcurrent::run(&VPattern::ParsePieceCSARecords, element);

View File

@ -324,7 +324,7 @@ bool VAbstractPattern::RequiresMeasurements() const
//---------------------------------------------------------------------------------------------------------------------
QStringList VAbstractPattern::ListMeasurements() const
{
const QFuture<QStringList> futureIncrements = QtConcurrent::run(this, &VAbstractPattern::ListIncrements);
const QFuture<QStringList> futureIncrements = QtConcurrent::run([this](){return ListIncrements();});
const QList<QString> tokens = ConvertToList(QtConcurrent::blockingMappedReduced(ListExpressions(), GetTokens,
GatherTokens));
@ -1722,16 +1722,15 @@ QVector<VFormulaField> VAbstractPattern::ListExpressions() const
// If new tool bring absolutely new type and has formula(s) create new method to cover it.
// Note. Tool Union Details also contains formulas, but we don't use them for union and keep only to simplifying
// working with nodes. Same code for saving reading.
auto futurePointExpressions = QtConcurrent::run(this, &VAbstractPattern::ListPointExpressions);
auto futureArcExpressions = QtConcurrent::run(this, &VAbstractPattern::ListArcExpressions);
auto futureElArcExpressions = QtConcurrent::run(this, &VAbstractPattern::ListElArcExpressions);
auto futureSplineExpressions = QtConcurrent::run(this, &VAbstractPattern::ListSplineExpressions);
auto futureIncrementExpressions = QtConcurrent::run(this, &VAbstractPattern::ListIncrementExpressions);
auto futureOperationExpressions = QtConcurrent::run(this, &VAbstractPattern::ListOperationExpressions);
auto futurePathExpressions = QtConcurrent::run(this, &VAbstractPattern::ListPathExpressions);
auto futurePieceExpressions = QtConcurrent::run(this, &VAbstractPattern::ListPieceExpressions);
auto futureFinalMeasurementsExpressions = QtConcurrent::run(this,
&VAbstractPattern::ListFinalMeasurementsExpressions);
auto futurePointExpressions = QtConcurrent::run([this](){return ListPointExpressions();});
auto futureArcExpressions = QtConcurrent::run([this](){return ListArcExpressions();});
auto futureElArcExpressions = QtConcurrent::run([this](){return ListElArcExpressions();});
auto futureSplineExpressions = QtConcurrent::run([this](){return ListSplineExpressions();});
auto futureIncrementExpressions = QtConcurrent::run([this](){return ListIncrementExpressions();});
auto futureOperationExpressions = QtConcurrent::run([this](){return ListOperationExpressions();});
auto futurePathExpressions = QtConcurrent::run([this](){return ListPathExpressions();});
auto futurePieceExpressions = QtConcurrent::run([this](){return ListPieceExpressions();});
auto futureFinalMeasurementsExpressions = QtConcurrent::run([this](){return ListFinalMeasurementsExpressions();});
QVector<VFormulaField> list;
list << futurePointExpressions.result();

View File

@ -703,7 +703,7 @@ void VDomDocument::RefreshElementIdCache()
{
if (m_watcher->isFinished())
{
m_watcher->setFuture(QtConcurrent::run(this, &VDomDocument::RefreshCache, documentElement()));
m_watcher->setFuture(QtConcurrent::run([this](){return RefreshCache(documentElement());}));
}
}

View File

@ -622,10 +622,12 @@ VLayoutPiece::~VLayoutPiece() //NOLINT(modernize-use-equals-default)
//---------------------------------------------------------------------------------------------------------------------
auto VLayoutPiece::Create(const VPiece &piece, vidtype id, const VContainer *pattern) -> VLayoutPiece
{
QFuture<QVector<VLayoutPoint> > futureSeamAllowance = QtConcurrent::run(piece, &VPiece::SeamAllowancePoints,
pattern);
QFuture<bool> futureSeamAllowanceValid = QtConcurrent::run(piece, &VPiece::IsSeamAllowanceValid, pattern);
QFuture<QVector<VLayoutPoint> > futureMainPath = QtConcurrent::run(piece, &VPiece::MainPathPoints, pattern);
QFuture<QVector<VLayoutPoint> > futureSeamAllowance =
QtConcurrent::run([piece, pattern](){return piece.SeamAllowancePoints(pattern);});
QFuture<bool> futureSeamAllowanceValid =
QtConcurrent::run([piece, pattern](){return piece.IsSeamAllowanceValid(pattern);});
QFuture<QVector<VLayoutPoint> > futureMainPath =
QtConcurrent::run([piece, pattern](){return piece.MainPathPoints(pattern);});
QFuture<QVector<VLayoutPiecePath> > futureInternalPaths = QtConcurrent::run(ConvertInternalPaths, piece, pattern);
QFuture<QVector<VLayoutPassmark> > futurePassmarks = QtConcurrent::run(ConvertPassmarks, piece, pattern);
QFuture<QVector<VLayoutPlaceLabel> > futurePlaceLabels = QtConcurrent::run(ConvertPlaceLabels, piece, pattern);

View File

@ -1424,18 +1424,18 @@ void VToolSeamAllowance::RefreshGeometry(bool updateChildren)
this->setFlag(QGraphicsItem::ItemSendsGeometryChanges, false);
const VPiece detail = VAbstractTool::data.GetPiece(m_id);
QFuture<QPainterPath > futurePath = QtConcurrent::run(detail,
QOverload<const VContainer *>::of(&VPiece::MainPathPath),
this->getData());
QFuture<QPainterPath > futurePassmarks = QtConcurrent::run(detail, &VPiece::PassmarksPath, this->getData());
QFuture<QPainterPath > futurePath = QtConcurrent::run([this, detail](){return detail.MainPathPath(getData());});
QFuture<QPainterPath > futurePassmarks =
QtConcurrent::run([this, detail](){return detail.PassmarksPath(getData());});
QFuture<QVector<VLayoutPoint> > futureSeamAllowance;
QFuture<bool> futureSeamAllowanceValid;
if (detail.IsSeamAllowance())
{
futureSeamAllowance = QtConcurrent::run(detail, &VPiece::SeamAllowancePoints, this->getData());
futureSeamAllowanceValid = QtConcurrent::run(detail, &VPiece::IsSeamAllowanceValid, this->getData());
futureSeamAllowance = QtConcurrent::run([this, detail](){return detail.SeamAllowancePoints(getData());});
futureSeamAllowanceValid = QtConcurrent::run([this, detail](){return detail.IsSeamAllowanceValid(getData());});
}
this->setPos(detail.GetMx(), detail.GetMy());