forked from qt-creator/qt-creator
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:
@@ -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(),
|
||||
|
@@ -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;
|
||||
}
|
||||
}
|
||||
|
@@ -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) {
|
||||
|
Reference in New Issue
Block a user