From 1db2a10b73fdd60caff71f30c0679a4c7191c03c Mon Sep 17 00:00:00 2001 From: Rainer Keller Date: Tue, 18 Oct 2022 13:46:49 +0200 Subject: [PATCH] McuSupport: Use signals to propagate path changes from McuPackages Instead of calling the update function manually unconditionally it will be called through a connection. Change-Id: Ibfd3efd0fbaa66c4857d8a15c202472e1f00f576 Reviewed-by: Reviewed-by: Rainer Keller --- src/plugins/mcusupport/mcupackage.cpp | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/plugins/mcusupport/mcupackage.cpp b/src/plugins/mcusupport/mcupackage.cpp index d79fe8c8a8f..63a86442290 100644 --- a/src/plugins/mcusupport/mcupackage.cpp +++ b/src/plugins/mcusupport/mcupackage.cpp @@ -113,15 +113,12 @@ FilePath McuPackage::detectionPath() const void McuPackage::setPath(const FilePath &newPath) { + if (m_path == newPath) + return; + m_path = newPath; updateStatus(); -} - -void McuPackage::updatePath() -{ - m_path = m_fileChooser->rawFilePath(); - m_fileChooser->lineEdit()->button(FancyLineEdit::Right)->setEnabled(m_path != m_defaultPath); - updateStatus(); + emit changed(); } void McuPackage::updateStatus() @@ -274,8 +271,12 @@ QWidget *McuPackage::widget() QObject::connect(this, &McuPackage::statusChanged, widget, [this] { updateStatusUi(); }); QObject::connect(m_fileChooser, &PathChooser::textChanged, this, [this] { - updatePath(); - emit changed(); + setPath(m_fileChooser->rawFilePath()); + }); + + connect(this, &McuPackage::changed, m_fileChooser, [this] { + m_fileChooser->lineEdit()->button(FancyLineEdit::Right)->setEnabled(m_path != m_defaultPath); + m_fileChooser->setFilePath(m_path); }); updateStatus();