Tried to fix codeQL
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
This commit is contained in:
parent
5079ce8d64
commit
bcea19b957
@ -75,7 +75,7 @@ void GetModDependenciesTask::prepareDependecies()
|
|||||||
m_getNetworkDep->start();
|
m_getNetworkDep->start();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GetModDependenciesTask::addDependecies(ModPlatform::IndexedVersion new_version, int level)
|
void GetModDependenciesTask::addDependecies(const ModPlatform::IndexedVersion& new_version, int level)
|
||||||
{
|
{
|
||||||
// some mutex?
|
// some mutex?
|
||||||
m_dependencies.append(new_version);
|
m_dependencies.append(new_version);
|
||||||
@ -85,6 +85,7 @@ void GetModDependenciesTask::addDependecies(ModPlatform::IndexedVersion new_vers
|
|||||||
}
|
}
|
||||||
if (level == 0) {
|
if (level == 0) {
|
||||||
qWarning() << "Dependency cycle exeeded";
|
qWarning() << "Dependency cycle exeeded";
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
for (auto dep : c_dependencies) {
|
for (auto dep : c_dependencies) {
|
||||||
auto task = m_getDependenciesVersionAPI(
|
auto task = m_getDependenciesVersionAPI(
|
||||||
@ -93,20 +94,20 @@ void GetModDependenciesTask::addDependecies(ModPlatform::IndexedVersion new_vers
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
QList<ModPlatform::Dependency> GetModDependenciesTask::getDependenciesForVersions(QList<ModPlatform::IndexedVersion> selected)
|
QList<ModPlatform::Dependency> GetModDependenciesTask::getDependenciesForVersions(const QList<ModPlatform::IndexedVersion>& selected)
|
||||||
{
|
{
|
||||||
auto c_dependencies = QList<ModPlatform::Dependency>();
|
auto c_dependencies = QList<ModPlatform::Dependency>();
|
||||||
for (auto version : selected) {
|
for (auto version : selected) {
|
||||||
for (auto ver_dep : version.dependencies) {
|
for (auto ver_dep : version.dependencies) {
|
||||||
if (ver_dep.type == ModPlatform::DependencyType::REQUIRED) {
|
if (ver_dep.type == ModPlatform::DependencyType::REQUIRED) {
|
||||||
if (auto dep = std::find_if(c_dependencies.begin(), c_dependencies.end(),
|
if (auto dep = std::find_if(c_dependencies.begin(), c_dependencies.end(),
|
||||||
[ver_dep](auto i) { return i.addonId == ver_dep.addonId; });
|
[&ver_dep](auto i) { return i.addonId == ver_dep.addonId; });
|
||||||
dep == c_dependencies.end()) { // check the current dependency list
|
dep == c_dependencies.end()) { // check the current dependency list
|
||||||
if (auto dep =
|
if (auto dep =
|
||||||
std::find_if(selected.begin(), selected.end(), [ver_dep](auto i) { return i.addonId == ver_dep.addonId; });
|
std::find_if(selected.begin(), selected.end(), [&ver_dep](auto i) { return i.addonId == ver_dep.addonId; });
|
||||||
dep == selected.end()) { // check the selected versions
|
dep == selected.end()) { // check the selected versions
|
||||||
if (auto dep =
|
if (auto dep =
|
||||||
std::find_if(m_mods.begin(), m_mods.end(), [ver_dep](auto i) { return i.mod_id() == ver_dep.addonId; });
|
std::find_if(m_mods.begin(), m_mods.end(), [&ver_dep](auto i) { return i.mod_id() == ver_dep.addonId; });
|
||||||
dep == m_mods.end()) { // check the existing mods
|
dep == m_mods.end()) { // check the existing mods
|
||||||
c_dependencies.append(ver_dep);
|
c_dependencies.append(ver_dep);
|
||||||
}
|
}
|
||||||
@ -118,15 +119,15 @@ QList<ModPlatform::Dependency> GetModDependenciesTask::getDependenciesForVersion
|
|||||||
return c_dependencies;
|
return c_dependencies;
|
||||||
};
|
};
|
||||||
|
|
||||||
QList<ModPlatform::Dependency> GetModDependenciesTask::getDependenciesForVersion(ModPlatform::IndexedVersion version)
|
QList<ModPlatform::Dependency> GetModDependenciesTask::getDependenciesForVersion(const ModPlatform::IndexedVersion& version)
|
||||||
{
|
{
|
||||||
auto c_dependencies = QList<ModPlatform::Dependency>();
|
auto c_dependencies = QList<ModPlatform::Dependency>();
|
||||||
for (auto ver_dep : version.dependencies) {
|
for (auto ver_dep : version.dependencies) {
|
||||||
if (ver_dep.type == ModPlatform::DependencyType::REQUIRED) {
|
if (ver_dep.type == ModPlatform::DependencyType::REQUIRED) {
|
||||||
if (auto dep =
|
if (auto dep =
|
||||||
std::find_if(c_dependencies.begin(), c_dependencies.end(), [ver_dep](auto i) { return i.addonId == ver_dep.addonId; });
|
std::find_if(c_dependencies.begin(), c_dependencies.end(), [&ver_dep](auto i) { return i.addonId == ver_dep.addonId; });
|
||||||
dep == c_dependencies.end()) { // check the current dependency list
|
dep == c_dependencies.end()) { // check the current dependency list
|
||||||
if (auto dep = std::find_if(m_mods.begin(), m_mods.end(), [ver_dep](auto i) { return i.mod_id() == ver_dep.addonId; });
|
if (auto dep = std::find_if(m_mods.begin(), m_mods.end(), [&ver_dep](auto i) { return i.mod_id() == ver_dep.addonId; });
|
||||||
dep == m_mods.end()) { // check the existing mods
|
dep == m_mods.end()) { // check the existing mods
|
||||||
c_dependencies.append(ver_dep);
|
c_dependencies.append(ver_dep);
|
||||||
}
|
}
|
||||||
|
@ -34,7 +34,8 @@ class GetModDependenciesTask : public Task {
|
|||||||
using Ptr = shared_qobject_ptr<GetModDependenciesTask>;
|
using Ptr = shared_qobject_ptr<GetModDependenciesTask>;
|
||||||
using LocalModGetAllTaskPtr = shared_qobject_ptr<LocalModGetAllTask>;
|
using LocalModGetAllTaskPtr = shared_qobject_ptr<LocalModGetAllTask>;
|
||||||
|
|
||||||
using NewDependecyVersionAPITask = std::function<Task::Ptr(ModPlatform::Dependency, std::function<void(ModPlatform::IndexedVersion)>)>;
|
using NewDependecyVersionAPITask =
|
||||||
|
std::function<Task::Ptr(const ModPlatform::Dependency&, std::function<void(const ModPlatform::IndexedVersion&)>)>;
|
||||||
|
|
||||||
explicit GetModDependenciesTask(QDir index_dir, QList<ModPlatform::IndexedVersion> selected, NewDependecyVersionAPITask api);
|
explicit GetModDependenciesTask(QDir index_dir, QList<ModPlatform::IndexedVersion> selected, NewDependecyVersionAPITask api);
|
||||||
|
|
||||||
@ -48,9 +49,9 @@ class GetModDependenciesTask : public Task {
|
|||||||
void executeTask() override;
|
void executeTask() override;
|
||||||
|
|
||||||
void prepareDependecies();
|
void prepareDependecies();
|
||||||
void addDependecies(ModPlatform::IndexedVersion, int);
|
void addDependecies(const ModPlatform::IndexedVersion&, int);
|
||||||
QList<ModPlatform::Dependency> getDependenciesForVersions(QList<ModPlatform::IndexedVersion>);
|
QList<ModPlatform::Dependency> getDependenciesForVersions(const QList<ModPlatform::IndexedVersion>&);
|
||||||
QList<ModPlatform::Dependency> getDependenciesForVersion(ModPlatform::IndexedVersion);
|
QList<ModPlatform::Dependency> getDependenciesForVersion(const ModPlatform::IndexedVersion&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QList<ModPlatform::IndexedVersion> m_selected;
|
QList<ModPlatform::IndexedVersion> m_selected;
|
||||||
|
@ -49,7 +49,7 @@ ResourceAPI::VersionSearchArgs ModModel::createVersionsArguments(QModelIndex& en
|
|||||||
return { pack, versions, profile->getModLoaders() };
|
return { pack, versions, profile->getModLoaders() };
|
||||||
}
|
}
|
||||||
|
|
||||||
ResourceAPI::DependencySearchArgs ModModel::createDependecyArguments(ModPlatform::Dependency& dep)
|
ResourceAPI::DependencySearchArgs ModModel::createDependecyArguments(const ModPlatform::Dependency& dep)
|
||||||
{
|
{
|
||||||
auto profile = static_cast<MinecraftInstance const&>(m_base_instance).getPackProfile();
|
auto profile = static_cast<MinecraftInstance const&>(m_base_instance).getPackProfile();
|
||||||
|
|
||||||
|
@ -40,7 +40,7 @@ class ModModel : public ResourceModel {
|
|||||||
ResourceAPI::SearchArgs createSearchArguments() override;
|
ResourceAPI::SearchArgs createSearchArguments() override;
|
||||||
ResourceAPI::VersionSearchArgs createVersionsArguments(QModelIndex&) override;
|
ResourceAPI::VersionSearchArgs createVersionsArguments(QModelIndex&) override;
|
||||||
ResourceAPI::ProjectInfoArgs createInfoArguments(QModelIndex&) override;
|
ResourceAPI::ProjectInfoArgs createInfoArguments(QModelIndex&) override;
|
||||||
ResourceAPI::DependencySearchArgs createDependecyArguments(ModPlatform::Dependency&) override;
|
ResourceAPI::DependencySearchArgs createDependecyArguments(const ModPlatform::Dependency&) override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
auto documentToArray(QJsonDocument& obj) const -> QJsonArray override = 0;
|
auto documentToArray(QJsonDocument& obj) const -> QJsonArray override = 0;
|
||||||
|
@ -452,7 +452,8 @@ void ResourceModel::infoRequestSucceeded(QJsonDocument& doc, ModPlatform::Indexe
|
|||||||
QList<ModPlatform::IndexedVersion> ResourceModel::getDependecies(QDir& dir, QList<ModPlatform::IndexedVersion> selected)
|
QList<ModPlatform::IndexedVersion> ResourceModel::getDependecies(QDir& dir, QList<ModPlatform::IndexedVersion> selected)
|
||||||
{
|
{
|
||||||
auto task = new GetModDependenciesTask(
|
auto task = new GetModDependenciesTask(
|
||||||
dir, selected, [this](ModPlatform::Dependency dependency, std::function<void(ModPlatform::IndexedVersion)> succeeded) -> Task::Ptr {
|
dir, selected,
|
||||||
|
[this](const ModPlatform::Dependency& dependency, std::function<void(const ModPlatform::IndexedVersion&)> succeeded) -> Task::Ptr {
|
||||||
auto args{ createDependecyArguments(dependency) };
|
auto args{ createDependecyArguments(dependency) };
|
||||||
auto callbacks{ createDependecyCallbacks() };
|
auto callbacks{ createDependecyCallbacks() };
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ class ResourceModel : public QAbstractListModel {
|
|||||||
virtual ResourceAPI::ProjectInfoArgs createInfoArguments(QModelIndex&) = 0;
|
virtual ResourceAPI::ProjectInfoArgs createInfoArguments(QModelIndex&) = 0;
|
||||||
virtual ResourceAPI::ProjectInfoCallbacks createInfoCallbacks(QModelIndex&) { return {}; }
|
virtual ResourceAPI::ProjectInfoCallbacks createInfoCallbacks(QModelIndex&) { return {}; }
|
||||||
|
|
||||||
virtual ResourceAPI::DependencySearchArgs createDependecyArguments(ModPlatform::Dependency&) { return {}; };
|
virtual ResourceAPI::DependencySearchArgs createDependecyArguments(const ModPlatform::Dependency&) { return {}; };
|
||||||
virtual ResourceAPI::DependencySearchCallbacks createDependecyCallbacks() { return {}; }
|
virtual ResourceAPI::DependencySearchCallbacks createDependecyCallbacks() { return {}; }
|
||||||
|
|
||||||
/** Requests the API for more entries. */
|
/** Requests the API for more entries. */
|
||||||
|
Loading…
Reference in New Issue
Block a user