forked from qt-creator/qt-creator
ProjectExplorer: Follow up on too-much-magic in IProjectManager
Use a ProjectManager::registerProjectType<Project>(MimeType) function, removing cryptic IProjectManager object ownership. Change-Id: I212cd25bd4ee757022a8cb0decb4b8de3a112d12 Reviewed-by: Tobias Hunger <tobias.hunger@qt.io>
This commit is contained in:
@@ -26,10 +26,10 @@
|
||||
#include "jsonkitspage.h"
|
||||
#include "jsonwizard.h"
|
||||
|
||||
#include "../iprojectmanager.h"
|
||||
#include "../kit.h"
|
||||
#include "../project.h"
|
||||
#include "../projectexplorer.h"
|
||||
#include "../projectmanager.h"
|
||||
|
||||
#include <coreplugin/featureprovider.h>
|
||||
|
||||
@@ -102,19 +102,16 @@ void JsonKitsPage::setPreferredFeatures(const QVariant &data)
|
||||
|
||||
void JsonKitsPage::setupProjectFiles(const JsonWizard::GeneratorFiles &files)
|
||||
{
|
||||
Project *project = nullptr;
|
||||
|
||||
for (const JsonWizard::GeneratorFile &f : files) {
|
||||
if (f.file.attributes() & GeneratedFile::OpenProjectAttribute) {
|
||||
const QFileInfo fi(f.file.path());
|
||||
const QString path = fi.absoluteFilePath();
|
||||
IProjectManager *manager = IProjectManager::managerForMimeType(Utils::mimeTypeForFile(fi));
|
||||
project = manager ? manager->openProject(path) : nullptr;
|
||||
Project *project = ProjectManager::openProject(Utils::mimeTypeForFile(fi),
|
||||
Utils::FileName::fromString(path));
|
||||
if (project) {
|
||||
if (setupProject(project))
|
||||
project->saveSettings();
|
||||
delete project;
|
||||
project = nullptr;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user