Python: Fix setting current interpreter

There was a vicious cycle started when loading a runconfig pointing
to an interpreter with an id that was not present in the combobox.

Amends 9decfcb151.

Change-Id: I77595795eb825bde55919c8d8dd632f3bf397578
Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
hjk
2021-06-22 18:25:56 +02:00
parent ddf323b136
commit 8e40db5580

View File

@@ -186,7 +186,7 @@ void InterpreterAspect::addToLayout(LayoutBuilder &builder)
m_comboBox = new QComboBox; m_comboBox = new QComboBox;
updateComboBox(); updateComboBox();
connect(m_comboBox, &QComboBox::currentTextChanged, connect(m_comboBox, QOverload<int>::of(&QComboBox::currentIndexChanged),
this, &InterpreterAspect::updateCurrentInterpreter); this, &InterpreterAspect::updateCurrentInterpreter);
auto manageButton = new QPushButton(tr("Manage...")); auto manageButton = new QPushButton(tr("Manage..."));
@@ -199,8 +199,12 @@ void InterpreterAspect::addToLayout(LayoutBuilder &builder)
void InterpreterAspect::updateCurrentInterpreter() void InterpreterAspect::updateCurrentInterpreter()
{ {
m_currentId = currentInterpreter().id; const int index = m_comboBox->currentIndex();
m_comboBox->setToolTip(currentInterpreter().command.toUserOutput()); if (index < 0)
return;
QTC_ASSERT(index < m_interpreters.size(), return);
m_currentId = m_interpreters[index].id;
m_comboBox->setToolTip(m_interpreters[index].command.toUserOutput());
emit changed(); emit changed();
} }