mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-30 22:20:21 +00:00
cleanup: move clearing of device nodes to clear_dive_file_data()
It makes no sense to keep the device nodes if all the other data is cleared. Let's do this automatically and not explicitly. This ensures that the function is also called on mobile. Currently it was only called on desktop. Weirdly, the parser-tests were expecting that the device nodes were not reset by clear_dive_file_data() and therefore divecomputers were accumulating in the test results. Thus, the additional computers had to be removed from the expected test results. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
52f93ea326
commit
17526ded58
11 changed files with 9 additions and 23 deletions
|
@ -14,6 +14,7 @@ extern void set_dc_deviceid(struct divecomputer *dc, unsigned int deviceid);
|
|||
extern void create_device_node(const char *model, uint32_t deviceid, const char *serial, const char *firmware, const char *nickname);
|
||||
extern void call_for_each_dc(void *f, void (*callback)(void *, const char *, uint32_t,
|
||||
const char *, const char *, const char *), bool select_only);
|
||||
extern void clear_device_nodes();
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
|
|
@ -85,6 +85,11 @@ extern "C" void create_device_node(const char *model, uint32_t deviceid, const c
|
|||
dcList.addDC(model, deviceid, nickname, serial, firmware);
|
||||
}
|
||||
|
||||
extern "C" void clear_device_nodes()
|
||||
{
|
||||
dcList.dcs.clear();
|
||||
}
|
||||
|
||||
static bool compareDCById(const DiveComputerNode &a, const DiveComputerNode &b)
|
||||
{
|
||||
return a.deviceId < b.deviceId;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "subsurface-string.h"
|
||||
#include "deco.h"
|
||||
#include "device.h"
|
||||
#include "divesite.h"
|
||||
#include "divelist.h"
|
||||
#include "fulltext.h"
|
||||
|
@ -1367,6 +1368,7 @@ void clear_dive_file_data()
|
|||
}
|
||||
|
||||
clear_dive(&displayed_dive);
|
||||
clear_device_nodes();
|
||||
|
||||
reset_min_datafile_version();
|
||||
clear_git_id();
|
||||
|
|
|
@ -18,7 +18,6 @@
|
|||
|
||||
#include "core/color.h"
|
||||
#include "core/device.h"
|
||||
#include "core/divecomputer.h"
|
||||
#include "core/divesitehelpers.h"
|
||||
#include "core/errorhelper.h"
|
||||
#include "core/file.h"
|
||||
|
@ -653,7 +652,7 @@ void MainWindow::closeCurrentFile()
|
|||
{
|
||||
/* free the dives and trips */
|
||||
clear_git_id();
|
||||
MultiFilterSortModel::instance()->clear();
|
||||
MultiFilterSortModel::instance()->clear(); // this clears all the core data structures
|
||||
setCurrentFile(nullptr);
|
||||
diveList->setSortOrder(DiveTripModelBase::NR, Qt::DescendingOrder);
|
||||
MapWidget::instance()->reload();
|
||||
|
@ -663,8 +662,6 @@ void MainWindow::closeCurrentFile()
|
|||
setFileClean();
|
||||
|
||||
clear_events();
|
||||
|
||||
dcList.dcs.clear();
|
||||
}
|
||||
|
||||
void MainWindow::updateCloudOnlineStatus()
|
||||
|
|
|
@ -1,10 +1,5 @@
|
|||
<divelog program='subsurface' version='3'>
|
||||
<settings>
|
||||
<divecomputerid model='Subsurface Divelog' deviceid='01234567' serial='3' nickname='Heinrichs Weikamp OSTC 3'/>
|
||||
<divecomputerid model='Vyper Air' deviceid='013749e4' serial='20400612'/>
|
||||
<divecomputerid model='Suunto Vyper Air' deviceid='11223344' serial='99999999'/>
|
||||
<divecomputerid model='Heinrichs Weikamp OSTC Sport' deviceid='abcdef00' serial='10000' firmware='10.31'/>
|
||||
<divecomputerid model='Vyper Air' deviceid='ffffffff' serial='20400612'/>
|
||||
</settings>
|
||||
<divesites>
|
||||
</divesites>
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
<divelog program='subsurface' version='3'>
|
||||
<settings>
|
||||
<divecomputerid model='Vyper Air' deviceid='013749e4' serial='20400612'/>
|
||||
<divecomputerid model='Vyper Air' deviceid='ffffffff' serial='20400612'/>
|
||||
</settings>
|
||||
<divesites>
|
||||
</divesites>
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
<divelog program='subsurface' version='3'>
|
||||
<settings>
|
||||
<divecomputerid model='Vyper Air' deviceid='013749e4' serial='20400612'/>
|
||||
<divecomputerid model='Vyper Air' deviceid='ffffffff' serial='20400612'/>
|
||||
</settings>
|
||||
<divesites>
|
||||
<site uuid='64785a00' name='USA, Hoodsport, WA / Sund Rock' gps='47.400269 -123.142632'>
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
<divelog program='subsurface' version='3'>
|
||||
<settings>
|
||||
<divecomputerid model='Vyper Air' deviceid='013749e4' serial='20400612'/>
|
||||
<divecomputerid model='Vyper Air' deviceid='ffffffff' serial='20400612'/>
|
||||
</settings>
|
||||
<divesites>
|
||||
</divesites>
|
||||
|
|
|
@ -1,7 +1,5 @@
|
|||
<divelog program='subsurface' version='3'>
|
||||
<settings>
|
||||
<divecomputerid model='Vyper Air' deviceid='013749e4' serial='20400612'/>
|
||||
<divecomputerid model='Vyper Air' deviceid='ffffffff' serial='20400612'/>
|
||||
</settings>
|
||||
<divesites>
|
||||
</divesites>
|
||||
|
|
|
@ -1,9 +1,7 @@
|
|||
<divelog program='subsurface' version='3'>
|
||||
<settings>
|
||||
<divecomputerid model='Vyper Air' deviceid='013749e4' serial='20400612'/>
|
||||
<divecomputerid model='Suunto Vyper Air' deviceid='11223344' serial='99999999'/>
|
||||
<divecomputerid model='Heinrichs Weikamp OSTC Sport' deviceid='abcdef00' serial='10000' firmware='10.31'/>
|
||||
<divecomputerid model='Vyper Air' deviceid='ffffffff' serial='20400612'/>
|
||||
</settings>
|
||||
<divesites>
|
||||
</divesites>
|
||||
|
|
|
@ -286,11 +286,6 @@ void TestParse::testParseDLD()
|
|||
fprintf(stderr, "number of dives from DLD: %d \n", dive_table.nr);
|
||||
|
||||
// Compare output
|
||||
/*
|
||||
* DC is not cleared from previous tests with the
|
||||
* clear_dive_file_data(), so we do have an additional DC nick
|
||||
* name field on the log.
|
||||
*/
|
||||
QCOMPARE(save_dives("./testdldout.ssrf"), 0);
|
||||
FILE_COMPARE("./testdldout.ssrf",
|
||||
SUBSURFACE_TEST_DATA "/dives/TestDiveDivelogsDE.xml")
|
||||
|
|
Loading…
Reference in a new issue