core: add constructor/destructor pairs to dive and divecomputer

This allows us to use non-C member variables. Convert a number
of pointers to unique_ptr<>s.

Code in uemis-downloader.cpp had to be refactored, because
it mixed owning and non-owning pointers. Mad.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-05-16 20:11:21 +02:00 committed by bstoeger
parent bfb54aa581
commit cc39f709ce
35 changed files with 289 additions and 308 deletions

View file

@ -1191,7 +1191,7 @@ void QMLManager::commitChanges(QString diveId, QString number, QString date, QSt
report_info("state :'%s'", qPrintable(state));
}
OwningDivePtr d_ptr(alloc_dive()); // Automatically delete dive if we exit early!
auto d_ptr = std::make_unique<dive>(); // Automatically delete dive if we exit early!
dive *d = d_ptr.get();
copy_dive(orig, d);
@ -1728,7 +1728,7 @@ int QMLManager::addDive()
// TODO: Duplicate code with desktop-widgets/mainwindow.cpp
// create a dive an hour from now with a default depth (15m/45ft) and duration (40 minutes)
// as a starting point for the user to edit
struct dive d = { 0 };
struct dive d;
int diveId = d.id = dive_getUniqID();
d.when = QDateTime::currentMSecsSinceEpoch() / 1000L + gettimezoneoffset() + 3600;
d.dc.duration.seconds = 40 * 60;