Qt 6 build: Fix Restart button for Link to Qt

Qt 6 ignores the call to close() for the main window, if the options
dialog is still open, so explicitly close it if the user chooses
"Restart Now" from the "Link to Qt" button in the Qt options.

Fixes: QTCREATORBUG-26279
Task-number: QTCREATORBUG-24098
Change-Id: Iaa1c4774dde5e20a7f40b03e0b8768fc9c22dd6c
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
Reviewed-by: Artem Sokolovskii <artem.sokolovskii@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
This commit is contained in:
Eike Ziller
2021-10-29 10:02:17 +02:00
parent 84f6b8891b
commit a8bc9774f9

View File

@@ -177,7 +177,7 @@ public:
QtOptionsPageWidget();
~QtOptionsPageWidget();
static void linkWithQt();
static bool linkWithQt();
private:
void apply() final;
@@ -857,7 +857,16 @@ void QtOptionsPageWidget::setupLinkWithQtButton()
QString tip;
canLinkWithQt(&tip);
m_ui.linkWithQtButton->setToolTip(tip);
connect(m_ui.linkWithQtButton, &QPushButton::clicked, this, &QtOptionsPage::linkWithQt);
connect(m_ui.linkWithQtButton, &QPushButton::clicked, this, [this] {
if (linkWithQt()) {
QWidget *w = window();
// close options dialog
if (QDialog *dialog = qobject_cast<QDialog *>(w))
dialog->accept();
else
window()->close();
}
});
}
void QtOptionsPageWidget::updateCurrentQtName()
@@ -950,7 +959,7 @@ static FilePath defaultQtInstallationPath()
return FileUtils::homePath() / "Qt";
}
void QtOptionsPageWidget::linkWithQt()
bool QtOptionsPageWidget::linkWithQt()
{
const QString title = tr("Choose Qt Installation");
const QString restartText = tr("The change will take effect after restart.");
@@ -1019,8 +1028,9 @@ void QtOptionsPageWidget::linkWithQt()
}
if (askForRestart) {
Core::RestartDialog restartDialog(Core::ICore::dialogParent(), restartText);
restartDialog.exec();
return restartDialog.exec() == QDialog::Accepted;
}
return false;
}
// QtOptionsPage