diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2012-12-23 09:06:23 -0800 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2012-12-23 09:06:23 -0800 |
commit | 1bd6f72d3191fc8f68acc9b44099e5705293db59 (patch) | |
tree | 8cfded1822aed7b141a9ec06648538a5aa8b7f8f /gtk-gui.c | |
parent | 06cd494a2f1906de3d56100fe5b883d9a5093329 (diff) | |
download | subsurface-1bd6f72d3191fc8f68acc9b44099e5705293db59.tar.gz |
Different is different from the same (fix silly bug in nickname handling)
Trying to simplify the API for nickname handling I went a bit too far. We
indeed need to different API calls, one that returns an entry in the
nicknamelist for the deviceid that we have. And one that looks if there is
an entry for a different deviceid but the same model that we have.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'gtk-gui.c')
-rw-r--r-- | gtk-gui.c | 18 |
1 files changed, 15 insertions, 3 deletions
@@ -2063,7 +2063,7 @@ const char *get_dc_nickname(uint32_t deviceid) } /* do we have a DIFFERENT divecomputer of the same model? */ -static struct dcnicknamelist *get_dc_nicknameentry(const char *model, int deviceid) +static struct dcnicknamelist *get_different_dc_nicknameentry(const char *model, int deviceid) { struct dcnicknamelist *known = nicknamelist; while (known) { @@ -2075,6 +2075,18 @@ static struct dcnicknamelist *get_dc_nicknameentry(const char *model, int device return NULL; } +/* just fine the entry for this divecomputer */ +static struct dcnicknamelist *get_dc_nicknameentry(int deviceid) +{ + struct dcnicknamelist *known = nicknamelist; + while (known) { + if (known->deviceid == deviceid) + return known; + known = known->next; + } + return NULL; +} + /* no curly braces or commas, please */ static char *cleanedup_nickname(const char *nickname, int len) { @@ -2168,7 +2180,7 @@ void remember_dc(uint32_t deviceid, const char *model, const char *nickname, gbo subsurface_set_conf("dc_nicknames", PREF_STRING, nicknamestring); } else { /* modify existing entry */ - struct dcnicknamelist *nn_entry = get_dc_nicknameentry(model, deviceid); + struct dcnicknamelist *nn_entry = get_dc_nicknameentry(deviceid); if (!nn_entry->model || !*nn_entry->model) nn_entry->model = model; nn_entry->nickname = nickname; @@ -2201,7 +2213,7 @@ void set_dc_nickname(struct dive *dive) fprintf(debugfile, "set_dc_nickname for model %s deviceid %8x\n", dc->model ? : "", dc->deviceid); #endif if (get_dc_nickname(dc->deviceid) == NULL) { - struct dcnicknamelist *nn_entry = get_dc_nicknameentry(dc->model, dc->deviceid); + struct dcnicknamelist *nn_entry = get_different_dc_nicknameentry(dc->model, dc->deviceid); if (!nn_entry) { /* just remember the dive computer without setting a nickname */ if (dc->model) |