diff options
author | Dirk Hohndel <dirk@hohndel.org> | 2015-04-22 13:20:27 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2015-04-22 13:20:27 -0700 |
commit | 6f7e3d04cb737515b03243adc638fbc03e565c4d (patch) | |
tree | 0a8070cea96fac183e9db345130fbe8064e53409 | |
parent | 959077c66bd42d0b613a5ee54bc17fe3b9517bdd (diff) | |
download | subsurface-6f7e3d04cb737515b03243adc638fbc03e565c4d.tar.gz |
Handle XSLT based imports correctly
XSLT conversions create V2 XML files, but we shouldn't abort when we parse
those without having the user informed about the potential slowness - all
XSLT based imports are slow, anyway.
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r-- | dive.h | 1 | ||||
-rw-r--r-- | parse-xml.c | 7 | ||||
-rw-r--r-- | qt-ui/divelogimportdialog.cpp | 7 |
3 files changed, 10 insertions, 5 deletions
@@ -51,6 +51,7 @@ extern "C" { extern int last_xml_version; extern bool abort_read_of_old_file; extern bool v2_question_shown; +extern bool imported_via_xslt; enum dive_comp_type {OC, CCR, PSCR, FREEDIVE, NUM_DC_TYPE}; // Flags (Open-circuit and Closed-circuit-rebreather) for setting dive computer type enum cylinderuse {OC_GAS, DILUENT, OXYGEN, NUM_GAS_USE}; // The different uses for cylinders diff --git a/parse-xml.c b/parse-xml.c index a02c4afac..819d3a8ca 100644 --- a/parse-xml.c +++ b/parse-xml.c @@ -24,6 +24,7 @@ int metric = 1; int last_xml_version = -1; bool abort_read_of_old_file = false; bool v2_question_shown = false; +bool imported_via_xslt = false; static xmlDoc *test_xslt_transforms(xmlDoc *doc, const char **params); @@ -1681,7 +1682,7 @@ static bool entry(const char *name, char *buf) if (!strncmp(name, "version.program", sizeof("version.program") - 1) || !strncmp(name, "version.divelog", sizeof("version.divelog") - 1)) { last_xml_version = atoi(buf); - if (last_xml_version < 3 && !v2_question_shown) { + if (last_xml_version < 3 && !v2_question_shown && !imported_via_xslt) { // let's ask the user what they want to do about reverse geo coding // and warn them that opening older XML files can take a while // since C code shouldn't call the UI we set a global flag and bail @@ -1953,7 +1954,7 @@ int parse_xml_buffer(const char *url, const char *buffer, int size, } dive_end(); xmlFreeDoc(doc); - + imported_via_xslt = false; return ret; } @@ -3154,7 +3155,7 @@ static xmlDoc *test_xslt_transforms(xmlDoc *doc, const char **params) } free((void *)attribute); } - + imported_via_xslt = true; xmlSubstituteEntitiesDefault(1); xslt = get_stylesheet(info->file); if (xslt == NULL) { diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp index cccafdabf..763476d9f 100644 --- a/qt-ui/divelogimportdialog.cpp +++ b/qt-ui/divelogimportdialog.cpp @@ -574,6 +574,7 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy) void DiveLogImportDialog::on_buttonBox_accepted() { + imported_via_xslt = true; QStringList r = resultModel->result(); if (ui->knownImports->currentText() != "Manual import") { for (int i = 0; i < fileNames.size(); ++i) { @@ -592,9 +593,10 @@ void DiveLogImportDialog::on_buttonBox_accepted() specialCSV.contains(ui->knownImports->currentIndex()) ? CSVApps[ui->knownImports->currentIndex()].name.toUtf8().data() : "csv", ui->CSVUnits->currentIndex(), delta.toUtf8().data() - ) < 0) + ) < 0) { + imported_via_xslt = false; return; - + } // Seabear CSV stores NDL and TTS in Minutes, not seconds struct dive *dive = dive_table.dives[dive_table.nr - 1]; for(int s_nr = 0 ; s_nr <= dive->dc.samples ; s_nr++) { @@ -667,6 +669,7 @@ void DiveLogImportDialog::on_buttonBox_accepted() } process_dives(true, false); MainWindow::instance()->refreshDisplay(); + imported_via_xslt = false; } TagDragDelegate::TagDragDelegate(QObject *parent) : QStyledItemDelegate(parent) |