Tasklist: reload tasks when open task file again

Fixes: QTCREATORBUG-25108
Change-Id: Ib1096a098ab2b06ab384b31715ca32a0fd710781
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
David Schulz
2021-01-14 12:53:55 +01:00
parent 5d7f2d7444
commit 89f2c274c0

View File

@@ -35,6 +35,7 @@
#include <projectexplorer/session.h> #include <projectexplorer/session.h>
#include <projectexplorer/task.h> #include <projectexplorer/task.h>
#include <projectexplorer/taskhub.h> #include <projectexplorer/taskhub.h>
#include <utils/algorithm.h>
#include <QDir> #include <QDir>
#include <QMessageBox> #include <QMessageBox>
@@ -165,25 +166,24 @@ static bool parseTaskFile(QString *errorString, const FilePath &name)
IDocument *TaskListPlugin::openTasks(const FilePath &fileName) IDocument *TaskListPlugin::openTasks(const FilePath &fileName)
{ {
foreach (TaskFile *doc, d->m_openFiles) { TaskFile *file = Utils::findOrDefault(d->m_openFiles, Utils::equal(&TaskFile::filePath, fileName));
if (doc->filePath() == fileName)
return doc;
}
auto file = new TaskFile(this);
QString errorString; QString errorString;
if (!file->load(&errorString, fileName)) { if (file) {
QMessageBox::critical(ICore::dialogParent(), tr("File Error"), errorString); file->load(&errorString, fileName);
delete file; } else {
return nullptr; file = new TaskFile(this);
if (!file->load(&errorString, fileName)) {
QMessageBox::critical(ICore::dialogParent(), tr("File Error"), errorString);
delete file;
return nullptr;
}
d->m_openFiles.append(file);
// Register with filemanager:
DocumentManager::addDocument(file);
} }
d->m_openFiles.append(file);
// Register with filemanager:
DocumentManager::addDocument(file);
return file; return file;
} }