From 0a931c56a4688677481afaa7011e006f468ab8f4 Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Wed, 18 Oct 2017 12:58:59 +0200 Subject: PythonEditor: Avoid creation of useless empty run config Opening a python project created an empty 'Custom RunConfiguration' the first time it had been opened. Avoid this by re-ordering and simplifying the processing of the project and its respective settings. Change-Id: I0c0f71e0dab6f03df46e5ddbdc7e1dbf73e8bef8 Reviewed-by: hjk --- src/plugins/pythoneditor/pythoneditorplugin.cpp | 29 +++++-------------------- 1 file changed, 6 insertions(+), 23 deletions(-) (limited to 'src/plugins/pythoneditor') diff --git a/src/plugins/pythoneditor/pythoneditorplugin.cpp b/src/plugins/pythoneditor/pythoneditorplugin.cpp index 29f55ad94d..6564f6ffc4 100644 --- a/src/plugins/pythoneditor/pythoneditorplugin.cpp +++ b/src/plugins/pythoneditor/pythoneditorplugin.cpp @@ -312,7 +312,10 @@ public: if (!canHandle(parent)) return false; PythonProject *project = static_cast(parent->project()); - return project->files(ProjectExplorer::Project::AllFiles).contains(scriptFromId(id)); + const QString script = scriptFromId(id); + if (script.endsWith(".pyqtc")) + return false; + return project->files(ProjectExplorer::Project::AllFiles).contains(script); } bool canRestore(Target *parent, const QVariantMap &map) const override @@ -560,31 +563,11 @@ Project::RestoreResult PythonProject::fromMap(const QVariantMap &map, QString *e { Project::RestoreResult res = Project::fromMap(map, errorMessage); if (res == RestoreResult::Ok) { + refresh(); + Kit *defaultKit = KitManager::defaultKit(); if (!activeTarget() && defaultKit) addTarget(createTarget(defaultKit)); - - refresh(); - - QList targetList = targets(); - foreach (Target *t, targetList) { - const QList runConfigs = t->runConfigurations(); - foreach (const QString &file, m_files) { - // skip the 'project' file - if (file.endsWith(".pyqtc")) - continue; - const Id id = idFromScript(file); - bool alreadyPresent = false; - foreach (RunConfiguration *runCfg, runConfigs) { - if (runCfg->id() == id) { - alreadyPresent = true; - break; - } - } - if (!alreadyPresent) - t->addRunConfiguration(IRunConfigurationFactory::createHelper(t, id)); - } - } } return res; -- cgit v1.2.1