mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Make created dive site uuid deterministic
Having random uuids seemed like a good idea, but there are several situations where they really cause problems. One is merging dive file imports from V2 logfiles. Another is testing such imports. Instead of making the uuid random we now hash the name and add the timestamp of the first dive associated with this dive site to the hash (first in this context is "first encountered" with no guarantee that it is the chronologically first). This way V2 imports create deterministic uuids but uuid conflicts are still extremely unlikely, even if the user has multiple dive sites with the same name. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
6eed3155e6
commit
e03b553e80
11 changed files with 60 additions and 37 deletions
|
@ -1,3 +1,4 @@
|
|||
#include "units.h"
|
||||
#include "divelocationmodel.h"
|
||||
#include "dive.h"
|
||||
#include <QDebug>
|
||||
|
@ -126,14 +127,14 @@ void LocationInformationModel::update()
|
|||
endResetModel();
|
||||
}
|
||||
|
||||
int32_t LocationInformationModel::addDiveSite(const QString& name, int lon, int lat)
|
||||
int32_t LocationInformationModel::addDiveSite(const QString& name, timestamp_t divetime, int lon, int lat)
|
||||
{
|
||||
degrees_t latitude, longitude;
|
||||
latitude.udeg = lat;
|
||||
longitude.udeg = lon;
|
||||
|
||||
beginInsertRows(QModelIndex(), dive_site_table.nr + 2, dive_site_table.nr + 2);
|
||||
uint32_t uuid = create_dive_site_with_gps(name.toUtf8().data(), latitude, longitude);
|
||||
uint32_t uuid = create_dive_site_with_gps(name.toUtf8().data(), latitude, longitude, divetime);
|
||||
qSort(dive_site_table.dive_sites, dive_site_table.dive_sites + dive_site_table.nr, dive_site_less_than);
|
||||
internalRowCount = dive_site_table.nr;
|
||||
endInsertRows();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue