From 8a904282516efab8a70b294021ee32ed2ecd2e91 Mon Sep 17 00:00:00 2001 From: Christian Stenger Date: Wed, 29 May 2024 11:59:56 +0200 Subject: [PATCH] Wizards: Fix updating path chooser Do not update the path chooser from the same slot where the path chooser gets validated or we end up inside a soft assert of the path chooser's (locked) guard. Currently no harm as the project chooser is not used actively and no page is declared as a sub project on this page yet. Change-Id: I641bb7da55de5919c772b1fa29693f4fa75d4a7c Reviewed-by: Eike Ziller --- src/libs/utils/projectintropage.cpp | 27 ++++++++++++++++++++------- src/libs/utils/projectintropage.h | 1 + 2 files changed, 21 insertions(+), 7 deletions(-) diff --git a/src/libs/utils/projectintropage.cpp b/src/libs/utils/projectintropage.cpp index 7a42b7280c1..2c8b43b66a4 100644 --- a/src/libs/utils/projectintropage.cpp +++ b/src/libs/utils/projectintropage.cpp @@ -136,7 +136,7 @@ ProjectIntroPage::ProjectIntroPage(QWidget *parent) : connect(d->m_nameLineEdit, &FancyLineEdit::validReturnPressed, this, &ProjectIntroPage::slotActivated); connect(d->m_projectComboBox, &QComboBox::currentIndexChanged, - this, &ProjectIntroPage::slotChanged); + this, &ProjectIntroPage::onCurrentProjectIndexChanged); setProperty(SHORT_TITLE_PROPERTY, Tr::tr("Location")); registerFieldWithName(QLatin1String("Path"), d->m_pathChooser, "path", SIGNAL(textChanged(QString))); @@ -193,12 +193,6 @@ bool ProjectIntroPage::isComplete() const bool ProjectIntroPage::validate() { - if (d->m_forceSubProject) { - int index = d->m_projectComboBox->currentIndex(); - if (index == 0) - return false; - d->m_pathChooser->setFilePath(d->m_projectDirectories.at(index)); - } // Validate and display status if (!d->m_pathChooser->isValid()) { if (const QString msg = d->m_pathChooser->errorMessage(); !msg.isEmpty()) @@ -261,6 +255,25 @@ void ProjectIntroPage::slotActivated() emit activated(); } +void ProjectIntroPage::onCurrentProjectIndexChanged(int index) +{ + if (d->m_forceSubProject) { + const int available = d->m_projectDirectories.size(); + if (available == 0) + return; + QTC_ASSERT(index < available, return); + if (index < 0) + return; + + const FilePath current = d->m_projectDirectories.at(index); + const FilePath visible = d->m_pathChooser->filePath(); + if (visible != current && !visible.isChildOf(current)) + d->m_pathChooser->setFilePath(current); + + fieldsUpdated(); + } +} + bool ProjectIntroPage::forceSubProject() const { return d->m_forceSubProject; diff --git a/src/libs/utils/projectintropage.h b/src/libs/utils/projectintropage.h index 48b2f6b036c..562b5b06e42 100644 --- a/src/libs/utils/projectintropage.h +++ b/src/libs/utils/projectintropage.h @@ -58,6 +58,7 @@ public slots: private: void slotChanged(); void slotActivated(); + void onCurrentProjectIndexChanged(int index); bool validate(); void displayStatusMessage(InfoLabel::InfoType t, const QString &);