From 0b33a08af1e088670e561fad316f4dfe7fcd265e Mon Sep 17 00:00:00 2001 From: Marcus Tillmanns Date: Thu, 15 Dec 2022 09:06:02 +0100 Subject: [PATCH] QtSupport: Warn if Link With Qt failed When installing Qt Creator via https://download.qt.io/official_releases/qtcreator/9.0/9.0.0/ qt-creator-opensource-mac-x86_64-9.0.0.dmg The bundle is not writable / no folders can be created in it. therefor "Link With Qt" would silently fail, as the button is not disabled, even if the "canLinkWithQt()" returns false. This also adds a message box to let the user known if the linking failed. Change-Id: Ifbc5d170cf81e898eec3ab8b9f53e1a939652b42 Reviewed-by: Eike Ziller --- src/plugins/qtsupport/qtoptionspage.cpp | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/plugins/qtsupport/qtoptionspage.cpp b/src/plugins/qtsupport/qtoptionspage.cpp index 0ac3ab8fbda..eb37f3b7839 100644 --- a/src/plugins/qtsupport/qtoptionspage.cpp +++ b/src/plugins/qtsupport/qtoptionspage.cpp @@ -872,7 +872,8 @@ static bool canLinkWithQt(QString *toolTip) void QtOptionsPageWidget::setupLinkWithQtButton() { QString tip; - canLinkWithQt(&tip); + const bool canLink = canLinkWithQt(&tip); + m_linkWithQtButton->setEnabled(canLink); m_linkWithQtButton->setToolTip(tip); connect(m_linkWithQtButton, &QPushButton::clicked, this, &QtOptionsPage::linkWithQt); } @@ -1030,8 +1031,17 @@ void QtOptionsPageWidget::linkWithQt() if (dialog.result() == QDialog::Accepted) { const std::optional settingsDir = settingsDirForQtDir(pathInput->rawFilePath().toString()); if (QTC_GUARD(settingsDir)) { - QSettings(settingsFile(Core::ICore::resourcePath().toString()), QSettings::IniFormat) - .setValue(kInstallSettingsKey, *settingsDir); + const QString settingsFilePath = settingsFile(Core::ICore::resourcePath().toString()); + QSettings settings(settingsFilePath, QSettings::IniFormat); + settings.setValue(kInstallSettingsKey, *settingsDir); + settings.sync(); + if (settings.status() == QSettings::AccessError) { + QMessageBox::critical(Core::ICore::dialogParent(), + Tr::tr("Error Linking With Qt"), + Tr::tr("Could not write to \"%1\".").arg(settingsFilePath)); + return; + } + askForRestart = true; } }