mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
core: make clone_* functions return a unique_ptr<>
Don't use plain pointers for owning pointers. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
0ef497c3c9
commit
1e09ec77d7
4 changed files with 22 additions and 31 deletions
|
@ -871,7 +871,7 @@ SplitDiveComputer::SplitDiveComputer(dive *d, int dc_num) :
|
|||
setText(Command::Base::tr("split dive computer"));
|
||||
}
|
||||
|
||||
DiveComputerBase::DiveComputerBase(dive *old_dive, dive *new_dive, int dc_nr_before, int dc_nr_after) :
|
||||
DiveComputerBase::DiveComputerBase(dive *old_dive, std::unique_ptr<dive> new_dive, int dc_nr_before, int dc_nr_after) :
|
||||
dc_nr_before(dc_nr_before),
|
||||
dc_nr_after(dc_nr_after)
|
||||
{
|
||||
|
@ -891,7 +891,7 @@ DiveComputerBase::DiveComputerBase(dive *old_dive, dive *new_dive, int dc_nr_bef
|
|||
new_dive->dive_site = nullptr;
|
||||
|
||||
diveToAdd.dives.resize(1);
|
||||
diveToAdd.dives[0].dive.reset(new_dive);
|
||||
diveToAdd.dives[0].dive = std::move(new_dive);
|
||||
diveToAdd.dives[0].trip = old_dive->divetrip;
|
||||
diveToAdd.dives[0].site = old_dive->dive_site;
|
||||
}
|
||||
|
@ -921,13 +921,13 @@ void DiveComputerBase::undoit()
|
|||
}
|
||||
|
||||
MoveDiveComputerToFront::MoveDiveComputerToFront(dive *d, int dc_num)
|
||||
: DiveComputerBase(d, make_first_dc(d, dc_num), dc_num, 0)
|
||||
: DiveComputerBase(d, clone_make_first_dc(*d, dc_num), dc_num, 0)
|
||||
{
|
||||
setText(Command::Base::tr("move dive computer to front"));
|
||||
}
|
||||
|
||||
DeleteDiveComputer::DeleteDiveComputer(dive *d, int dc_num)
|
||||
: DiveComputerBase(d, clone_delete_divecomputer(d, dc_num), dc_num, std::min((int)number_of_computers(d) - 1, dc_num))
|
||||
: DiveComputerBase(d, clone_delete_divecomputer(*d, dc_num), dc_num, std::min((int)number_of_computers(d) - 1, dc_num))
|
||||
{
|
||||
setText(Command::Base::tr("delete dive computer"));
|
||||
}
|
||||
|
|
|
@ -237,7 +237,7 @@ class DiveComputerBase : public DiveListBase {
|
|||
protected:
|
||||
// old_dive must be a dive known to the core.
|
||||
// new_dive must be new dive whose ownership is taken.
|
||||
DiveComputerBase(dive *old_dive, dive *new_dive, int dc_nr_before, int dc_nr_after);
|
||||
DiveComputerBase(dive *old_dive, std::unique_ptr<dive> new_dive, int dc_nr_before, int dc_nr_after);
|
||||
private:
|
||||
void undoit() override;
|
||||
void redoit() override;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue