mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Cleanup: introduce empty_weightsystem constant
To make things more future-proof, introduce an empty_weightsystem constant. Replace explicit aggragate initialization of empty weightsystems by this constant. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
92b833a7d8
commit
dc67876c79
4 changed files with 6 additions and 6 deletions
|
@ -978,9 +978,8 @@ void AddWeight::undo()
|
|||
|
||||
void AddWeight::redo()
|
||||
{
|
||||
weightsystem_t ws { {0}, "" };
|
||||
for (dive *d: dives) {
|
||||
add_cloned_weightsystem(&d->weightsystems, ws);
|
||||
add_cloned_weightsystem(&d->weightsystems, empty_weightsystem);
|
||||
emit diveListNotifier.weightAdded(d, d->weightsystems.nr - 1);
|
||||
}
|
||||
}
|
||||
|
@ -996,7 +995,7 @@ static int find_weightsystem_index(const struct dive *d, weightsystem_t ws)
|
|||
|
||||
RemoveWeight::RemoveWeight(int index, bool currentDiveOnly) :
|
||||
EditDivesBase(currentDiveOnly),
|
||||
ws{ {0}, nullptr }
|
||||
ws(empty_weightsystem)
|
||||
{
|
||||
// Get the old weightsystem, bail if index is invalid
|
||||
if (!current || index < 0 || index >= current->weightsystems.nr) {
|
||||
|
|
|
@ -50,6 +50,8 @@ typedef struct
|
|||
const char *description; /* "integrated", "belt", "ankle" */
|
||||
} weightsystem_t;
|
||||
|
||||
static const weightsystem_t empty_weightsystem = { { 0 }, 0 };
|
||||
|
||||
/* Table of weightsystems. Attention: this stores weightsystems,
|
||||
* *not* pointers * to weightsystems. This has two crucial
|
||||
* consequences:
|
||||
|
|
|
@ -298,8 +298,7 @@ void cylinder_end(struct parser_state *state)
|
|||
|
||||
void ws_start(struct parser_state *state)
|
||||
{
|
||||
weightsystem_t w = { {0}, "" };
|
||||
add_cloned_weightsystem(&state->cur_dive->weightsystems, w);
|
||||
add_cloned_weightsystem(&state->cur_dive->weightsystems, empty_weightsystem);
|
||||
}
|
||||
|
||||
void ws_end(struct parser_state *state)
|
||||
|
|
|
@ -23,7 +23,7 @@ weightsystem_t WeightModel::weightSystemAt(const QModelIndex &index) const
|
|||
int row = index.row();
|
||||
if (row < 0 || row >= d->weightsystems.nr) {
|
||||
qWarning("WeightModel: Accessing invalid weightsystem %d (of %d)", row, d->weightsystems.nr);
|
||||
return { { 0 }, nullptr };
|
||||
return empty_weightsystem;
|
||||
}
|
||||
return d->weightsystems.weightsystems[index.row()];
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue