mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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:
parent
bfb54aa581
commit
cc39f709ce
35 changed files with 289 additions and 308 deletions
|
@ -537,7 +537,7 @@ void PlannerDetails::setPlanNotes(QString plan)
|
|||
}
|
||||
|
||||
PlannerWidgets::PlannerWidgets() :
|
||||
planned_dive(alloc_dive()),
|
||||
planned_dive(std::make_unique<dive>()),
|
||||
dcNr(0),
|
||||
plannerWidget(*planned_dive, dcNr, this),
|
||||
plannerSettingsWidget(this)
|
||||
|
|
|
@ -3,8 +3,8 @@
|
|||
#define DIVEPLANNER_H
|
||||
|
||||
#include "core/divemode.h"
|
||||
#include "core/owning_ptrs.h"
|
||||
|
||||
#include <memory>
|
||||
#include <QAbstractTableModel>
|
||||
#include <QAbstractButton>
|
||||
#include <QDateTime>
|
||||
|
@ -91,7 +91,7 @@ public
|
|||
slots:
|
||||
void printDecoPlan();
|
||||
private:
|
||||
OwningDivePtr planned_dive;
|
||||
std::unique_ptr<dive> planned_dive;
|
||||
int dcNr;
|
||||
public:
|
||||
DivePlannerWidget plannerWidget;
|
||||
|
|
|
@ -209,7 +209,6 @@ MainWindow::MainWindow() :
|
|||
#ifdef NO_USERMANUAL
|
||||
ui.menuHelp->removeAction(ui.actionUserManual);
|
||||
#endif
|
||||
memset(©PasteDive, 0, sizeof(copyPasteDive));
|
||||
memset(&what, 0, sizeof(what));
|
||||
|
||||
updateManager = new UpdateManager(this);
|
||||
|
@ -703,7 +702,7 @@ void MainWindow::on_actionAddDive_triggered()
|
|||
|
||||
// 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;
|
||||
d.id = dive_getUniqID();
|
||||
d.when = QDateTime::currentMSecsSinceEpoch() / 1000L + gettimezoneoffset() + 3600;
|
||||
d.dc.duration.seconds = 40 * 60;
|
||||
|
|
|
@ -324,7 +324,7 @@ void ProfileWidget::unsetProfTissues()
|
|||
|
||||
void ProfileWidget::editDive()
|
||||
{
|
||||
editedDive.reset(alloc_dive());
|
||||
editedDive = std::make_unique<dive>();
|
||||
copy_dive(d, editedDive.get()); // Work on a copy of the dive
|
||||
DivePlannerPointsModel::instance()->setPlanMode(DivePlannerPointsModel::EDIT);
|
||||
DivePlannerPointsModel::instance()->loadFromDive(editedDive.get(), dc);
|
||||
|
|
|
@ -48,7 +48,7 @@ private:
|
|||
void editDive();
|
||||
void exitEditMode();
|
||||
void rotateDC(int dir);
|
||||
OwningDivePtr editedDive;
|
||||
std::unique_ptr<dive> editedDive;
|
||||
bool placingCommand;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue