From 154c2c07087f2eff56ef8eb7cd2924f4615204fc Mon Sep 17 00:00:00 2001 From: dismine Date: Thu, 12 Jun 2014 12:51:40 +0300 Subject: [PATCH] Return method GarbageCollector. --HG-- branch : feature --- src/app/xml/vdomdocument.h | 1 - src/app/xml/vpattern.cpp | 22 ++++++++++++++++++++++ src/app/xml/vpattern.h | 1 + 3 files changed, 23 insertions(+), 1 deletion(-) diff --git a/src/app/xml/vdomdocument.h b/src/app/xml/vdomdocument.h index 5a51dfdec..cb1ed24b6 100644 --- a/src/app/xml/vdomdocument.h +++ b/src/app/xml/vdomdocument.h @@ -152,7 +152,6 @@ protected: */ VContainer *data; void setTagText(const QString &tag, const QString &text); - private: Q_DISABLE_COPY(VDomDocument) /** diff --git a/src/app/xml/vpattern.cpp b/src/app/xml/vpattern.cpp index a2ef41579..6b02f4b73 100644 --- a/src/app/xml/vpattern.cpp +++ b/src/app/xml/vpattern.cpp @@ -639,6 +639,7 @@ bool VPattern::SaveDocument(const QString &fileName) e.CriticalMessageBox(tr("Error no unique id.")); return false; } + return VDomDocument::SaveDocument(fileName); } @@ -1865,7 +1866,28 @@ void VPattern::UpdateMeasurements() } } +//--------------------------------------------------------------------------------------------------------------------- +void VPattern::GarbageCollector() +{ + QHashIterator 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()< &vector)const; void PrepareForParse(const Document &parse); void UpdateMeasurements(); + void GarbageCollector(); }; //---------------------------------------------------------------------------------------------------------------------