Compare commits

...

2 commits

Author SHA1 Message Date
Roman Telezhynskyi b1470053f7 Fix incorrect memory management. 2023-03-30 17:20:16 +03:00
Roman Telezhynskyi e1e3a5106e For calculating area a formula needs CurrentSeamAllowance variable. 2023-03-30 15:41:37 +03:00
2 changed files with 35 additions and 6 deletions

View file

@ -711,8 +711,17 @@ auto VDxfEngine::ExportToAAMA(const QVector<VLayoutPiece> &details) -> bool
for(auto detail : details)
{
// Use custom deleter function to lose ownership after adding the block
bool deleteBlock = true;
auto NoOpDeleter =[&deleteBlock](dx_ifaceBlock* block)
{
if (deleteBlock)
{
delete block;
}
};
auto detailBlock = QSharedPointer<dx_ifaceBlock>::create();
auto detailBlock = QSharedPointer<dx_ifaceBlock>(new dx_ifaceBlock, NoOpDeleter);
QString blockName = detail.GetName();
if (m_version <= DRW::AC1009)
@ -740,6 +749,8 @@ auto VDxfEngine::ExportToAAMA(const QVector<VLayoutPiece> &details) -> bool
insert->layer = *layer1;
m_input->AddEntity(insert.take());
deleteBlock = false; // lose ownership
}
return m_input->fileExport(m_binary);
@ -929,7 +940,16 @@ auto VDxfEngine::ExportToASTM(const QVector<VLayoutPiece> &details) -> bool
for(auto detail : details)
{
auto detailBlock = QSharedPointer<dx_ifaceBlock>::create();
// Use custom deleter function to lose ownership after adding the block
bool deleteBlock = true;
auto NoOpDeleter =[&deleteBlock](dx_ifaceBlock* block)
{
if (deleteBlock)
{
delete block;
}
};
auto detailBlock = QSharedPointer<dx_ifaceBlock>(new dx_ifaceBlock, NoOpDeleter);
QString blockName = detail.GetName();
if (m_version <= DRW::AC1009)
@ -959,6 +979,8 @@ auto VDxfEngine::ExportToASTM(const QVector<VLayoutPiece> &details) -> bool
insert->layer = *layer1;
m_input->AddEntity(insert.take());
deleteBlock = false; // lose ownership
}
return m_input->fileExport(m_binary);

View file

@ -27,8 +27,9 @@
*************************************************************************/
#include "vpiecearea.h"
#include "vpiecearea_p.h"
#include "../vpatterndb/vpiece.h"
#include "../vpatterndb/vcontainer.h"
#include "../vpiece.h"
#include "../vcontainer.h"
#include "vincrement.h"
#include <QRegularExpression>
@ -48,17 +49,23 @@ VPieceArea::VPieceArea(PieceAreaType type, quint32 pieceId, const VPiece &piece,
QString shortName = PieceShortName(piece);
VContainer tempData = *data;
auto currentSA = new VIncrement(&tempData, currentSeamAllowance);
currentSA->SetFormula(piece.GetSAWidth(), QString().setNum(piece.GetSAWidth()), true);
tempData.AddVariable(currentSA);
if (type == PieceAreaType::External)
{
SetType(VarType::PieceExternalArea);
SetName(pieceArea_ + shortName);
VInternalVariable::SetValue(FromPixel2(piece.ExternalArea(data), unit));
VInternalVariable::SetValue(FromPixel2(piece.ExternalArea(&tempData), unit));
}
else
{
SetType(VarType::PieceSeamLineArea);
SetName(pieceSeamLineArea_ + shortName);
VInternalVariable::SetValue(FromPixel2(piece.SeamLineArea(data), unit));
VInternalVariable::SetValue(FromPixel2(piece.SeamLineArea(&tempData), unit));
}
}