fix(RD): pass copy of IndexedPack to callbacks instead of ref.

This prevents a crash in which the pack list gets updated in a search
request meanwhile a versions / extra info request is being processed.
Previously, this situation would cause the reference in the latter
callbacks to be invalidated by an internal relocation of the pack list.

Signed-off-by: flow <flowlnlnln@gmail.com>
This commit is contained in:
flow
2022-12-20 16:27:15 -03:00
parent 36571c5e22
commit 38e20eb148
2 changed files with 36 additions and 30 deletions

View File

@ -81,7 +81,7 @@ class ResourceAPI {
};
struct VersionSearchArgs {
ModPlatform::IndexedPack& pack;
ModPlatform::IndexedPack pack;
std::optional<std::list<Version> > mcVersions;
std::optional<ModLoaderTypes> loaders;
@ -94,16 +94,16 @@ class ResourceAPI {
}
};
struct VersionSearchCallbacks {
std::function<void(QJsonDocument&, ModPlatform::IndexedPack&)> on_succeed;
std::function<void(QJsonDocument&, ModPlatform::IndexedPack)> on_succeed;
};
struct ProjectInfoArgs {
ModPlatform::IndexedPack& pack;
ModPlatform::IndexedPack pack;
void operator=(ProjectInfoArgs other) { pack = other.pack; }
};
struct ProjectInfoCallbacks {
std::function<void(QJsonDocument&, ModPlatform::IndexedPack&)> on_succeed;
std::function<void(QJsonDocument&, ModPlatform::IndexedPack)> on_succeed;
};
public: