Plugins: Fix Plugin installation from archive / file

Previously the spec returned and used was initialized from the temporary
folder after extraction. That folder is deleted though once the install wizard
is done.

We now re-create the spec after copying the files to their final destination.

Change-Id: Ia6b2f3c67a9d89687fece97e59143c00689ae513
Reviewed-by: Eike Ziller <eike.ziller@qt.io>
This commit is contained in:
Marcus Tillmanns
2025-01-21 17:39:40 +01:00
parent 6589db0be7
commit 89702040cd
3 changed files with 37 additions and 2 deletions

View File

@@ -1405,6 +1405,16 @@ static QList<PluginSpec *> createCppPluginsFromArchive(const FilePath &path)
{
QList<PluginSpec *> results;
if (path.isFile()) {
if (QLibrary::isLibrary(path.toFSPathString())) {
expected_str<std::unique_ptr<PluginSpec>> spec = readCppPluginSpec(path);
QTC_CHECK_EXPECTED(spec);
if (spec)
results.push_back(spec->release());
}
return results;
}
// look for plugin
QDirIterator
it(path.path(),

View File

@@ -533,7 +533,15 @@ bool executePluginInstallWizard(const FilePath &archive)
const FilePath installPath = data.pluginSpec->installLocation(
!data.installIntoApplication);
if (hasLibSuffix(data.sourcePath)) {
return copyPluginFile(data.sourcePath, installPath);
if (!copyPluginFile(data.sourcePath, installPath))
return false;
auto specs = pluginSpecsFromArchive(installPath.resolvePath(
data.pluginSpec->filePath().relativePathFrom(data.extractedPath)));
QTC_ASSERT(specs.size() == 1, return false);
data.pluginSpec.reset(specs.front());
} else {
QString error;
FileUtils::CopyAskingForOverwrite copy(ICore::dialogParent(), postCopyOperation());
@@ -542,6 +550,13 @@ bool executePluginInstallWizard(const FilePath &archive)
ICore::dialogParent(), Tr::tr("Failed to Copy Plugin Files"), error);
return false;
}
auto specs = pluginSpecsFromArchive(installPath.resolvePath(
data.pluginSpec->filePath().relativePathFrom(data.extractedPath)));
QTC_ASSERT(specs.size() == 1, return false);
data.pluginSpec.reset(specs.front());
return true;
}
}

View File

@@ -317,7 +317,17 @@ public:
setupLuaExpander(globalMacroExpander());
pluginSpecsFromArchiveFactories().push_back([](const FilePath &path) {
pluginSpecsFromArchiveFactories().push_back([](const FilePath &path) -> QList<PluginSpec *> {
if (path.isFile()) {
if (path.suffix() == "lua") {
Utils::expected_str<PluginSpec *> spec = loadPlugin(path);
QTC_CHECK_EXPECTED(spec);
if (spec)
return {*spec};
}
return {};
}
QList<PluginSpec *> plugins;
auto dirs = path.dirEntries(QDir::Dirs | QDir::NoDotAndDotDot);
for (const auto &dir : dirs) {