Core: Remove one functional indirection in copyPostOperation

And replace a FilePath::toString() by .path()

Change-Id: I5e4c36f8fd9cc0494cf76f274f259d97231b2dc0
Reviewed-by: Marcus Tillmanns <marcus.tillmanns@qt.io>
This commit is contained in:
hjk
2024-12-11 12:46:35 +01:00
parent bcdf7d71b6
commit 4c5c33eb80

View File

@@ -452,18 +452,16 @@ private:
QTextEdit *m_terms = nullptr; QTextEdit *m_terms = nullptr;
}; };
static std::function<void(FilePath)> postCopyOperation() static void postCopyOperation(FilePath filePath)
{ {
return [](const FilePath &filePath) {
if (!HostOsInfo::isMacHost()) if (!HostOsInfo::isMacHost())
return; return;
// On macOS, downloaded files get a quarantine flag, remove it, otherwise it is a hassle // 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. // to get it loaded as a plugin in Qt Creator.
Process xattr; Process xattr;
xattr.setCommand({"/usr/bin/xattr", {"-d", "com.apple.quarantine", filePath.absoluteFilePath().toString()}}); xattr.setCommand({"/usr/bin/xattr", {"-d", "com.apple.quarantine", filePath.absoluteFilePath().path()}});
using namespace std::chrono_literals; using namespace std::chrono_literals;
xattr.runBlocking(1s); xattr.runBlocking(1s);
};
} }
static bool copyPluginFile(const FilePath &src, const FilePath &dest) 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())); Tr::tr("Failed to write file \"%1\".").arg(destFile.toUserOutput()));
return false; return false;
} }
postCopyOperation()(destFile); postCopyOperation(destFile);
return true; return true;
} }
@@ -528,7 +526,7 @@ bool executePluginInstallWizard(const FilePath &archive)
return copyPluginFile(data.sourcePath, installPath); return copyPluginFile(data.sourcePath, installPath);
} else { } else {
QString error; QString error;
FileUtils::CopyAskingForOverwrite copy(postCopyOperation()); FileUtils::CopyAskingForOverwrite copy(&postCopyOperation);
if (!FileUtils::copyRecursively(data.extractedPath, installPath, &error, copy())) { if (!FileUtils::copyRecursively(data.extractedPath, installPath, &error, copy())) {
QMessageBox::warning( QMessageBox::warning(
ICore::dialogParent(), Tr::tr("Failed to Copy Plugin Files"), error); ICore::dialogParent(), Tr::tr("Failed to Copy Plugin Files"), error);