mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
divelog: turn owning-pointers into unique_ptr<>s
Since everything is C++ now, we can use unique_ptr<>s. This makes the code significantly shorter, because we can now use the default move constructor and assignment operators. This has a semantic change when std::move()-ing the divelog: now not the contents of the tables are moved, but the pointers. That is, the moved-from object now has no more tables and must not be used anymore. This made it necessary to replace std::move()s by std::swap()s. In that regard, the old code was in principle broken: it used moved-from objects, which may work but usually doesn't. This commit adds a myriad of .get() function calls where the code expects a C-style pointer. The plan is to remove virtually all of them, when we move free-standing functions into the class it acts on. Or, replace C-style pointers by references where we don't support NULL. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
6e352d5281
commit
d242198c99
22 changed files with 113 additions and 138 deletions
|
@ -991,7 +991,7 @@ static void parse_settings_divecomputerid(char *line, struct git_parser_state *s
|
|||
break;
|
||||
line = parse_keyvalue_entry(parse_divecomputerid_keyvalue, &id, line, state);
|
||||
}
|
||||
create_device_node(state->log->devices, id.model.c_str(), id.serial.c_str(), id.nickname.c_str());
|
||||
create_device_node(state->log->devices.get(), id.model.c_str(), id.serial.c_str(), id.nickname.c_str());
|
||||
}
|
||||
|
||||
struct fingerprint_helper {
|
||||
|
@ -1386,7 +1386,7 @@ static void finish_active_trip(struct git_parser_state *state)
|
|||
|
||||
if (trip) {
|
||||
state->active_trip = NULL;
|
||||
insert_trip(trip, state->log->trips);
|
||||
insert_trip(trip, state->log->trips.get());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1396,7 +1396,7 @@ static void finish_active_dive(struct git_parser_state *state)
|
|||
|
||||
if (dive) {
|
||||
state->active_dive = NULL;
|
||||
record_dive_to_table(dive, state->log->dives);
|
||||
record_dive_to_table(dive, state->log->dives.get());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1787,7 +1787,7 @@ static int parse_filter_preset(struct git_parser_state *state, const git_tree_en
|
|||
|
||||
git_blob_free(blob);
|
||||
|
||||
add_filter_preset_to_table(state->active_filter.get(), state->log->filter_presets);
|
||||
add_filter_preset_to_table(state->active_filter.get(), state->log->filter_presets.get());
|
||||
state->active_filter.reset();
|
||||
|
||||
return 0;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue