diff options
Diffstat (limited to 'core')
-rw-r--r-- | core/dive.c | 13 | ||||
-rw-r--r-- | core/dive.h | 2 | ||||
-rw-r--r-- | core/qthelper.cpp | 25 |
3 files changed, 12 insertions, 28 deletions
diff --git a/core/dive.c b/core/dive.c index 78263dfab..c977183a3 100644 --- a/core/dive.c +++ b/core/dive.c @@ -454,6 +454,15 @@ double get_weight_units(unsigned int grams, int *frac, const char **units) return value; } +// we need this to be uniq. oh, and it has no meaning whatsoever +// - that's why we have the silly initial number and increment by 3 :-) +int dive_getUniqID() +{ + static int maxId = 83529; + maxId += 3; + return maxId; +} + struct dive *alloc_dive(void) { struct dive *dive; @@ -462,7 +471,7 @@ struct dive *alloc_dive(void) if (!dive) exit(1); memset(dive, 0, sizeof(*dive)); - dive->id = dive_getUniqID(dive); + dive->id = dive_getUniqID(); return dive; } @@ -1784,7 +1793,7 @@ struct dive *fixup_dive(struct dive *dive) /* we should always have a uniq ID as that gets assigned during alloc_dive(), * but we want to make sure... */ if (!dive->id) - dive->id = dive_getUniqID(dive); + dive->id = dive_getUniqID(); return dive; } diff --git a/core/dive.h b/core/dive.h index 1e694e271..8458a3ae3 100644 --- a/core/dive.h +++ b/core/dive.h @@ -757,7 +757,7 @@ extern int legacy_format_o2pressures(struct dive *dive, struct divecomputer *dc) extern void sort_table(struct dive_table *table); extern struct dive *fixup_dive(struct dive *dive); extern void fixup_dc_duration(struct divecomputer *dc); -extern int dive_getUniqID(struct dive *d); +extern int dive_getUniqID(); extern unsigned int dc_airtemp(struct divecomputer *dc); extern unsigned int dc_watertemp(struct divecomputer *dc); extern int split_dive(struct dive *); diff --git a/core/qthelper.cpp b/core/qthelper.cpp index 6ee0cb6ae..fd9a8212b 100644 --- a/core/qthelper.cpp +++ b/core/qthelper.cpp @@ -288,31 +288,6 @@ QList<int> getDivesInTrip(dive_trip_t *trip) return ret; } -// we need this to be uniq, but also make sure -// it doesn't change during the life time of a Subsurface session -// oh, and it has no meaning whatsoever - that's why we have the -// silly initial number and increment by 3 :-) -int dive_getUniqID(struct dive *d) -{ - static QSet<int> ids; - static int maxId = 83529; - - int id = d->id; - if (id) { - if (!ids.contains(id)) { - qDebug() << "WTF - only I am allowed to create IDs"; - ids.insert(id); - } - return id; - } - maxId += 3; - id = maxId; - Q_ASSERT(!ids.contains(id)); - ids.insert(id); - return id; -} - - static xmlDocPtr get_stylesheet_doc(const xmlChar *uri, xmlDictPtr, int, void *, xsltLoadType) { QFile f(QLatin1String(":/xslt/") + (const char *)uri); |