diff options
Diffstat (limited to 'core/parse-xml.c')
-rw-r--r-- | core/parse-xml.c | 19 |
1 files changed, 14 insertions, 5 deletions
diff --git a/core/parse-xml.c b/core/parse-xml.c index 2c20ad56c..7b1a62ef9 100644 --- a/core/parse-xml.c +++ b/core/parse-xml.c @@ -1223,7 +1223,10 @@ static void try_to_fill_dive(struct dive *dive, const char *name, char *buf, str { char *hash = NULL; cylinder_t *cyl = dive->cylinders.nr > 0 ? get_cylinder(dive, dive->cylinders.nr - 1) : NULL; + weightsystem_t *ws = dive->weightsystems.nr > 0 ? + &dive->weightsystems.weightsystems[dive->weightsystems.nr - 1] : NULL; pressure_t p; + weight_t w; start_match("dive", name, buf); switch (state->import_source) { @@ -1326,12 +1329,18 @@ static void try_to_fill_dive(struct dive *dive, const char *name, char *buf, str return; if (MATCH_STATE("airpressure.dive", pressure, &dive->surface_pressure)) return; - if (MATCH("description.weightsystem", utf8_string, &dive->weightsystems.weightsystems[dive->weightsystems.nr - 1].description)) - return; - if (MATCH_STATE("weight.weightsystem", weight, &dive->weightsystems.weightsystems[dive->weightsystems.nr - 1].weight)) - return; - if (MATCH_STATE("weight", weight, &dive->weightsystems.weightsystems[dive->weightsystems.nr - 1].weight)) + if (ws) { + if (MATCH("description.weightsystem", utf8_string, &ws->description)) + return; + if (MATCH_STATE("weight.weightsystem", weight, &ws->weight)) + return; + } + if (MATCH_STATE("weight", weight, &w)) { + weightsystem_t ws = empty_weightsystem; + ws.weight = w; + add_cloned_weightsystem(&dive->weightsystems, ws); return; + } if (cyl) { if (MATCH("size.cylinder", cylindersize, &cyl->type.size)) return; |