From bdc470a80e0260011e3dfc4d949df8f9e222f73f Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sun, 18 Feb 2018 16:22:34 +0100 Subject: Cleanup: Remove hash field from picture-structure The hash field in the picture-structure was in principle non-operational. It was set on loading, but never actually changed. The authoritative hash comes from the filename->hash map. Therefore, make this explicit by removing the hash field from the picture structure. Instead of filling the picture structure on loading, add the hash directly to the filename->hash map. This is done in the register_hash() function, which does not overwrite old entries. I.e. the local hash has priority over the save-file. This policy might be refined in the future. Signed-off-by: Berthold Stoeger --- core/parse-xml.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'core/parse-xml.c') diff --git a/core/parse-xml.c b/core/parse-xml.c index 2241b330e..8b4830b2c 100644 --- a/core/parse-xml.c +++ b/core/parse-xml.c @@ -1154,6 +1154,7 @@ static void gps_picture_location(char *buffer, struct picture *pic) /* We're in the top-level dive xml. Try to convert whatever value to a dive value */ static void try_to_fill_dive(struct dive *dive, const char *name, char *buf) { + char *hash; start_match("dive", name, buf); switch (import_source) { @@ -1197,8 +1198,11 @@ static void try_to_fill_dive(struct dive *dive, const char *name, char *buf) return; if (MATCH("gps.picture", gps_picture_location, cur_picture)) return; - if (MATCH("hash.picture", utf8_string, &cur_picture->hash)) + if (MATCH("hash.picture", utf8_string, &hash)) { + register_hash(cur_picture->filename, hash); + free(hash); return; + } if (MATCH("cylinderstartpressure", pressure, &dive->cylinder[0].start)) return; if (MATCH("cylinderendpressure", pressure, &dive->cylinder[0].end)) -- cgit v1.2.3-70-g09d2