Skip to content

Commit

Permalink
fix: [python] Package not updated when switching interpreter
Browse files Browse the repository at this point in the history
  • Loading branch information
Kakueeen committed Jan 6, 2025
1 parent e7eda41 commit e5f8dab
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
11 changes: 5 additions & 6 deletions src/plugins/python/python/option/interpreterwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ void InterpreterWidget::setupUi()
d->interpreterComboBox = new DComboBox();
d->interpreterComboBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Preferred);
QObject::connect(d->interpreterComboBox, &DComboBox::currentTextChanged,
this, &InterpreterWidget::setPackageData);
this, &InterpreterWidget::updatePackageData);

d->selectCustomInterpreter = new DPushButton(tr("Browse"), this);
d->removeCustomInterpreter = new DPushButton(tr("Remove"), this);
Expand Down Expand Up @@ -253,12 +253,11 @@ void InterpreterWidget::updateUi()
}
}

void InterpreterWidget::setPackageData(const QString &text)
void InterpreterWidget::updatePackageData()
{
QString cmd = "pip list";
if (text.indexOf("python3") > -1) {
cmd = "pip3 list";
}
auto param = qvariant_cast<ToolChainData::ToolChainParam>(d->interpreterComboBox->currentData(Qt::UserRole + 1));
QString cmd = param.path + " -m pip list";

QtConcurrent::run(this, &InterpreterWidget::findPackages, cmd);
}

Expand Down
2 changes: 1 addition & 1 deletion src/plugins/python/python/option/interpreterwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public slots:
bool getControlValue(QMap<QString, QVariant> &map);
void setControlValue(const QMap<QString, QVariant> &map);

void setPackageData(const QString &text);
void updatePackageData();
void findPackages(const QString &cmd);

InterpreterWidgetPrivate *const d;
Expand Down

0 comments on commit e5f8dab

Please sign in to comment.