From 01cac8299b8978f2cf883d3d17ca933767c15891 Mon Sep 17 00:00:00 2001 From: David Schulz Date: Tue, 15 Aug 2023 10:01:33 +0200 Subject: [PATCH] ProjectExplorer: fix Interpreter::changed emits Only emit changed if the current interpreter changes. This is more in line with the other aspects. This fixes the pyside detection since the changed signal was not emitted in all relevant code paths. Change-Id: I53409b17f260b35914e39de894b48d7bd1ce27c0 Reviewed-by: hjk --- .../runconfigurationaspects.cpp | 22 ++++++++++++++----- .../projectexplorer/runconfigurationaspects.h | 1 + src/plugins/python/pythonrunconfiguration.cpp | 1 - 3 files changed, 17 insertions(+), 7 deletions(-) diff --git a/src/plugins/projectexplorer/runconfigurationaspects.cpp b/src/plugins/projectexplorer/runconfigurationaspects.cpp index 7afe438ea6b..158a102ad1b 100644 --- a/src/plugins/projectexplorer/runconfigurationaspects.cpp +++ b/src/plugins/projectexplorer/runconfigurationaspects.cpp @@ -809,6 +809,8 @@ Interpreter InterpreterAspect::currentInterpreter() const void InterpreterAspect::updateInterpreters(const QList &interpreters) { + if (m_interpreters == interpreters) + return; m_interpreters = interpreters; if (m_comboBox) updateComboBox(); @@ -816,9 +818,11 @@ void InterpreterAspect::updateInterpreters(const QList &interpreter void InterpreterAspect::setDefaultInterpreter(const Interpreter &interpreter) { + if (m_defaultId == interpreter.id) + return; m_defaultId = interpreter.id; if (m_currentId.isEmpty()) - m_currentId = m_defaultId; + setCurrentInterpreter(interpreter); } void InterpreterAspect::setCurrentInterpreter(const Interpreter &interpreter) @@ -829,14 +833,13 @@ void InterpreterAspect::setCurrentInterpreter(const Interpreter &interpreter) return; m_comboBox->setCurrentIndex(index); } else { - m_currentId = interpreter.id; + setCurrentInterpreterId(interpreter.id); } - emit changed(); } void InterpreterAspect::fromMap(const QVariantMap &map) { - m_currentId = map.value(settingsKey(), m_defaultId).toString(); + setCurrentInterpreterId(map.value(settingsKey(), m_defaultId).toString()); } void InterpreterAspect::toMap(QVariantMap &map) const @@ -862,15 +865,22 @@ void InterpreterAspect::addToLayout(LayoutItem &builder) builder.addItems({Tr::tr("Interpreter:"), m_comboBox.data(), manageButton}); } +void InterpreterAspect::setCurrentInterpreterId(const QString &id) +{ + if (id == m_currentId) + return; + m_currentId = id; + emit changed(); +} + void InterpreterAspect::updateCurrentInterpreter() { 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(); + setCurrentInterpreterId(m_interpreters[index].id); } void InterpreterAspect::updateComboBox() diff --git a/src/plugins/projectexplorer/runconfigurationaspects.h b/src/plugins/projectexplorer/runconfigurationaspects.h index 7865aef3775..e9f88d8a011 100644 --- a/src/plugins/projectexplorer/runconfigurationaspects.h +++ b/src/plugins/projectexplorer/runconfigurationaspects.h @@ -245,6 +245,7 @@ public: struct Data : Utils::BaseAspect::Data { Interpreter interpreter; }; private: + void setCurrentInterpreterId(const QString &id); void updateCurrentInterpreter(); void updateComboBox(); QList m_interpreters; diff --git a/src/plugins/python/pythonrunconfiguration.cpp b/src/plugins/python/pythonrunconfiguration.cpp index 4675ef4b1bf..05366abff24 100644 --- a/src/plugins/python/pythonrunconfiguration.cpp +++ b/src/plugins/python/pythonrunconfiguration.cpp @@ -127,7 +127,6 @@ public: { connect(q, &InterpreterAspect::changed, this, &PythonInterpreterAspectPrivate::currentInterpreterChanged); - currentInterpreterChanged(); connect(PySideInstaller::instance(), &PySideInstaller::pySideInstalled, this, [this](const FilePath &python) {