summaryrefslogtreecommitdiff
path: root/src/plugins/coreplugin/plugininstallwizard.cpp
diff options
context:
space:
mode:
authorEike Ziller <eike.ziller@qt.io>2021-02-12 16:06:24 +0100
committerEike Ziller <eike.ziller@qt.io>2021-02-15 14:10:17 +0000
commit27300c66fe63ee36bf46450c2960770ecc25980e (patch)
tree5873ff695323f5ed938b715edbb0e3b10d8a6e91 /src/plugins/coreplugin/plugininstallwizard.cpp
parent5168af31448635a96c9c05b19df0b9f2f62d388a (diff)
downloadqt-creator-27300c66fe63ee36bf46450c2960770ecc25980e.tar.gz
Improve plugin install wizard on macOS
Downloaded files get a quarantine flag on macOS, which prevents loading them as a plugin in Qt Creator. Remove the quarantine flag when copying the plugin. Change-Id: I3edef3ddfbab299be750e728a9fac0536634ba1b Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Diffstat (limited to 'src/plugins/coreplugin/plugininstallwizard.cpp')
-rw-r--r--src/plugins/coreplugin/plugininstallwizard.cpp19
1 files changed, 17 insertions, 2 deletions
diff --git a/src/plugins/coreplugin/plugininstallwizard.cpp b/src/plugins/coreplugin/plugininstallwizard.cpp
index c9ce41b348..ee2f4bd1f6 100644
--- a/src/plugins/coreplugin/plugininstallwizard.cpp
+++ b/src/plugins/coreplugin/plugininstallwizard.cpp
@@ -37,6 +37,7 @@
#include <utils/pathchooser.h>
#include <utils/qtcassert.h>
#include <utils/runextensions.h>
+#include <utils/synchronousprocess.h>
#include <utils/temporarydirectory.h>
#include <utils/wizard.h>
#include <utils/wizardpage.h>
@@ -418,6 +419,19 @@ private:
Data *m_data = nullptr;
};
+static std::function<void(QFileInfo)> postCopyOperation()
+{
+ return [](const QFileInfo &fi) {
+ if (!HostOsInfo::isMacHost())
+ return;
+ // On macOS, downloaded files get a quarantine flag, remove it, otherwise it is a hassle
+ // to get it loaded as a plugin in Qt Creator.
+ SynchronousProcess xattr;
+ xattr.setTimeoutS(1);
+ xattr.runBlocking({"/usr/bin/xattr", {"-d", "com.apple.quarantine", fi.absoluteFilePath()}});
+ };
+}
+
static bool copyPluginFile(const FilePath &src, const FilePath &dest)
{
const FilePath destFile = dest.pathAppended(src.fileName());
@@ -444,6 +458,7 @@ static bool copyPluginFile(const FilePath &src, const FilePath &dest)
.arg(destFile.toUserOutput()));
return false;
}
+ postCopyOperation()(destFile.toFileInfo());
return true;
}
@@ -475,8 +490,8 @@ bool PluginInstallWizard::exec()
if (!FileUtils::copyRecursively(data.extractedPath,
installPath,
&error,
- FileUtils::CopyAskingForOverwrite(
- ICore::dialogParent()))) {
+ FileUtils::CopyAskingForOverwrite(ICore::dialogParent(),
+ postCopyOperation()))) {
QMessageBox::warning(ICore::dialogParent(),
PluginInstallWizard::tr("Failed to Copy Plugin Files"),
error);