Changeset 0ce215e in subsurface


Ignore:
Timestamp:
Feb 12, 2015, 12:31:10 PM (3 years ago)
Author:
Dirk Hohndel <dirk@…>
Branches:
Mtest, android_test, dcDownload, foratdotde, gitMerge, gitdebug, gitpictures, ios, master, mergeKirigamiPort, pictimeshift, resolutionIndependence, spinner, testTomaz, testing, v4.5-branch
Children:
7fb35c9
Parents:
a6336d1
git-author:
Dirk Hohndel <dirk@…> (02/12/15 12:28:54)
git-committer:
Dirk Hohndel <dirk@…> (02/12/15 12:31:10)
Message:

Fix dive site creation from v2 git storage

Clearly didn't test that part well enough.

Signed-off-by: Dirk Hohndel <dirk@…>

Files:
3 edited

Legend:

Unmodified
Added
Removed
  • divesite.c

    ra6336d1 r0ce215e  
    6868        return id;
    6969}
     70
     71/* if the uuid is valid, just get the site, otherwise create it first;
     72 * so you can call this with dive->dive_site_uuid and you'll either get the existing
     73 * dive site or it will create a new one - so make sure you assign the uuid back to
     74 * dive->dive_site_uuid when using this function! */
     75struct dive_site *get_or_create_dive_site_by_uuid(uint32_t uuid)
     76{
     77        struct dive_site *ds = get_dive_site_by_uuid(uuid);
     78
     79        if (!ds)
     80                ds = alloc_dive_site();
     81
     82        return ds;
     83}
  • divesite.h

    rcd28e88b r0ce215e  
    6161uint32_t create_dive_site_with_gps(const char *name, degrees_t latitude, degrees_t longitude);
    6262uint32_t dive_site_uuid_by_name(const char *name);
     63struct dive_site *get_or_create_dive_site_by_uuid(uint32_t uuid);
    6364
    6465#ifdef __cplusplus
  • load-git.c

    r0594853 r0ce215e  
    2424
    2525extern degrees_t parse_degrees(char *buf, char **end);
    26 static void parse_dive_gps(char *line, struct membuffer *str, void *_dive)
    27 {
    28         struct dive *dive = _dive;
    29 
    30         dive->latitude = parse_degrees(line, &line);
    31         dive->longitude = parse_degrees(line, &line);
    32 }
    3326
    3427static char *get_utf8(struct membuffer *b)
     
    146139{ return strtoul(line, NULL, 16); }
    147140
     141static void parse_dive_gps(char *line, struct membuffer *str, void *_dive)
     142{
     143        struct dive *dive = _dive;
     144        struct dive_site *ds = get_or_create_dive_site_by_uuid(dive->dive_site_uuid);
     145        dive->dive_site_uuid = ds->uuid;
     146        ds->latitude = parse_degrees(line, &line);
     147        ds->longitude = parse_degrees(line, &line);
     148}
     149
    148150static void parse_dive_location(char *line, struct membuffer *str, void *_dive)
    149 { struct dive *dive = _dive; dive->location = get_utf8(str); }
     151{
     152        struct dive *dive = _dive;
     153        struct dive_site *ds = get_or_create_dive_site_by_uuid(dive->dive_site_uuid);
     154        dive->dive_site_uuid = ds->uuid;
     155        ds->name = get_utf8(str);
     156}
    150157
    151158static void parse_dive_divemaster(char *line, struct membuffer *str, void *_dive)
Note: See TracChangeset for help on using the changeset viewer.