mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Update the serial number and deviceid in sync when loading
When we save the divecomputer data, we never actually save the serial value as a field. We used to rely on saving the very dodgy 'deviceid', and then look up the serial number from there. And that never really worked reliably, but we didn't really notice, because we never really _used_ the serial number anywhere. The only place the serial number is actually reliably displayed is in the "Extra data" tab, which contains the key value pairs, and that's where the original dive download code got the serial number from. So just parse that at load time too, the same way we parsed it at dive download time. In fact, do the firmware version the same way, and remove the code from the downloader, since it too can rely on 'add_extra_data()' just picking up the information directly. Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
35adf2d729
commit
d141bbf38f
2 changed files with 11 additions and 24 deletions
|
@ -474,16 +474,22 @@ void remove_event_from_dc(struct divecomputer *dc, struct event *event)
|
|||
void add_extra_data(struct divecomputer *dc, const char *key, const char *value)
|
||||
{
|
||||
struct extra_data **ed = &dc->extra_data;
|
||||
const char *newval = strdup(value);
|
||||
|
||||
if (!strcasecmp(key, "Serial"))
|
||||
if (!strcasecmp(key, "Serial")) {
|
||||
dc->deviceid = calculate_string_hash(value);
|
||||
dc->serial = newval;
|
||||
}
|
||||
if (!strcmp(key, "FW Version")) {
|
||||
dc->fw_version = newval;
|
||||
}
|
||||
|
||||
while (*ed)
|
||||
ed = &(*ed)->next;
|
||||
*ed = malloc(sizeof(struct extra_data));
|
||||
if (*ed) {
|
||||
(*ed)->key = strdup(key);
|
||||
(*ed)->value = strdup(value);
|
||||
(*ed)->value = newval;
|
||||
(*ed)->next = NULL;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue