forked from qt-creator/qt-creator
PythonEditor: Avoid file duplication
Every add/remove of a file added another entry of the project file. Change-Id: I800adc3540c3fc8b109864e86ab590af5374e30b Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
committed by
Orgad Shaneh
parent
b1c37910f1
commit
a31655cde7
@@ -312,11 +312,13 @@ PythonProject::PythonProject(const FileName &fileName) :
|
|||||||
setDisplayName(fileName.toFileInfo().completeBaseName());
|
setDisplayName(fileName.toFileInfo().completeBaseName());
|
||||||
}
|
}
|
||||||
|
|
||||||
static QStringList readLines(const QString &absoluteFileName)
|
static QStringList readLines(const Utils::FileName &projectFile)
|
||||||
{
|
{
|
||||||
QStringList lines;
|
const QString projectFileName = projectFile.fileName();
|
||||||
|
QSet<QString> visited = { projectFileName };
|
||||||
|
QStringList lines = { projectFileName };
|
||||||
|
|
||||||
QFile file(absoluteFileName);
|
QFile file(projectFile.toString());
|
||||||
if (file.open(QFile::ReadOnly)) {
|
if (file.open(QFile::ReadOnly)) {
|
||||||
QTextStream stream(&file);
|
QTextStream stream(&file);
|
||||||
|
|
||||||
@@ -324,8 +326,10 @@ static QStringList readLines(const QString &absoluteFileName)
|
|||||||
QString line = stream.readLine();
|
QString line = stream.readLine();
|
||||||
if (line.isNull())
|
if (line.isNull())
|
||||||
break;
|
break;
|
||||||
|
if (visited.contains(line))
|
||||||
|
continue;
|
||||||
lines.append(line);
|
lines.append(line);
|
||||||
|
visited.insert(line);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -410,8 +414,7 @@ bool PythonProject::renameFile(const QString &filePath, const QString &newFilePa
|
|||||||
void PythonProject::parseProject()
|
void PythonProject::parseProject()
|
||||||
{
|
{
|
||||||
m_rawListEntries.clear();
|
m_rawListEntries.clear();
|
||||||
m_rawFileList = readLines(projectFilePath().toString());
|
m_rawFileList = readLines(projectFilePath());
|
||||||
m_rawFileList << projectFilePath().fileName();
|
|
||||||
m_files = processEntries(m_rawFileList, &m_rawListEntries);
|
m_files = processEntries(m_rawFileList, &m_rawListEntries);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user