From 2c6b1a99af103232d420a09023e9e0e6ccee9084 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Tue, 17 Jul 2018 23:05:03 +0200 Subject: 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 --- desktop-widgets/mainwindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'desktop-widgets') diff --git a/desktop-widgets/mainwindow.cpp b/desktop-widgets/mainwindow.cpp index ff525eb00..a9423e053 100644 --- a/desktop-widgets/mainwindow.cpp +++ b/desktop-widgets/mainwindow.cpp @@ -982,7 +982,7 @@ void MainWindow::setupForAddAndPlan(const char *model) // clean out the dive and give it an id and the correct dc model clear_dive(&displayed_dive); clear_dive_site(&displayed_dive_site); - displayed_dive.id = dive_getUniqID(&displayed_dive); + displayed_dive.id = dive_getUniqID(); displayed_dive.when = QDateTime::currentMSecsSinceEpoch() / 1000L + gettimezoneoffset() + 3600; displayed_dive.dc.model = strdup(model); // don't translate! this is stored in the XML file dc_number = 1; -- cgit v1.2.3-70-g09d2