aboutsummaryrefslogtreecommitdiffstats
path: root/src/plugins/python/pythonsettings.cpp
diff options
context:
space:
mode:
authorChristian Stenger <christian.stenger@qt.io>2024-09-12 15:13:42 +0200
committerChristian Stenger <christian.stenger@qt.io>2024-09-18 05:39:25 +0000
commit26372392d8986f90b95c203032d2b2ec43877a41 (patch)
tree7cd817e73c8bc804ac80cf44c229eda26cd7973a /src/plugins/python/pythonsettings.cpp
parent151f9e7d04433263933ff8e1ceaf59ff535a8e99 (diff)
Python: Allow kit creation for virtual environments
This had been intentionally disabled before, but we still should permit to explicitly create a kit for a registered virtual environment if the user requests so. Change-Id: I677c0c5093bedd1a9f50e73da173db09195e128e Reviewed-by: David Schulz <david.schulz@qt.io>
Diffstat (limited to 'src/plugins/python/pythonsettings.cpp')
-rw-r--r--src/plugins/python/pythonsettings.cpp19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/plugins/python/pythonsettings.cpp b/src/plugins/python/pythonsettings.cpp
index ba74146053e..b53977c3966 100644
--- a/src/plugins/python/pythonsettings.cpp
+++ b/src/plugins/python/pythonsettings.cpp
@@ -580,7 +580,7 @@ void InterpreterOptionsWidget::generateKit()
{
const QModelIndex &index = m_view->currentIndex();
if (index.isValid())
- PythonSettings::addKitsForInterpreter(m_model.itemAt(index.row())->itemData);
+ PythonSettings::addKitsForInterpreter(m_model.itemAt(index.row())->itemData, true);
m_generateKitButton->setEnabled(false);
}
@@ -808,19 +808,20 @@ static void setRelevantAspectsToKit(Kit *k)
k->setRelevantAspects(relevantAspects);
}
-void PythonSettings::addKitsForInterpreter(const Interpreter &interpreter)
+void PythonSettings::addKitsForInterpreter(const Interpreter &interpreter, bool force)
{
if (!KitManager::isLoaded()) {
- connect(KitManager::instance(), &KitManager::kitsLoaded, settingsInstance, [interpreter]() {
- addKitsForInterpreter(interpreter);
- });
+ connect(KitManager::instance(),
+ &KitManager::kitsLoaded,
+ settingsInstance,
+ [interpreter, force]() { addKitsForInterpreter(interpreter, force); });
return;
}
const Id kitId = Id::fromString(interpreter.id);
if (Kit *k = KitManager::kit(kitId)) {
setRelevantAspectsToKit(k);
- } else if (!isVenvPython(interpreter.command)) {
+ } else if (force || !isVenvPython(interpreter.command)) {
KitManager::registerKit(
[interpreter](Kit *k) {
k->setAutoDetected(true);
@@ -856,7 +857,7 @@ void PythonSettings::setInterpreter(const QList<Interpreter> &interpreters, cons
QList<Interpreter> toRemove = settingsInstance->m_interpreters;
for (const Interpreter &interpreter : interpreters) {
if (!Utils::eraseOne(toRemove, Utils::equal(&Interpreter::id, interpreter.id)))
- addKitsForInterpreter(interpreter);
+ addKitsForInterpreter(interpreter, false);
}
for (const Interpreter &interpreter : toRemove)
removeKitsForInterpreter(interpreter);
@@ -901,7 +902,7 @@ void PythonSettings::addInterpreter(const Interpreter &interpreter, bool isDefau
if (isDefault)
settingsInstance->m_defaultInterpreterId = interpreter.id;
saveSettings();
- addKitsForInterpreter(interpreter);
+ addKitsForInterpreter(interpreter, false);
}
Interpreter PythonSettings::addInterpreter(const FilePath &interpreterPath,
@@ -1071,7 +1072,7 @@ void PythonSettings::initFromSettings(QtcSettings *settings)
if (cmd.needsDevice() || cmd.parentDir().pathAppended("activate").exists())
continue;
}
- addKitsForInterpreter(interpreter);
+ addKitsForInterpreter(interpreter, false);
}
} else {
fixupPythonKits();