mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-27 20:58:47 +00:00
parser: keep divelist sorted
The parser used to append each parsed dive at the end of the log. At the end the list was sorted. However, the divelist code depends on the list being sorted. To avoid inconsistent states, add the dives at the proper position. Note that the reference data of TestDiveSeabearNewFormat had to be adapted, because the CNS calculation now gives a different value. This shouls be investigated. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
124362caa5
commit
4afefb1b9b
4 changed files with 4 additions and 31 deletions
|
@ -262,12 +262,8 @@ void dive_end(struct parser_state *state)
|
|||
if (is_dive(state)) {
|
||||
if (state->cur_trip)
|
||||
state->cur_trip->add_dive(state->cur_dive.get());
|
||||
// Note: we add dives in an unsorted way. The caller of the parsing
|
||||
// function must sort dives.
|
||||
fixup_dive(state->cur_dive.get());
|
||||
state->log->dives.push_back(std::move(state->cur_dive));
|
||||
// This would add dives in a sorted way:
|
||||
// state->log->dives.record_dive(std::move(state->cur_dive));
|
||||
state->log->dives.record_dive(std::move(state->cur_dive));
|
||||
}
|
||||
state->cur_dive.reset();
|
||||
state->cur_dc = NULL;
|
||||
|
|
|
@ -834,7 +834,7 @@
|
|||
<sample time='17:15 min' depth='0.0 m' />
|
||||
</divecomputer>
|
||||
</dive>
|
||||
<dive number='3' otu='14' cns='20%' date='2012-10-01' time='06:49:00' duration='16:25 min'>
|
||||
<dive number='3' otu='14' cns='29%' date='2012-10-01' time='06:49:00' duration='16:25 min'>
|
||||
<divecomputer model='Seabear T1'>
|
||||
<depth max='69.9 m' mean='32.928 m' />
|
||||
<temperature water='25.0 C' />
|
||||
|
@ -1974,7 +1974,7 @@
|
|||
<sample time='16:24 min' depth='0.1 m' />
|
||||
</divecomputer>
|
||||
</dive>
|
||||
<dive number='4' otu='14' cns='27%' date='2012-10-01' time='07:07:00' duration='16:17 min'>
|
||||
<dive number='4' otu='14' cns='48%' date='2012-10-01' time='07:07:00' duration='16:17 min'>
|
||||
<divecomputer model='Seabear T1' dctype='Freedive'>
|
||||
<depth max='70.1 m' mean='33.197 m' />
|
||||
<temperature water='24.0 C' />
|
||||
|
@ -3113,7 +3113,7 @@
|
|||
<sample time='17:15 min' depth='0.0 m' />
|
||||
</divecomputer>
|
||||
</dive>
|
||||
<dive number='5' otu='14' cns='35%' date='2012-10-01' time='07:24:00' duration='16:25 min'>
|
||||
<dive number='5' otu='14' cns='70%' date='2012-10-01' time='07:24:00' duration='16:25 min'>
|
||||
<divecomputer model='Seabear T1'>
|
||||
<depth max='69.9 m' mean='32.928 m' />
|
||||
<temperature water='25.0 C' />
|
||||
|
|
|
@ -132,8 +132,6 @@ void TestParse::testParse()
|
|||
QCOMPARE(parseV3(), 0);
|
||||
fprintf(stderr, "number of dives %d \n", static_cast<int>(divelog.dives.size()));
|
||||
|
||||
divelog.dives.sort();
|
||||
|
||||
QCOMPARE(save_dives("./testout.ssrf"), 0);
|
||||
FILE_COMPARE("./testout.ssrf",
|
||||
SUBSURFACE_TEST_DATA "/dives/test40-42.xml");
|
||||
|
@ -144,8 +142,6 @@ void TestParse::testParseDM4()
|
|||
QCOMPARE(sqlite3_open(SUBSURFACE_TEST_DATA "/dives/TestDiveDM4.db", &_sqlite3_handle), 0);
|
||||
QCOMPARE(parse_dm4_buffer(_sqlite3_handle, 0, 0, 0, &divelog), 0);
|
||||
|
||||
divelog.dives.sort();
|
||||
|
||||
QCOMPARE(save_dives("./testdm4out.ssrf"), 0);
|
||||
FILE_COMPARE("./testdm4out.ssrf",
|
||||
SUBSURFACE_TEST_DATA "/dives/TestDiveDM4.xml");
|
||||
|
@ -156,8 +152,6 @@ void TestParse::testParseDM5()
|
|||
QCOMPARE(sqlite3_open(SUBSURFACE_TEST_DATA "/dives/TestDiveDM5.db", &_sqlite3_handle), 0);
|
||||
QCOMPARE(parse_dm5_buffer(_sqlite3_handle, 0, 0, 0, &divelog), 0);
|
||||
|
||||
divelog.dives.sort();
|
||||
|
||||
QCOMPARE(save_dives("./testdm5out.ssrf"), 0);
|
||||
FILE_COMPARE("./testdm5out.ssrf",
|
||||
SUBSURFACE_TEST_DATA "/dives/TestDiveDM5.xml");
|
||||
|
@ -200,8 +194,6 @@ void TestParse::testParseHUDC()
|
|||
dive.dcs[0].when = 1255152761;
|
||||
}
|
||||
|
||||
divelog.dives.sort();
|
||||
|
||||
QCOMPARE(save_dives("./testhudcout.ssrf"), 0);
|
||||
FILE_COMPARE("./testhudcout.ssrf",
|
||||
SUBSURFACE_TEST_DATA "/dives/TestDiveSeabearHUDC.xml");
|
||||
|
@ -237,8 +229,6 @@ void TestParse::testParseNewFormat()
|
|||
QCOMPARE(divelog.dives.size(), i + 1);
|
||||
}
|
||||
|
||||
divelog.dives.sort();
|
||||
|
||||
fprintf(stderr, "number of dives %d \n", static_cast<int>(divelog.dives.size()));
|
||||
QCOMPARE(save_dives("./testsbnewout.ssrf"), 0);
|
||||
|
||||
|
@ -257,8 +247,6 @@ void TestParse::testParseDLD()
|
|||
|
||||
fprintf(stderr, "number of dives from DLD: %d \n", static_cast<int>(divelog.dives.size()));
|
||||
|
||||
divelog.dives.sort();
|
||||
|
||||
// Compare output
|
||||
QCOMPARE(save_dives("./testdldout.ssrf"), 0);
|
||||
FILE_COMPARE("./testdldout.ssrf",
|
||||
|
@ -273,8 +261,6 @@ void TestParse::testParseMerge()
|
|||
QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/ostc.xml", &divelog), 0);
|
||||
QCOMPARE(parse_file(SUBSURFACE_TEST_DATA "/dives/vyper.xml", &divelog), 0);
|
||||
|
||||
divelog.dives.sort();
|
||||
|
||||
QCOMPARE(save_dives("./testmerge.ssrf"), 0);
|
||||
FILE_COMPARE("./testmerge.ssrf",
|
||||
SUBSURFACE_TEST_DATA "/dives/mergedVyperOstc.xml");
|
||||
|
@ -335,7 +321,6 @@ void TestParse::exportCSVDiveDetails()
|
|||
// We do not currently support reading SAC, thus faking it
|
||||
if (!divelog.dives.empty())
|
||||
divelog.dives.back()->sac = saved_sac;
|
||||
divelog.dives.sort();
|
||||
|
||||
export_dives_xslt("testcsvexportmanual2.csv", 0, 0, "xml2manualcsv.xslt", false);
|
||||
FILE_COMPARE("testcsvexportmanual2.csv",
|
||||
|
@ -368,8 +353,6 @@ void TestParse::exportSubsurfaceCSV()
|
|||
if (!divelog.dives.empty())
|
||||
divelog.dives.back()->sac = saved_sac;
|
||||
|
||||
divelog.dives.sort();
|
||||
|
||||
export_dives_xslt("testcsvexportmanual2-cyl.csv", 0, 0, "xml2manualcsv.xslt", false);
|
||||
FILE_COMPARE("testcsvexportmanual2-cyl.csv",
|
||||
"testcsvexportmanual-cyl.csv");
|
||||
|
@ -407,7 +390,6 @@ void TestParse::exportCSVDiveProfile()
|
|||
clear_dive_file_data();
|
||||
|
||||
parseCSVprofile(1, "testcsvexportprofileimperial.csv");
|
||||
divelog.dives.sort();
|
||||
|
||||
export_dives_xslt("testcsvexportprofile2.csv", 0, 0, "xml2csv.xslt", false);
|
||||
FILE_COMPARE("testcsvexportprofile2.csv",
|
||||
|
@ -425,7 +407,6 @@ void TestParse::exportUDDF()
|
|||
clear_dive_file_data();
|
||||
|
||||
parse_file("testuddfexport.uddf", &divelog);
|
||||
divelog.dives.sort();
|
||||
|
||||
export_dives_xslt("testuddfexport2.uddf", 0, 1, "uddf-export.xslt", false);
|
||||
FILE_COMPARE("testuddfexport.uddf",
|
||||
|
@ -473,8 +454,6 @@ void TestParse::parseDL7()
|
|||
0);
|
||||
QCOMPARE(divelog.dives.size(), 3);
|
||||
|
||||
divelog.dives.sort();
|
||||
|
||||
QCOMPARE(save_dives("./testdl7out.ssrf"), 0);
|
||||
FILE_COMPARE("./testdl7out.ssrf",
|
||||
SUBSURFACE_TEST_DATA "/dives/DL7.xml");
|
||||
|
|
|
@ -35,7 +35,6 @@ void TestProfile::testProfileExport()
|
|||
{
|
||||
prefs.planner_deco_mode = BUEHLMANN;
|
||||
parse_file(SUBSURFACE_TEST_DATA "/dives/abitofeverything.ssrf", &divelog);
|
||||
divelog.dives.sort();
|
||||
save_profiledata("exportprofile.csv", false);
|
||||
QFile org(SUBSURFACE_TEST_DATA "/dives/exportprofilereference.csv");
|
||||
QCOMPARE(org.open(QFile::ReadOnly), true);
|
||||
|
@ -52,7 +51,6 @@ void TestProfile::testProfileExportVPMB()
|
|||
{
|
||||
prefs.planner_deco_mode = VPMB;
|
||||
parse_file(SUBSURFACE_TEST_DATA "/dives/abitofeverything.ssrf", &divelog);
|
||||
divelog.dives.sort();
|
||||
save_profiledata("exportprofileVPMB.csv", false);
|
||||
QFile org(SUBSURFACE_TEST_DATA "/dives/exportprofilereferenceVPMB.csv");
|
||||
QCOMPARE(org.open(QFile::ReadOnly), true);
|
||||
|
|
Loading…
Reference in a new issue