forked from qt-creator/qt-creator
Fix file descriptor and memory leak in autotools plugin
Don't create QFile's on heap when not needed. Don't forget to delete those which have to created on heap. Change-Id: I0e23e0d926febbfd464b3ff5d3e29fd46c16cb44 Reviewed-by: Daniel Teske <daniel.teske@nokia.com> Reviewed-by: Peter Penz <peter.penz19@gmail.com>
This commit is contained in:
@@ -57,6 +57,11 @@ MakefileParser::MakefileParser(const QString &makefile) :
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
MakefileParser::~MakefileParser()
|
||||||
|
{
|
||||||
|
delete m_textStream.device();
|
||||||
|
}
|
||||||
|
|
||||||
bool MakefileParser::parse()
|
bool MakefileParser::parse()
|
||||||
{
|
{
|
||||||
m_mutex.lock();
|
m_mutex.lock();
|
||||||
@@ -261,11 +266,11 @@ void MakefileParser::parseSubDirs()
|
|||||||
+ slash + makefileName;
|
+ slash + makefileName;
|
||||||
|
|
||||||
// Parse sub directory
|
// Parse sub directory
|
||||||
QFile *file = new QFile(subDirMakefile);
|
QFile file(subDirMakefile);
|
||||||
|
|
||||||
// Don't try to parse a file, that might not exist (e. g.
|
// Don't try to parse a file, that might not exist (e. g.
|
||||||
// if SUBDIRS specifies a 'po' directory).
|
// if SUBDIRS specifies a 'po' directory).
|
||||||
if (!file->exists())
|
if (!file.exists())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
MakefileParser parser(subDirMakefile);
|
MakefileParser parser(subDirMakefile);
|
||||||
@@ -422,15 +427,15 @@ void MakefileParser::parseIncludePaths()
|
|||||||
QFileInfo info(m_makefile);
|
QFileInfo info(m_makefile);
|
||||||
const QString dirName = info.absolutePath();
|
const QString dirName = info.absolutePath();
|
||||||
|
|
||||||
QFile *file = new QFile(dirName + QLatin1String("/Makefile"));
|
QFile file(dirName + QLatin1String("/Makefile"));
|
||||||
if (!file->open(QIODevice::ReadOnly | QIODevice::Text))
|
if (!file.open(QIODevice::ReadOnly | QIODevice::Text))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// TODO: The parsing is done very poor. Comments are ignored and targets
|
// TODO: The parsing is done very poor. Comments are ignored and targets
|
||||||
// are ignored too. Whether it is worth to improve this, depends on whether
|
// are ignored too. Whether it is worth to improve this, depends on whether
|
||||||
// we want to parse the generated Makefile at all or whether we want to
|
// we want to parse the generated Makefile at all or whether we want to
|
||||||
// improve the Makefile.am parsing to be aware of variables.
|
// improve the Makefile.am parsing to be aware of variables.
|
||||||
QTextStream textStream(file);
|
QTextStream textStream(&file);
|
||||||
QString line;
|
QString line;
|
||||||
do {
|
do {
|
||||||
line = textStream.readLine();
|
line = textStream.readLine();
|
||||||
|
|||||||
@@ -65,6 +65,8 @@ public:
|
|||||||
*/
|
*/
|
||||||
MakefileParser(const QString &makefile);
|
MakefileParser(const QString &makefile);
|
||||||
|
|
||||||
|
~MakefileParser();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Parses the makefile. Must be invoked at least once, otherwise
|
* Parses the makefile. Must be invoked at least once, otherwise
|
||||||
* the getter methods of MakefileParser will return empty values.
|
* the getter methods of MakefileParser will return empty values.
|
||||||
|
|||||||
Reference in New Issue
Block a user