Cppcheck. Fix for garbage collector.
--HG-- branch : develop
This commit is contained in:
parent
0101a6f56c
commit
3e363aea81
|
@ -463,59 +463,6 @@ void VContainer::ClearCalculationGObjects()
|
|||
}
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief FindVar return value of variable by name
|
||||
* @param name name of variable
|
||||
* @param ok false if can't find variable
|
||||
* @return value of variable
|
||||
*/
|
||||
qreal VContainer::FindVar(const QString &name, bool *ok)const
|
||||
{
|
||||
if (sizeName == name)
|
||||
{
|
||||
*ok = true;
|
||||
return _size;
|
||||
}
|
||||
if (heightName == name)
|
||||
{
|
||||
*ok = true;
|
||||
return _height;
|
||||
}
|
||||
if (measurements.contains(name))
|
||||
{
|
||||
*ok = true;
|
||||
return GetValueStandardTableRow(name);
|
||||
}
|
||||
if (increments.contains(name))
|
||||
{
|
||||
*ok = true;
|
||||
return GetValueIncrementTableRow(name);
|
||||
}
|
||||
if (lengthLines.contains(name))
|
||||
{
|
||||
*ok = true;
|
||||
return lengthLines.value(name);
|
||||
}
|
||||
if (lengthArcs.contains(name))
|
||||
{
|
||||
*ok = true;
|
||||
return lengthArcs.value(name);
|
||||
}
|
||||
if (lineAngles.contains(name))
|
||||
{
|
||||
*ok = true;
|
||||
return lineAngles.value(name);
|
||||
}
|
||||
if (lengthSplines.contains(name))
|
||||
{
|
||||
*ok = true;
|
||||
return lengthSplines.value(name);
|
||||
}
|
||||
*ok = false;
|
||||
return 0;
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
/**
|
||||
* @brief AddLine add line to container
|
||||
|
|
|
@ -127,7 +127,6 @@ public:
|
|||
QString SizeName()const;
|
||||
qreal height() const;
|
||||
QString HeightName()const;
|
||||
qreal FindVar(const QString& name, bool *ok)const;
|
||||
bool IncrementTableContains(const QString& name);
|
||||
static quint32 getNextId();
|
||||
void RemoveIncrementTableRow(const QString& name);
|
||||
|
|
|
@ -133,6 +133,7 @@ QString VException::DetailedInformation() const
|
|||
* @brief clone clone exception
|
||||
* @return new exception
|
||||
*/
|
||||
// cppcheck-suppress unusedFunction
|
||||
VException *VException::clone() const
|
||||
{
|
||||
return new VException(*this);
|
||||
|
|
|
@ -47,6 +47,7 @@ public:
|
|||
virtual ~VException() noexcept (true){}
|
||||
|
||||
virtual void raise() const;
|
||||
// cppcheck-suppress unusedFunction
|
||||
virtual VException *clone() const;
|
||||
virtual QString ErrorMessage() const;
|
||||
virtual QString DetailedInformation() const;
|
||||
|
|
|
@ -586,4 +586,5 @@ void VToolDetail::InitTool(VMainGraphicsScene *scene, const VNodeDetail &node)
|
|||
SCASSERT(tool != nullptr);
|
||||
connect(tool, &Tool::ChoosedTool, scene, &VMainGraphicsScene::ChoosedItem);
|
||||
tool->setParentItem(this);
|
||||
doc->IncrementReferens(node.getId());
|
||||
}
|
||||
|
|
|
@ -41,6 +41,7 @@ AddDet::~AddDet()
|
|||
{}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
// cppcheck-suppress unusedFunction
|
||||
void AddDet::undo()
|
||||
{
|
||||
QDomElement element;
|
||||
|
@ -57,6 +58,7 @@ void AddDet::undo()
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
// cppcheck-suppress unusedFunction
|
||||
void AddDet::redo()
|
||||
{
|
||||
QDomElement element;
|
||||
|
|
|
@ -40,7 +40,9 @@ class AddDet : public QObject, public QUndoCommand
|
|||
public:
|
||||
AddDet(const QDomElement &xml, VPattern *doc, QUndoCommand *parent = 0);
|
||||
virtual ~AddDet();
|
||||
// cppcheck-suppress unusedFunction
|
||||
virtual void undo();
|
||||
// cppcheck-suppress unusedFunction
|
||||
virtual void redo();
|
||||
signals:
|
||||
void NeedFullParsing();
|
||||
|
|
|
@ -67,6 +67,7 @@ void DeleteDetail::redo()
|
|||
{
|
||||
parentNode.removeChild(domElement);
|
||||
|
||||
//When UnionDetail delete detail we can't use FullParsing. So we hide detail on scene directly.
|
||||
QHash<quint32, VDataTool*>* tools = doc->getTools();
|
||||
SCASSERT(tools != nullptr);
|
||||
VToolDetail *toolDet = qobject_cast<VToolDetail*>(tools->value(detId));
|
||||
|
|
|
@ -107,6 +107,7 @@ void MoveDetail::redo()
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
// cppcheck-suppress unusedFunction
|
||||
bool MoveDetail::mergeWith(const QUndoCommand *command)
|
||||
{
|
||||
const MoveDetail *moveCommand = static_cast<const MoveDetail *>(command);
|
||||
|
|
|
@ -43,6 +43,7 @@ public:
|
|||
virtual ~MoveDetail();
|
||||
virtual void undo();
|
||||
virtual void redo();
|
||||
// cppcheck-suppress unusedFunction
|
||||
virtual bool mergeWith(const QUndoCommand *command);
|
||||
virtual int id() const;
|
||||
quint32 getDetId() const;
|
||||
|
|
|
@ -65,6 +65,7 @@ void SaveDetailOptions::undo()
|
|||
{
|
||||
VAbstractNode *node = qobject_cast<VAbstractNode *>(tools->value(nodes.at(i).getId()));
|
||||
node->RestoreNode();
|
||||
doc->IncrementReferens(nodes.at(i).getId());
|
||||
}
|
||||
}
|
||||
emit NeedLiteParsing();
|
||||
|
@ -102,6 +103,7 @@ void SaveDetailOptions::redo()
|
|||
{
|
||||
VAbstractNode *node = qobject_cast<VAbstractNode *>(tools->value(list.at(i)));
|
||||
node->DeleteNode();
|
||||
doc->DecrementReferens(list.at(i));
|
||||
}
|
||||
}
|
||||
emit NeedLiteParsing();
|
||||
|
|
|
@ -1716,18 +1716,6 @@ QString VApplication::Description(const QString &measurement) const
|
|||
return descriptions.value(measurement).translate();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VApplication::Variable(const QString &name) const
|
||||
{
|
||||
return variables.value(name).translate();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VApplication::Function(const QString &name) const
|
||||
{
|
||||
return functions.value(name).translate();
|
||||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
QString VApplication::PostfixOperator(const QString &name) const
|
||||
{
|
||||
|
|
|
@ -67,8 +67,6 @@ public:
|
|||
QString VarFromUser(const QString &var) const;
|
||||
QString GuiText(const QString &measurement) const;
|
||||
QString Description(const QString &measurement) const;
|
||||
QString Variable(const QString &name) const;
|
||||
QString Function(const QString &name) const;
|
||||
QString PostfixOperator(const QString &name) const;
|
||||
QString FormulaFromUser(const QString &formula);
|
||||
QString FormulaToUser(const QString &formula);
|
||||
|
|
|
@ -50,7 +50,7 @@ signals:
|
|||
* @param pos new posotion.
|
||||
*/
|
||||
void ControlPointChangePosition(const qint32 &indexSpline, SplinePointPosition position,
|
||||
const QPointF pos);
|
||||
const QPointF &pos);
|
||||
public slots:
|
||||
void RefreshLine(const qint32 &indexSpline, SplinePointPosition pos, const QPointF &controlPoint,
|
||||
const QPointF &splinePoint);
|
||||
|
|
|
@ -53,7 +53,7 @@ signals:
|
|||
* @brief NameChangePosition emit when label change position.
|
||||
* @param pos new posotion.
|
||||
*/
|
||||
void NameChangePosition(const QPointF pos);
|
||||
void NameChangePosition(const QPointF &pos);
|
||||
/**
|
||||
* @brief ShowContextMenu emit when need show tool context menu.
|
||||
* @param event context menu event.
|
||||
|
|
|
@ -76,6 +76,7 @@ inline qint64 MessageHandler::column() const
|
|||
}
|
||||
|
||||
//---------------------------------------------------------------------------------------------------------------------
|
||||
// cppcheck-suppress unusedFunction
|
||||
void MessageHandler::handleMessage(QtMsgType type, const QString &description, const QUrl &identifier,
|
||||
const QSourceLocation &sourceLocation)
|
||||
{
|
||||
|
|
|
@ -637,6 +637,7 @@ bool VPattern::SaveDocument(const QString &fileName)
|
|||
e.CriticalMessageBox(tr("Error no unique id."));
|
||||
return false;
|
||||
}
|
||||
GarbageCollector();
|
||||
|
||||
return VDomDocument::SaveDocument(fileName);
|
||||
}
|
||||
|
@ -1868,17 +1869,19 @@ void VPattern::UpdateMeasurements()
|
|||
void VPattern::GarbageCollector()
|
||||
{
|
||||
QHashIterator<quint32, VDataTool*> t(tools);
|
||||
while (t.hasNext()) {
|
||||
while (t.hasNext())
|
||||
{
|
||||
t.next();
|
||||
VDataTool *tool = t.value();
|
||||
if(tool->referens() <= 0){
|
||||
if(tool->referens() <= 1)
|
||||
{
|
||||
QDomElement domElement = elementById(QString().setNum(t.key()));
|
||||
if(domElement.isElement()){
|
||||
if(domElement.isElement())
|
||||
{
|
||||
QDomNode parent = domElement.parentNode();
|
||||
if(!parent.isNull()){
|
||||
if(parent.isNull() == false && parent.toElement().tagName() == TagModeling)
|
||||
{
|
||||
parent.removeChild(domElement);
|
||||
} else {
|
||||
qWarning()<<tr("Can't get parent for object id = %1").arg(t.key());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user