diff options
-rw-r--r-- | divelist.c | 13 | ||||
-rw-r--r-- | divelist.h | 1 | ||||
-rw-r--r-- | qt-mobile/qmlmanager.cpp | 8 | ||||
-rw-r--r-- | qt-ui/mainwindow.cpp | 11 |
4 files changed, 20 insertions, 13 deletions
diff --git a/divelist.c b/divelist.c index 953dd7839..18ff99135 100644 --- a/divelist.c +++ b/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(); +} diff --git a/divelist.h b/divelist.h index 04f26f68a..bc3fd1af1 100644 --- a/divelist.h +++ b/divelist.h @@ -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); diff --git a/qt-mobile/qmlmanager.cpp b/qt-mobile/qmlmanager.cpp index 8cefbe95f..3e09be7c3 100644 --- a/qt-mobile/qmlmanager.cpp +++ b/qt-mobile/qmlmanager.cpp @@ -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) diff --git a/qt-ui/mainwindow.cpp b/qt-ui/mainwindow.cpp index d67187149..971b31c1c 100644 --- a/qt-ui/mainwindow.cpp +++ b/qt-ui/mainwindow.cpp @@ -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); |