QScopedPointer::take() was deprecated since 6.1.

This commit is contained in:
Roman Telezhynskyi 2023-04-03 13:44:20 +03:00
parent e7e4e07162
commit 433389b798
9 changed files with 78 additions and 78 deletions

View File

@ -5849,8 +5849,8 @@ auto MainWindow::LoadPattern(QString fileName, const QString& customMeasureFile)
QFuture<VPatternConverter *> futureConverter = QtConcurrent::run([fileName]()
{
QScopedPointer<VPatternConverter> converter(new VPatternConverter(fileName));
return converter.take();
std::unique_ptr<VPatternConverter> converter(new VPatternConverter(fileName));
return converter.release();
});
//We have unsaved changes or load more then one file per time

View File

@ -1002,7 +1002,7 @@ QString VPatternConverter::FixMeasurementInFormulaToV0_2_0(const QString &formul
QScopedPointer<qmu::QmuTokenParser> cal(new qmu::QmuTokenParser(formula, false, false));// Eval formula
QMap<vsizetype, QString> tokens = cal->GetTokens();// Tokens (variables, measurements)
delete cal.take();
cal.reset();
QList<vsizetype> tKeys = tokens.keys();// Take all tokens positions
QList<QString> tValues = tokens.values();

View File

@ -2764,11 +2764,11 @@ bool dxfRW::processPolyline() {
bool dxfRW::processVertex(DRW_Polyline *pl) {
DRW_DBG("dxfRW::processVertex");
int code;
QScopedPointer<DRW_Vertex> v(new DRW_Vertex());
std::unique_ptr<DRW_Vertex> v(new DRW_Vertex());
while (reader->readRec(&code)) {
DRW_DBG(code); DRW_DBG("\n");
if (0 == code) {
pl->appendVertex(v.take());
pl->appendVertex(v.release());
nextentity = reader->getString();
DRW_DBG(nextentity); DRW_DBG("\n");
if (nextentity == "SEQEND") {

View File

@ -747,11 +747,11 @@ auto VDxfEngine::ExportToAAMA(const QVector<VLayoutPiece> &details) -> bool
m_input->AddBlock(detailBlock.data());
QScopedPointer<DRW_Insert> insert(new DRW_Insert());
std::unique_ptr<DRW_Insert> insert(new DRW_Insert());
insert->name = blockName.toStdString();
insert->layer = *layer1;
m_input->AddEntity(insert.take());
m_input->AddEntity(insert.release());
deleteBlock = false; // lose ownership
}
@ -977,11 +977,11 @@ auto VDxfEngine::ExportToASTM(const QVector<VLayoutPiece> &details) -> bool
m_input->AddBlock(detailBlock.data());
QScopedPointer<DRW_Insert> insert(new DRW_Insert());
std::unique_ptr<DRW_Insert> insert(new DRW_Insert());
insert->name = blockName.toStdString();
insert->layer = *layer1;
m_input->AddEntity(insert.take());
m_input->AddEntity(insert.release());
deleteBlock = false; // lose ownership
}

View File

@ -170,8 +170,8 @@ bool WatermarkWindow::Open(QString path)
QFuture<VWatermarkConverter *> futureConverter = QtConcurrent::run([path]()
{
QScopedPointer<VWatermarkConverter> converter(new VWatermarkConverter(path));
return converter.take();
std::unique_ptr<VWatermarkConverter> converter(new VWatermarkConverter(path));
return converter.release();
});
//We have unsaved changes or load more then one file per time

View File

@ -1051,7 +1051,7 @@ auto VTranslateVars::FormulaFromUser(const QString &formula, bool osSeparator) c
new qmu::QmuTokenParser(formula, osSeparator, true, GetTranslatedFunctions()));
QMap<vsizetype, QString> tokens = cal->GetTokens();// Tokens (variables, measurements)
QMap<vsizetype, QString> numbers = cal->GetNumbers();// All numbers in expression for changing decimal separator
delete cal.take();
cal.reset();
QString newFormula = formula;// Local copy for making changes

View File

@ -2050,7 +2050,7 @@ void VToolSeamAllowance::InitSpecialPoints(const QVector<quint32> &points) const
//---------------------------------------------------------------------------------------------------------------------
void VToolSeamAllowance::DeleteToolWithConfirm(bool ask)
{
QScopedPointer<DeletePiece> delDet(new DeletePiece(doc, m_id, VAbstractTool::data, m_sceneDetails));
std::unique_ptr<DeletePiece> delDet(new DeletePiece(doc, m_id, VAbstractTool::data, m_sceneDetails));
if (ask)
{
if (ConfirmDeletion() == QMessageBox::No)
@ -2059,7 +2059,7 @@ void VToolSeamAllowance::DeleteToolWithConfirm(bool ask)
}
}
VAbstractApplication::VApp()->getUndoStack()->push(delDet.take());
VAbstractApplication::VApp()->getUndoStack()->push(delDet.release());
// Throw exception, this will help prevent case when we forget to immediately quit function.
VExceptionToolWasDeleted e(tr("Tool was used after deleting."));

View File

@ -393,22 +393,22 @@ quint32 AddNodePoint(const VPieceNode &node, const VToolUnionDetailsInitData &in
QVector<quint32> &children, const QString &drawName, qreal dx, qreal dy,
quint32 pRotate, qreal angle)
{
QScopedPointer<VPointF> point(new VPointF(*initData.data->GeometricObject<VPointF>(node.GetId())));
std::unique_ptr<VPointF> point(new VPointF(*initData.data->GeometricObject<VPointF>(node.GetId())));
point->setMode(Draw::Modeling);
if (not qFuzzyIsNull(dx) || not qFuzzyIsNull(dy) || pRotate != NULL_ID)
{
BiasRotatePoint(point.data(), dx, dy, static_cast<QPointF>(*initData.data->GeometricObject<VPointF>(pRotate)),
BiasRotatePoint(point.get(), dx, dy, static_cast<QPointF>(*initData.data->GeometricObject<VPointF>(pRotate)),
angle);
}
QScopedPointer<VPointF> point1(new VPointF(*point));
std::unique_ptr<VPointF> point1(new VPointF(*point));
const quint32 idObject = initData.data->AddGObject(point.take());
const quint32 idObject = initData.data->AddGObject(point.release());
children.append(idObject);
point1->setIdObject(idObject);
point1->setMode(Draw::Modeling);
const quint32 id = initData.data->AddGObject(point1.take());
const quint32 id = initData.data->AddGObject(point1.release());
VAbstractNodeInitData initNodeData;
initNodeData.id = id;
@ -429,21 +429,21 @@ quint32 AddNodePoint(const VPieceNode &node, const VToolUnionDetailsInitData &in
quint32 AddPin(quint32 id, const VToolUnionDetailsInitData &initData, QVector<quint32> &children,
const QString &drawName, qreal dx, qreal dy, quint32 pRotate, qreal angle)
{
QScopedPointer<VPointF> point(new VPointF(*initData.data->GeometricObject<VPointF>(id)));
std::unique_ptr<VPointF> point(new VPointF(*initData.data->GeometricObject<VPointF>(id)));
point->setMode(Draw::Modeling);
if (not qFuzzyIsNull(dx) || not qFuzzyIsNull(dy) || pRotate != NULL_ID)
{
BiasRotatePoint(point.data(), dx, dy, static_cast<QPointF>(*initData.data->GeometricObject<VPointF>(pRotate)),
BiasRotatePoint(point.get(), dx, dy, static_cast<QPointF>(*initData.data->GeometricObject<VPointF>(pRotate)),
angle);
}
QScopedPointer<VPointF> point1(new VPointF(*point));
std::unique_ptr<VPointF> point1(new VPointF(*point));
const quint32 idObject = initData.data->AddGObject(point.take());
const quint32 idObject = initData.data->AddGObject(point.release());
children.append(idObject);
point1->setMode(Draw::Modeling);
const quint32 idPin = initData.data->AddGObject(point1.take());
const quint32 idPin = initData.data->AddGObject(point1.release());
VToolPinInitData initNodeData;
initNodeData.id = idPin;
@ -464,11 +464,11 @@ quint32 AddPin(quint32 id, const VToolUnionDetailsInitData &initData, QVector<qu
quint32 AddPlaceLabel(quint32 id, const VToolUnionDetailsInitData &initData, QVector<quint32> &children,
const QString &drawName, qreal dx, qreal dy, quint32 pRotate, qreal angle)
{
QScopedPointer<VPlaceLabelItem> label(new VPlaceLabelItem(*initData.data->GeometricObject<VPlaceLabelItem>(id)));
std::unique_ptr<VPlaceLabelItem> label(new VPlaceLabelItem(*initData.data->GeometricObject<VPlaceLabelItem>(id)));
if (not qFuzzyIsNull(dx) || not qFuzzyIsNull(dy) || pRotate != NULL_ID)
{
BiasRotatePoint(label.data(), dx, dy, static_cast<QPointF>(*initData.data->GeometricObject<VPointF>(pRotate)),
BiasRotatePoint(label.get(), dx, dy, static_cast<QPointF>(*initData.data->GeometricObject<VPointF>(pRotate)),
angle);
}
@ -488,12 +488,12 @@ quint32 AddPlaceLabel(quint32 id, const VToolUnionDetailsInitData &initData, QVe
initNodeData.visibilityTrigger = label->GetVisibilityTrigger();
initNodeData.type = label->GetLabelType();
QScopedPointer<VPlaceLabelItem> label1(new VPlaceLabelItem(*label));
std::unique_ptr<VPlaceLabelItem> label1(new VPlaceLabelItem(*label));
initNodeData.centerPoint = initData.data->AddGObject(label.take());
initNodeData.centerPoint = initData.data->AddGObject(label.release());
children.append(initNodeData.centerPoint);
const quint32 idLabel = initData.data->AddGObject(label1.take());
const quint32 idLabel = initData.data->AddGObject(label1.release());
initNodeData.id = idLabel;
VToolPlaceLabel::Create(initNodeData);
@ -508,7 +508,7 @@ quint32 AddNodeArc(const VPieceNode &node, const VToolUnionDetailsInitData &init
const QSharedPointer<VArc> arc = initData.data->GeometricObject<VArc>(node.GetId());
VPointF p1 = VPointF(arc->GetP1(), "A", 0, 0);
VPointF p2 = VPointF(arc->GetP2(), "A", 0, 0);
QScopedPointer<VPointF> center(new VPointF(arc->GetCenter()));
std::unique_ptr<VPointF> center(new VPointF(arc->GetCenter()));
if (not qFuzzyIsNull(dx) || not qFuzzyIsNull(dy) || pRotate != NULL_ID)
{
@ -516,27 +516,27 @@ quint32 AddNodeArc(const VPieceNode &node, const VToolUnionDetailsInitData &init
BiasRotatePoint(&p1, dx, dy, p, angle);
BiasRotatePoint(&p2, dx, dy, p, angle);
BiasRotatePoint(center.data(), dx, dy, p, angle);
BiasRotatePoint(center.get(), dx, dy, p, angle);
}
QLineF l1(static_cast<QPointF>(*center), static_cast<QPointF>(p1));
QLineF l2(static_cast<QPointF>(*center), static_cast<QPointF>(p2));
center->setMode(Draw::Modeling);
VPointF *tmpCenter = center.take();
VPointF *tmpCenter = center.release();
const quint32 idCenter = initData.data->AddGObject(tmpCenter);
Q_UNUSED(idCenter)
QScopedPointer<VArc> arc1(new VArc(*tmpCenter, arc->GetRadius(), arc->GetFormulaRadius(), l1.angle(),
QString().setNum(l1.angle()), l2.angle(), QString().setNum(l2.angle())));
std::unique_ptr<VArc> arc1(new VArc(*tmpCenter, arc->GetRadius(), arc->GetFormulaRadius(), l1.angle(),
QString().setNum(l1.angle()), l2.angle(), QString().setNum(l2.angle())));
arc1->setMode(Draw::Modeling);
QScopedPointer<VArc>arc2(new VArc(*arc1));
std::unique_ptr<VArc>arc2(new VArc(*arc1));
const quint32 idObject = initData.data->AddGObject(arc1.take());
const quint32 idObject = initData.data->AddGObject(arc1.release());
children.append(idObject);
arc2->setIdObject(idObject);
arc2->setMode(Draw::Modeling);
const quint32 id = initData.data->AddGObject(arc2.take());
const quint32 id = initData.data->AddGObject(arc2.release());
VAbstractNodeInitData initNodeData;
initNodeData.id = id;
@ -560,7 +560,7 @@ quint32 AddNodeElArc(const VPieceNode &node, const VToolUnionDetailsInitData &in
const QSharedPointer<VEllipticalArc> arc = initData.data->GeometricObject<VEllipticalArc>(node.GetId());
VPointF p1 = VPointF(arc->GetP1(), "A", 0, 0);
VPointF p2 = VPointF(arc->GetP2(), "A", 0, 0);
QScopedPointer<VPointF> center(new VPointF(arc->GetCenter()));
std::unique_ptr<VPointF> center(new VPointF(arc->GetCenter()));
if (not qFuzzyIsNull(dx) || not qFuzzyIsNull(dy) || pRotate != NULL_ID)
{
@ -568,29 +568,29 @@ quint32 AddNodeElArc(const VPieceNode &node, const VToolUnionDetailsInitData &in
BiasRotatePoint(&p1, dx, dy, p, angle);
BiasRotatePoint(&p2, dx, dy, p, angle);
BiasRotatePoint(center.data(), dx, dy, p, angle);
BiasRotatePoint(center.get(), dx, dy, p, angle);
}
QLineF l1(static_cast<QPointF>(*center), static_cast<QPointF>(p1));
QLineF l2(static_cast<QPointF>(*center), static_cast<QPointF>(p2));
center->setMode(Draw::Modeling);
VPointF *tmpCenter = center.take();
VPointF *tmpCenter = center.release();
quint32 idCenter = initData.data->AddGObject(tmpCenter);
Q_UNUSED(idCenter)
QScopedPointer<VEllipticalArc> arc1(new VEllipticalArc (*tmpCenter, arc->GetRadius1(), arc->GetRadius2(),
arc->GetFormulaRadius1(), arc->GetFormulaRadius2(),
l1.angle(), QString().setNum(l1.angle()), l2.angle(),
QString().setNum(l2.angle()), 0, QChar('0')));
std::unique_ptr<VEllipticalArc> arc1(new VEllipticalArc (*tmpCenter, arc->GetRadius1(), arc->GetRadius2(),
arc->GetFormulaRadius1(), arc->GetFormulaRadius2(),
l1.angle(), QString().setNum(l1.angle()), l2.angle(),
QString().setNum(l2.angle()), 0, QChar('0')));
arc1->setMode(Draw::Modeling);
QScopedPointer<VEllipticalArc> arc2(new VEllipticalArc(*arc1));
std::unique_ptr<VEllipticalArc> arc2(new VEllipticalArc(*arc1));
const quint32 idObject = initData.data->AddGObject(arc1.take());
const quint32 idObject = initData.data->AddGObject(arc1.release());
children.append(idObject);
arc2->setIdObject(idObject);
arc2->setMode(Draw::Modeling);
const quint32 id = initData.data->AddGObject(arc2.take());
const quint32 id = initData.data->AddGObject(arc2.release());
VAbstractNodeInitData initNodeData;
initNodeData.id = id;
@ -657,7 +657,7 @@ quint32 AddNodeSplinePath(const VPieceNode &node, const VToolUnionDetailsInitDat
QVector<quint32> &children, const QString &drawName, qreal dx, qreal dy,
quint32 pRotate, qreal angle)
{
QScopedPointer<VSplinePath> path(new VSplinePath());
std::unique_ptr<VSplinePath> path(new VSplinePath());
path->setMode(Draw::Modeling);
const QSharedPointer<VAbstractCubicBezierPath> splinePath =
initData.data->GeometricObject<VAbstractCubicBezierPath>(node.GetId());
@ -703,14 +703,14 @@ quint32 AddNodeSplinePath(const VPieceNode &node, const VToolUnionDetailsInitDat
path->append(VSplinePoint(*p4, spl.GetEndAngle(), spl.GetEndAngleFormula(), angle2, angle2F,
spline.GetC2Length(), spline.GetC2LengthFormula(), pL2, pL2F));
}
QScopedPointer<VSplinePath> path1(new VSplinePath(*path));
std::unique_ptr<VSplinePath> path1(new VSplinePath(*path));
const quint32 idObject = initData.data->AddGObject(path.take());
const quint32 idObject = initData.data->AddGObject(path.release());
children.append(idObject);
path1->setIdObject(idObject);
path1->setMode(Draw::Modeling);
const quint32 id = initData.data->AddGObject(path1.take());
const quint32 id = initData.data->AddGObject(path1.release());
VAbstractNodeInitData initNodeData;
initNodeData.id = id;
@ -935,13 +935,13 @@ quint32 TakeNextId(QVector<quint32> &children)
void UpdateNodePoint(VContainer *data, const VPieceNode &node, QVector<quint32> &children, qreal dx, qreal dy,
quint32 pRotate, qreal angle)
{
QScopedPointer<VPointF> point(new VPointF(*data->GeometricObject<VPointF>(node.GetId())));
std::unique_ptr<VPointF> point(new VPointF(*data->GeometricObject<VPointF>(node.GetId())));
point->setMode(Draw::Modeling);
if (not qFuzzyIsNull(dx) || not qFuzzyIsNull(dy) || pRotate != NULL_ID)
{
BiasRotatePoint(point.data(), dx, dy, static_cast<QPointF>(*data->GeometricObject<VPointF>(pRotate)), angle);
BiasRotatePoint(point.get(), dx, dy, static_cast<QPointF>(*data->GeometricObject<VPointF>(pRotate)), angle);
}
data->UpdateGObject(TakeNextId(children), point.take());
data->UpdateGObject(TakeNextId(children), point.release());
}
//---------------------------------------------------------------------------------------------------------------------
@ -965,10 +965,10 @@ void UpdateNodeArc(VContainer *data, const VPieceNode &node, QVector<quint32> &c
QLineF l1(static_cast<QPointF>(*center), static_cast<QPointF>(p1));
QLineF l2(static_cast<QPointF>(*center), static_cast<QPointF>(p2));
QScopedPointer<VArc> arc1(new VArc(*center, arc->GetRadius(), arc->GetFormulaRadius(), l1.angle(),
QString().setNum(l1.angle()), l2.angle(), QString().setNum(l2.angle())));
std::unique_ptr<VArc> arc1(new VArc(*center, arc->GetRadius(), arc->GetFormulaRadius(), l1.angle(),
QString().setNum(l1.angle()), l2.angle(), QString().setNum(l2.angle())));
arc1->setMode(Draw::Modeling);
data->UpdateGObject(TakeNextId(children), arc1.take());
data->UpdateGObject(TakeNextId(children), arc1.release());
}
//---------------------------------------------------------------------------------------------------------------------
@ -992,12 +992,12 @@ void UpdateNodeElArc(VContainer *data, const VPieceNode &node, QVector<quint32>
QLineF l1(static_cast<QPointF>(*center), static_cast<QPointF>(p1));
QLineF l2(static_cast<QPointF>(*center), static_cast<QPointF>(p2));
QScopedPointer<VEllipticalArc> arc1(new VEllipticalArc (*center, arc->GetRadius1(), arc->GetRadius2(),
arc->GetFormulaRadius1(), arc->GetFormulaRadius2(),
l1.angle(), QString().setNum(l1.angle()), l2.angle(),
QString().setNum(l2.angle()), 0, QChar('0')));
std::unique_ptr<VEllipticalArc> arc1(new VEllipticalArc (*center, arc->GetRadius1(), arc->GetRadius2(),
arc->GetFormulaRadius1(), arc->GetFormulaRadius2(),
l1.angle(), QString().setNum(l1.angle()), l2.angle(),
QString().setNum(l2.angle()), 0, QChar('0')));
arc1->setMode(Draw::Modeling);
data->UpdateGObject(TakeNextId(children), arc1.take());
data->UpdateGObject(TakeNextId(children), arc1.release());
}
//---------------------------------------------------------------------------------------------------------------------
@ -1022,16 +1022,16 @@ void UpdateNodeSpline(VContainer *data, const VPieceNode &node, QVector<quint32>
BiasRotatePoint(p4.data(), dx, dy, p, angle);
}
QScopedPointer<VSpline> spl(new VSpline(*p1, static_cast<QPointF>(p2), static_cast<QPointF>(p3), *p4, 0,
Draw::Modeling));
data->UpdateGObject(TakeNextId(children), spl.take());
std::unique_ptr<VSpline> spl(new VSpline(*p1, static_cast<QPointF>(p2), static_cast<QPointF>(p3), *p4, 0,
Draw::Modeling));
data->UpdateGObject(TakeNextId(children), spl.release());
}
//---------------------------------------------------------------------------------------------------------------------
void UpdateNodeSplinePath(VContainer *data, const VPieceNode &node, QVector<quint32> &children, qreal dx, qreal dy,
quint32 pRotate, qreal angle)
{
QScopedPointer<VSplinePath> path(new VSplinePath());
std::unique_ptr<VSplinePath> path(new VSplinePath());
path->setMode(Draw::Modeling);
const QSharedPointer<VAbstractCubicBezierPath> splinePath =
data->GeometricObject<VAbstractCubicBezierPath>(node.GetId());
@ -1080,7 +1080,7 @@ void UpdateNodeSplinePath(VContainer *data, const VPieceNode &node, QVector<quin
path->append(VSplinePoint(*p4, spl.GetEndAngle(), spl.GetEndAngleFormula(), angle2, angle2F,
spline.GetC2Length(), spline.GetC2LengthFormula(), pL2, pL2F));
}
data->UpdateGObject(TakeNextId(children), path.take());
data->UpdateGObject(TakeNextId(children), path.release());
}
//---------------------------------------------------------------------------------------------------------------------
@ -1498,14 +1498,14 @@ void UpdateUnitedDetailPins(const VToolUnionDetailsInitData &initData, qreal dx,
for (auto record : records)
{
QScopedPointer<VPointF> point(new VPointF(*initData.data->GeometricObject<VPointF>(record)));
std::unique_ptr<VPointF> point(new VPointF(*initData.data->GeometricObject<VPointF>(record)));
point->setMode(Draw::Modeling);
if (not qFuzzyIsNull(dx) || not qFuzzyIsNull(dy) || pRotate != NULL_ID)
{
BiasRotatePoint(point.data(), dx, dy,
BiasRotatePoint(point.get(), dx, dy,
static_cast<QPointF>(*initData.data->GeometricObject<VPointF>(pRotate)), angle);
}
initData.data->UpdateGObject(TakeNextId(children), point.take());
initData.data->UpdateGObject(TakeNextId(children), point.release());
}
}
@ -1523,7 +1523,7 @@ void UpdateUnitedDetailPlaceLabels(const VToolUnionDetailsInitData &initData, qr
BiasRotatePoint(parentLabel.data(), dx, dy,
static_cast<QPointF>(*initData.data->GeometricObject<VPointF>(pRotate)), angle);
}
QScopedPointer<VPlaceLabelItem> label(new VPlaceLabelItem());
std::unique_ptr<VPlaceLabelItem> label(new VPlaceLabelItem());
label->setName(parentLabel->name());
label->setX(parentLabel->x());
label->setY(parentLabel->y());
@ -1531,7 +1531,7 @@ void UpdateUnitedDetailPlaceLabels(const VToolUnionDetailsInitData &initData, qr
label->setMy(parentLabel->my());
label->SetCorrectionAngle(parentLabel->GetCorrectionAngle()+angle);
initData.data->UpdateGObject(TakeNextId(children), label.take());
initData.data->UpdateGObject(TakeNextId(children), label.release());
}
}

View File

@ -61,30 +61,30 @@ VHighlighter::VHighlighter(QTextDocument *document)
//---------------------------------------------------------------------------------------------------------------------
void VHighlighter::highlightBlock(const QString &text)
{
QScopedPointer<VTextBlockData> data(new VTextBlockData);
std::unique_ptr<VTextBlockData> data(new VTextBlockData);
vsizetype leftPos = text.indexOf('(');
while (leftPos != -1)
{
QScopedPointer<ParenthesisInfo> info(new ParenthesisInfo);
std::unique_ptr<ParenthesisInfo> info(new ParenthesisInfo);
info->character = '(';
info->position = leftPos;
data->insert(info.take());
data->insert(info.release());
leftPos = text.indexOf('(', leftPos + 1);
}
vsizetype rightPos = text.indexOf(')');
while (rightPos != -1)
{
QScopedPointer<ParenthesisInfo> info(new ParenthesisInfo);
std::unique_ptr<ParenthesisInfo> info(new ParenthesisInfo);
info->character = ')';
info->position = rightPos;
data->insert(info.take());
data->insert(info.release());
rightPos = text.indexOf(')', rightPos +1);
}
setCurrentBlockUserData(data.take());
setCurrentBlockUserData(data.release());
}