r18648 by jghali - fix memory leak detected by Visual Leak Detector
scribus-commit
scribus-commit at lists.scribus.net
Sun Dec 15 18:59:38 UTC 2013
Author: jghali
Date: Sun Dec 15 18:59:38 2013
New Revision: 18648
URL: http://scribus.net/websvn/listing.php?repname=Scribus&sc=1&rev=18648
Log:
fix memory leak detected by Visual Leak Detector
Modified:
branches/Version14x/Scribus/scribus/nftrcreader.cpp
branches/Version14x/Scribus/scribus/nfttemplate.cpp
branches/Version14x/Scribus/scribus/nfttemplate.h
Modified: branches/Version14x/Scribus/scribus/nftrcreader.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18648&path=/branches/Version14x/Scribus/scribus/nftrcreader.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/nftrcreader.cpp (original)
+++ branches/Version14x/Scribus/scribus/nftrcreader.cpp Sun Dec 15 18:59:38 2013
@@ -79,7 +79,7 @@
enCat = attrs.value(i);
}
}
- tmpTemplate = new nfttemplate(new QFile(currentFile), category); // create a new template
+ tmpTemplate = new nfttemplate(currentFile, category); // create a new template
tmpTemplate->enCategory = enCat;
}
@@ -138,8 +138,15 @@
{ // new template starts here
inTemplate = false;
if (tmpTemplate != NULL) // If we have a template already created
+ {
if (tmpTemplate->isValid()) // and the template really exists push
templates->push_back(tmpTemplate); // it to the templates vector and start a new one
+ else
+ {
+ delete tmpTemplate;
+ tmpTemplate = 0;
+ }
+ }
}
if (inTemplate) {
if (inName && name == "name")
Modified: branches/Version14x/Scribus/scribus/nfttemplate.cpp
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18648&path=/branches/Version14x/Scribus/scribus/nfttemplate.cpp
==============================================================================
--- branches/Version14x/Scribus/scribus/nfttemplate.cpp (original)
+++ branches/Version14x/Scribus/scribus/nfttemplate.cpp Sun Dec 15 18:59:38 2013
@@ -10,25 +10,25 @@
#include "nfttemplate.h"
#include <QFileInfo>
-nfttemplate::nfttemplate(QFile* tmplXmlFile, const QString &tmplCategory)
+nfttemplate::nfttemplate(QString tmplFilePath, const QString &tmplCategory)
+ : tmplXml(tmplFilePath)
{
- tmplXml = tmplXmlFile;
templateCategory = tmplCategory;
- isWritable = tmplXml->open(QIODevice::WriteOnly | QIODevice::ReadOnly);
- tmplXml->close();
+ isWritable = tmplXml.open(QIODevice::WriteOnly | QIODevice::ReadOnly);
+ tmplXml.close();
isDeleted = false;
}
void nfttemplate::remove()
{
- if (!tmplXml->exists())
+ if (!tmplXml.exists())
return;
QString newTmplXml = "";
QString tmp;
bool collect = false;
- tmplXml->open(QIODevice::ReadOnly);
- QTextStream stream(tmplXml);
+ tmplXml.open(QIODevice::ReadOnly);
+ QTextStream stream(&tmplXml);
stream.setCodec("UTF-8");
QString line = stream.readLine();
while (!line.isNull())
@@ -70,12 +70,12 @@
}
line = stream.readLine();
}
- tmplXml->close();
- tmplXml->open(QIODevice::WriteOnly);
- QTextStream instream(tmplXml);
+ tmplXml.close();
+ tmplXml.open(QIODevice::WriteOnly);
+ QTextStream instream(&tmplXml);
instream.setCodec("UTF-8");
instream << newTmplXml;
- tmplXml->close();
+ tmplXml.close();
}
bool nfttemplate::canWrite()
Modified: branches/Version14x/Scribus/scribus/nfttemplate.h
URL: http://scribus.net/websvn/diff.php?repname=Scribus&rev=18648&path=/branches/Version14x/Scribus/scribus/nfttemplate.h
==============================================================================
--- branches/Version14x/Scribus/scribus/nfttemplate.h (original)
+++ branches/Version14x/Scribus/scribus/nfttemplate.h Sun Dec 15 18:59:38 2013
@@ -16,9 +16,9 @@
class nfttemplate {
public:
- nfttemplate(QFile* tmplXmlFile, const QString &tmplType);
+ nfttemplate(QString tmplFilePath, const QString &tmplType);
~nfttemplate();
- QFile* tmplXml;
+ QFile tmplXml;
QString enCategory;
QString templateCategory;
QString name;
More information about the scribus-commit
mailing list