Create UUID when adding a dive site to core

3f8b4604be introduced a bug: it replaced alloc_dive_site() by the
divesite constructor. However, the latter does not generate a
UUID (for that it would have to access the dive site table).

Thus newly added dive sites had no UUID and could not be saved
properly.

Use the register_site() instead of the put() function when
adding the dive site to the core, so that the UUID is created
if needed.

This needs an audit.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-12-08 21:08:16 +01:00
parent e0d1a54aef
commit a20cf96054

View file

@ -30,7 +30,7 @@ static std::vector<dive_site *> addDiveSites(std::vector<std::unique_ptr<dive_si
}
// Add dive site to core, but remember a non-owning pointer first.
auto add_res = divelog.sites.put(std::move(ds)); // Return ownership to backend.
auto add_res = divelog.sites.register_site(std::move(ds)); // Return ownership to backend.
res.push_back(add_res.ptr);
emit diveListNotifier.diveSiteAdded(res.back(), add_res.idx); // Inform frontend of new dive site.
}