mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
QML UI: make sure the dive list is empty before loading dives
When testing subsurface-mobile on the desktop from an account that had a default file set up in the Subsurface preferences that file would already be loaded creating rather confusing output. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
parent
7e7dcb2451
commit
a05e37188b
4 changed files with 20 additions and 13 deletions
13
divelist.c
13
divelist.c
|
@ -1098,3 +1098,16 @@ void report_datafile_version(int version)
|
|||
if (min_datafile_version == 0 || min_datafile_version > version)
|
||||
min_datafile_version = version;
|
||||
}
|
||||
|
||||
void clear_dive_file_data()
|
||||
{
|
||||
while (dive_table.nr)
|
||||
delete_single_dive(0);
|
||||
while (dive_site_table.nr)
|
||||
delete_dive_site(get_dive_site(0)->uuid);
|
||||
|
||||
free((void *)existing_filename);
|
||||
existing_filename = NULL;
|
||||
|
||||
reset_min_datafile_version();
|
||||
}
|
||||
|
|
|
@ -47,6 +47,7 @@ extern void set_dive_nr_for_current_dive();
|
|||
int get_min_datafile_version();
|
||||
void reset_min_datafile_version();
|
||||
void report_datafile_version(int version);
|
||||
void clear_dive_file_data();
|
||||
|
||||
#ifdef DEBUG_TRIP
|
||||
extern void dump_selection(void);
|
||||
|
|
|
@ -58,7 +58,7 @@ void QMLManager::loadDives()
|
|||
showMessage(get_error_string());
|
||||
return;
|
||||
}
|
||||
showMessage("got email / password");
|
||||
clear_dive_file_data();
|
||||
|
||||
QByteArray fileNamePrt = QFile::encodeName(url);
|
||||
int error = parse_file(fileNamePrt.data());
|
||||
|
@ -70,11 +70,13 @@ void QMLManager::loadDives()
|
|||
showMessage(get_error_string());
|
||||
}
|
||||
process_dives(false, false);
|
||||
|
||||
int i;
|
||||
struct dive *d;
|
||||
|
||||
for_each_dive(i, d)
|
||||
DiveListModel::instance()->addDive(d);
|
||||
for_each_dive(i, d) {
|
||||
DiveListModel::instance()->addDive(d);
|
||||
}
|
||||
}
|
||||
|
||||
void QMLManager::commitChanges(QString diveId, QString suit, QString buddy, QString diveMaster, QString notes)
|
||||
|
|
|
@ -433,16 +433,7 @@ void MainWindow::closeCurrentFile()
|
|||
graphics()->setEmptyState();
|
||||
/* free the dives and trips */
|
||||
clear_git_id();
|
||||
while (dive_table.nr)
|
||||
delete_single_dive(0);
|
||||
while (dive_site_table.nr)
|
||||
delete_dive_site(get_dive_site(0)->uuid);
|
||||
|
||||
free((void *)existing_filename);
|
||||
existing_filename = NULL;
|
||||
|
||||
reset_min_datafile_version();
|
||||
|
||||
clear_dive_file_data();
|
||||
cleanUpEmpty();
|
||||
mark_divelist_changed(false);
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue