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 <eike.ziller@qt.io>
This commit is contained in:
Christian Stenger
2024-05-29 11:59:56 +02:00
parent c14845181d
commit 8a90428251
2 changed files with 21 additions and 7 deletions

View File

@@ -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;

View File

@@ -58,6 +58,7 @@ public slots:
private:
void slotChanged();
void slotActivated();
void onCurrentProjectIndexChanged(int index);
bool validate();
void displayStatusMessage(InfoLabel::InfoType t, const QString &);