mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
Import: avoid model inconsistency in DiveImportedModel::recordDives()
DiveImportedModel::recordDives() called add_imported_dives(). But that actually consumes the dive and dive-site tables. Which in turn will lead to an inconsistent model. Properly reset the model by using the consumeTables() function. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
087a80194a
commit
5037fcdbdc
1 changed files with 9 additions and 2 deletions
|
@ -199,14 +199,21 @@ void DiveImportedModel::deleteDeselected()
|
||||||
// Note: this function is only used from mobile - perhaps move it there or unify.
|
// Note: this function is only used from mobile - perhaps move it there or unify.
|
||||||
void DiveImportedModel::recordDives()
|
void DiveImportedModel::recordDives()
|
||||||
{
|
{
|
||||||
|
deleteDeselected();
|
||||||
|
|
||||||
if (diveTable.nr == 0)
|
if (diveTable.nr == 0)
|
||||||
// nothing to do, just exit
|
// nothing to do, just exit
|
||||||
return;
|
return;
|
||||||
|
|
||||||
deleteDeselected();
|
// Consume the tables. They will be consumed by add_imported_dives() anyway.
|
||||||
|
// But let's do it in a controlled way with a proper model-reset so that the
|
||||||
|
// model doesn't become inconsistent.
|
||||||
|
std::pair<struct dive_table, struct dive_site_table> tables = consumeTables();
|
||||||
|
|
||||||
// TODO: Might want to let the user select IMPORT_ADD_TO_NEW_TRIP
|
// TODO: Might want to let the user select IMPORT_ADD_TO_NEW_TRIP
|
||||||
add_imported_dives(&diveTable, nullptr, &sitesTable, IMPORT_PREFER_IMPORTED | IMPORT_IS_DOWNLOADED);
|
add_imported_dives(&tables.first, nullptr, &tables.second, IMPORT_PREFER_IMPORTED | IMPORT_IS_DOWNLOADED);
|
||||||
|
free(tables.first.dives);
|
||||||
|
free(tables.second.dive_sites);
|
||||||
}
|
}
|
||||||
|
|
||||||
QHash<int, QByteArray> DiveImportedModel::roleNames() const {
|
QHash<int, QByteArray> DiveImportedModel::roleNames() const {
|
||||||
|
|
Loading…
Add table
Reference in a new issue