Core: Support disabling Addon by FreeCAD version
If package.xml metadata file exists, it is scanned for FreeCAD version compatibility before the Addon is loaded. If the Addon specifies that it is explicitly not compatible with the current version of FreeCAD, the Addon is not loaded.
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/***************************************************************************
|
||||
* Copyright (c) 2021 Chris Hennes <chennes@pioneerlibrarysystem.org> *
|
||||
* Copyright (c) 2022 FreeCAD Project Association *
|
||||
* *
|
||||
* This file is part of the FreeCAD CAx development system. *
|
||||
* *
|
||||
@@ -456,6 +456,23 @@ bool Metadata::satisfies(const Meta::Dependency& dep)
|
||||
return true;
|
||||
}
|
||||
|
||||
bool App::Metadata::supportsCurrentFreeCAD() const
|
||||
{
|
||||
static auto fcVersion = Meta::Version();
|
||||
if (fcVersion == Meta::Version()) {
|
||||
std::map<std::string, std::string>& config = App::Application::Config();
|
||||
std::stringstream ss;
|
||||
ss << config["BuildVersionMajor"] << "." << config["BuildVersionMinor"] << "." << config["BuildRevision"].empty() ? "0" : config["BuildRevision"];
|
||||
fcVersion = Meta::Version(ss.str());
|
||||
}
|
||||
|
||||
if (_freecadmin != Meta::Version() && _freecadmin > fcVersion)
|
||||
return false;
|
||||
else if (_freecadmax != Meta::Version() && _freecadmax < fcVersion)
|
||||
return false;
|
||||
return true;
|
||||
}
|
||||
|
||||
void Metadata::appendToElement(DOMElement* root) const
|
||||
{
|
||||
appendSimpleXMLNode(root, "name", _name);
|
||||
|
||||
Reference in New Issue
Block a user