Return method GarbageCollector.

--HG--
branch : feature
This commit is contained in:
dismine 2014-06-12 12:51:40 +03:00
parent bc545db1dc
commit 154c2c0708
3 changed files with 23 additions and 1 deletions

View File

@ -152,7 +152,6 @@ protected:
*/ */
VContainer *data; VContainer *data;
void setTagText(const QString &tag, const QString &text); void setTagText(const QString &tag, const QString &text);
private: private:
Q_DISABLE_COPY(VDomDocument) Q_DISABLE_COPY(VDomDocument)
/** /**

View File

@ -639,6 +639,7 @@ bool VPattern::SaveDocument(const QString &fileName)
e.CriticalMessageBox(tr("Error no unique id.")); e.CriticalMessageBox(tr("Error no unique id."));
return false; return false;
} }
return VDomDocument::SaveDocument(fileName); return VDomDocument::SaveDocument(fileName);
} }
@ -1865,7 +1866,28 @@ void VPattern::UpdateMeasurements()
} }
} }
//---------------------------------------------------------------------------------------------------------------------
void VPattern::GarbageCollector()
{
QHashIterator<quint32, VDataTool*> t(tools);
while (t.hasNext()) {
t.next();
VDataTool *tool = t.value();
if(tool->referens() <= 0){
QDomElement domElement = elementById(QString().setNum(t.key()));
if(domElement.isElement()){
QDomNode parent = domElement.parentNode();
if(!parent.isNull()){
parent.removeChild(domElement);
} else {
qWarning()<<tr("Can't get parent for object id = %1").arg(t.key());
}
}
}
}
}
//---------------------------------------------------------------------------------------------------------------------
QDomElement VPattern::GetPPElement(const QString &name) QDomElement VPattern::GetPPElement(const QString &name)
{ {
if (name.isEmpty() == false) if (name.isEmpty() == false)

View File

@ -197,6 +197,7 @@ private:
void CollectId(const QDomElement &node, QVector<quint32> &vector)const; void CollectId(const QDomElement &node, QVector<quint32> &vector)const;
void PrepareForParse(const Document &parse); void PrepareForParse(const Document &parse);
void UpdateMeasurements(); void UpdateMeasurements();
void GarbageCollector();
}; };
//--------------------------------------------------------------------------------------------------------------------- //---------------------------------------------------------------------------------------------------------------------