mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Cleanup: simplify dive_getUniqID()
dive_getUniqID() is used to create unique dive ids, which are stable during application lifetime. It was passed a dive, checked that the id was not set (if it was that it is know to the application) and set a new id (in contradiction to its name!) if it hadn't any. There were three callers: alloc_dive(): called the function on a zeroed dive struct. fixup_dive(): called the function only if the dive had a 0 id. MainWindow::setupForAddAndPlan(): called the function on a zeroed dive struct. Thus, in all three callers the id is guaranteed to be zero and the whole keeping-track-of-ids logic is moot. Remove the logic, don't pass a dive struct to dive_getUniqID() and move the function to the C-backend. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
4931b5a8e6
commit
2c6b1a99af
4 changed files with 13 additions and 29 deletions
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue