mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
core: default initialize units-type objects to 0
Makes the code much nicer to read. Default initialize cylinder_t to the empty cylinder. This produces lots of warnings, because most structure are now not PODs anymore and shouldn't be erased using memset(). These memset()s will be removed one-by-one and replaced by proper constructors. The whole ordeal made it necessary to add a constructor to struct event. To simplify things the whole optimization of the variable-size event names was removed. In upcoming commits this will be replaced by std::string anyway. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
b82fdd1d20
commit
408b31b6ce
34 changed files with 128 additions and 148 deletions
|
@ -1115,8 +1115,7 @@ void EditWeight::undo()
|
|||
|
||||
// ***** Add Cylinder *****
|
||||
AddCylinder::AddCylinder(bool currentDiveOnly) :
|
||||
EditDivesBase(currentDiveOnly),
|
||||
cyl(empty_cylinder)
|
||||
EditDivesBase(currentDiveOnly)
|
||||
{
|
||||
if (dives.empty())
|
||||
return;
|
||||
|
|
|
@ -186,7 +186,7 @@ bool AddGasSwitch::workToBeDone()
|
|||
|
||||
void AddGasSwitch::redoit()
|
||||
{
|
||||
std::vector<OwningEventPtr> newEventsToAdd;
|
||||
std::vector<std::unique_ptr<event>> newEventsToAdd;
|
||||
std::vector<event *> newEventsToRemove;
|
||||
newEventsToAdd.reserve(eventsToRemove.size());
|
||||
newEventsToRemove.reserve(eventsToAdd.size());
|
||||
|
@ -196,7 +196,7 @@ void AddGasSwitch::redoit()
|
|||
remove_event_from_dc(dc, ev);
|
||||
newEventsToAdd.emplace_back(ev); // take ownership of event
|
||||
}
|
||||
for (OwningEventPtr &ev: eventsToAdd) {
|
||||
for (auto &ev: eventsToAdd) {
|
||||
newEventsToRemove.push_back(ev.get());
|
||||
add_event_to_dc(dc, ev.release()); // return ownership to backend
|
||||
}
|
||||
|
|
|
@ -42,8 +42,8 @@ protected:
|
|||
private:
|
||||
bool workToBeDone() override;
|
||||
|
||||
OwningEventPtr eventToAdd; // for redo
|
||||
event *eventToRemove; // for undo
|
||||
std::unique_ptr<event> eventToAdd; // for redo
|
||||
event *eventToRemove; // for undo
|
||||
};
|
||||
|
||||
class AddEventBookmark : public AddEventBase {
|
||||
|
@ -73,8 +73,8 @@ private:
|
|||
void undoit() override;
|
||||
void redoit() override;
|
||||
|
||||
OwningEventPtr eventToAdd; // for undo and redo
|
||||
event *eventToRemove; // for undo and redo
|
||||
std::unique_ptr<event> eventToAdd; // for undo and redo
|
||||
event *eventToRemove; // for undo and redo
|
||||
};
|
||||
|
||||
class RemoveEvent : public EventBase {
|
||||
|
@ -86,9 +86,9 @@ private:
|
|||
void redoit() override;
|
||||
void post() const; // Called to fix up dives should a gas-change have happened.
|
||||
|
||||
OwningEventPtr eventToAdd; // for undo
|
||||
event *eventToRemove; // for redo
|
||||
int cylinder; // affected cylinder (if removing gas switch). <0: not a gas switch.
|
||||
std::unique_ptr<event> eventToAdd; // for undo
|
||||
event *eventToRemove; // for redo
|
||||
int cylinder; // affected cylinder (if removing gas switch). <0: not a gas switch.
|
||||
};
|
||||
|
||||
class AddGasSwitch : public EventBase {
|
||||
|
@ -100,7 +100,7 @@ private:
|
|||
void redoit() override;
|
||||
|
||||
std::vector<int> cylinders; // cylinders that are modified
|
||||
std::vector<OwningEventPtr> eventsToAdd;
|
||||
std::vector<std::unique_ptr<event>> eventsToAdd;
|
||||
std::vector<event *> eventsToRemove;
|
||||
};
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue