forked from qt-creator/qt-creator
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 <hjk@qt.io>
This commit is contained in:
@@ -312,7 +312,10 @@ public:
|
|||||||
if (!canHandle(parent))
|
if (!canHandle(parent))
|
||||||
return false;
|
return false;
|
||||||
PythonProject *project = static_cast<PythonProject *>(parent->project());
|
PythonProject *project = static_cast<PythonProject *>(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
|
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);
|
Project::RestoreResult res = Project::fromMap(map, errorMessage);
|
||||||
if (res == RestoreResult::Ok) {
|
if (res == RestoreResult::Ok) {
|
||||||
|
refresh();
|
||||||
|
|
||||||
Kit *defaultKit = KitManager::defaultKit();
|
Kit *defaultKit = KitManager::defaultKit();
|
||||||
if (!activeTarget() && defaultKit)
|
if (!activeTarget() && defaultKit)
|
||||||
addTarget(createTarget(defaultKit));
|
addTarget(createTarget(defaultKit));
|
||||||
|
|
||||||
refresh();
|
|
||||||
|
|
||||||
QList<Target *> targetList = targets();
|
|
||||||
foreach (Target *t, targetList) {
|
|
||||||
const QList<RunConfiguration *> 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<PythonRunConfiguration>(t, id));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
|
|||||||
Reference in New Issue
Block a user