From a8bc9774f9c1948c603ec23daf47d4c4af67f23f Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Fri, 29 Oct 2021 10:02:17 +0200 Subject: [PATCH] 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 Reviewed-by: Artem Sokolovskii Reviewed-by: Qt CI Bot --- src/plugins/qtsupport/qtoptionspage.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/plugins/qtsupport/qtoptionspage.cpp b/src/plugins/qtsupport/qtoptionspage.cpp index b026363b34a..0a8d55818a4 100644 --- a/src/plugins/qtsupport/qtoptionspage.cpp +++ b/src/plugins/qtsupport/qtoptionspage.cpp @@ -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(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