From 4c5c33eb800fb3936e8f679604e89ae47860ee78 Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 11 Dec 2024 12:46:35 +0100 Subject: [PATCH] Core: Remove one functional indirection in copyPostOperation And replace a FilePath::toString() by .path() Change-Id: I5e4c36f8fd9cc0494cf76f274f259d97231b2dc0 Reviewed-by: Marcus Tillmanns --- .../coreplugin/plugininstallwizard.cpp | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/plugins/coreplugin/plugininstallwizard.cpp b/src/plugins/coreplugin/plugininstallwizard.cpp index a227a549ff3..a02bee4d4e9 100644 --- a/src/plugins/coreplugin/plugininstallwizard.cpp +++ b/src/plugins/coreplugin/plugininstallwizard.cpp @@ -452,18 +452,16 @@ private: QTextEdit *m_terms = nullptr; }; -static std::function postCopyOperation() +static void postCopyOperation(FilePath filePath) { - return [](const FilePath &filePath) { - 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. - Process xattr; - xattr.setCommand({"/usr/bin/xattr", {"-d", "com.apple.quarantine", filePath.absoluteFilePath().toString()}}); - using namespace std::chrono_literals; - xattr.runBlocking(1s); - }; + 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. + Process xattr; + xattr.setCommand({"/usr/bin/xattr", {"-d", "com.apple.quarantine", filePath.absoluteFilePath().path()}}); + using namespace std::chrono_literals; + xattr.runBlocking(1s); } static bool copyPluginFile(const FilePath &src, const FilePath &dest) @@ -490,7 +488,7 @@ static bool copyPluginFile(const FilePath &src, const FilePath &dest) Tr::tr("Failed to write file \"%1\".").arg(destFile.toUserOutput())); return false; } - postCopyOperation()(destFile); + postCopyOperation(destFile); return true; } @@ -528,7 +526,7 @@ bool executePluginInstallWizard(const FilePath &archive) return copyPluginFile(data.sourcePath, installPath); } else { QString error; - FileUtils::CopyAskingForOverwrite copy(postCopyOperation()); + FileUtils::CopyAskingForOverwrite copy(&postCopyOperation); if (!FileUtils::copyRecursively(data.extractedPath, installPath, &error, copy())) { QMessageBox::warning( ICore::dialogParent(), Tr::tr("Failed to Copy Plugin Files"), error);