Skip to content
Snippets Groups Projects
Commit a29d9aac authored by Oliver Bock's avatar Oliver Bock
Browse files

- Improved memory management (QPointer, delete list entries on destruction)

- Use namespaces properly

git-svn-id: https://svn.origo.ethz.ch/fidelity@17 53d1999f-d1a8-4366-aa61-588fded17473
parent 3d4da960
No related branches found
No related tags found
No related merge requests found
......@@ -20,23 +20,32 @@
#include "VOTR.h"
Fidelity::Common::VOTR::VOTR()
namespace Fidelity {
namespace Common {
VOTR::VOTR()
{
initAttributes();
}
Fidelity::Common::VOTR::~VOTR()
VOTR::~VOTR()
{
// iterate over list and delete all referenced entries
while (!m_TDList->isEmpty()) {
QPointer<VOTD> entry = m_TDList->takeFirst();
if(entry) {delete entry;}
}
delete m_TDList;
}
void Fidelity::Common::VOTR::initAttributes()
void VOTR::initAttributes()
{
m_TDList = new QList<VOTD*>();
m_TDList = new QList<QPointer<VOTD> >();
}
bool Fidelity::Common::VOTR::buildXml(QDomElement* parent)
bool VOTR::buildXml(QDomElement* parent)
{
parent->setTagName("TR");
......@@ -57,7 +66,9 @@ bool Fidelity::Common::VOTR::buildXml(QDomElement* parent)
}
QList<VOTD*>* Fidelity::Common::VOTR::TDList()
QList<QPointer<VOTD> >* VOTR::TDList()
{
return m_TDList;
}
}}
......@@ -24,6 +24,7 @@
#include <QList>
#include <QDomDocument>
#include <QDomElement>
#include <QPointer>
#include "VOTD.h"
......@@ -39,7 +40,7 @@ namespace Fidelity {
* See this URL for the latest definition: http://www.ivoa.net/Documents/latest/VOT.html
* For the time being only XML and binary based output is supported...
*/
class VOTR
class VOTR : public QObject
{
public:
......@@ -66,10 +67,10 @@ public:
* Get the value of m_TDList
* @return the value of m_TDList
*/
QList<VOTD*>* TDList();
QList<QPointer<VOTD> >* TDList();
private:
QList<VOTD*>* m_TDList;
QList<QPointer<VOTD> >* m_TDList;
void initAttributes();
};}}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment