fix an issue that a file of unknown type destructs its parent

This commit is contained in:
falsycat 2022-11-19 12:19:54 +09:00
parent 704d8c93ca
commit cef93dabbc

View File

@ -30,11 +30,10 @@ struct serializer<
static Archive& load(Archive& ar, std::unique_ptr<nf7::File>& f) {
std::string name;
ar(name);
auto& type = nf7::File::registry(name);
try {
typename Archive::ChunkGuard guard {ar};
f = type.Deserialize(ar);
f = nf7::File::registry(name).Deserialize(ar);
guard.ValidateEnd();
} catch (...) {
f = nullptr;
@ -44,29 +43,6 @@ struct serializer<
}
};
template <size_t F>
struct serializer<
type_prop::not_a_fundamental,
ser_case::use_internal_serializer,
F,
std::shared_ptr<nf7::File>> {
public:
template <typename Archive>
static Archive& save(Archive& ar, const std::shared_ptr<nf7::File>& f) {
std::unique_ptr<nf7::File> uf(f.get());
ar(uf);
uf.release();
return ar;
}
template <typename Archive>
static Archive& load(Archive& ar, std::shared_ptr<nf7::File>& f) {
std::unique_ptr<nf7::File> uf;
ar(uf);
f = std::move(uf);
return ar;
}
};
template <size_t F>
struct serializer<
type_prop::not_a_fundamental,