From 8e40db558069c17772896d1d1432e83e4f47183d Mon Sep 17 00:00:00 2001 From: hjk Date: Tue, 22 Jun 2021 18:25:56 +0200 Subject: [PATCH] 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 --- src/plugins/python/pythonrunconfiguration.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/plugins/python/pythonrunconfiguration.cpp b/src/plugins/python/pythonrunconfiguration.cpp index fe8ede93b67..4564e8a6865 100644 --- a/src/plugins/python/pythonrunconfiguration.cpp +++ b/src/plugins/python/pythonrunconfiguration.cpp @@ -186,7 +186,7 @@ void InterpreterAspect::addToLayout(LayoutBuilder &builder) m_comboBox = new QComboBox; updateComboBox(); - connect(m_comboBox, &QComboBox::currentTextChanged, + connect(m_comboBox, QOverload::of(&QComboBox::currentIndexChanged), this, &InterpreterAspect::updateCurrentInterpreter); auto manageButton = new QPushButton(tr("Manage...")); @@ -199,8 +199,12 @@ void InterpreterAspect::addToLayout(LayoutBuilder &builder) void InterpreterAspect::updateCurrentInterpreter() { - m_currentId = currentInterpreter().id; - m_comboBox->setToolTip(currentInterpreter().command.toUserOutput()); + const int index = m_comboBox->currentIndex(); + 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(); }