Remove all the no longer necessary code that aborts read of first V2 file

This was a poorly implemented hack when we executed the reverse geo lookup
in the main thread and opening a V2 file could take a very long time. We
need to do the "Welcome" message quite differently.

Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Dirk Hohndel 2015-06-16 12:52:39 -07:00
parent bd11988f74
commit ccc9d80015
9 changed files with 4 additions and 75 deletions

3
dive.h
View file

@ -49,9 +49,6 @@ extern "C" {
#endif #endif
extern int last_xml_version; 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 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 enum cylinderuse {OC_GAS, DILUENT, OXYGEN, NUM_GAS_USE}; // The different uses for cylinders

9
file.c
View file

@ -1168,16 +1168,7 @@ int parse_manual_file(const char *filename, int sepidx, int units, int dateforma
if (try_to_xslt_open_csv(filename, &mem, "manualCSV")) if (try_to_xslt_open_csv(filename, &mem, "manualCSV"))
return -1; return -1;
// right now input files created by XSLT processing report being v2 XML which makes
// the parse function abort until the dialog about importing v2 files has been shown.
// Until the XSLT has been updated we just override this check
//
// FIXME
//
bool remember = v2_question_shown;
v2_question_shown = true;
ret = parse_xml_buffer(filename, mem.buffer, mem.size, &dive_table, (const char **)params); ret = parse_xml_buffer(filename, mem.buffer, mem.size, &dive_table, (const char **)params);
v2_question_shown = remember;
free(mem.buffer); free(mem.buffer);
return ret; return ret;

View file

@ -22,9 +22,6 @@
int verbose, quit; int verbose, quit;
int metric = 1; int metric = 1;
int last_xml_version = -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); static xmlDoc *test_xslt_transforms(xmlDoc *doc, const char **params);
@ -1718,14 +1715,6 @@ static bool entry(const char *name, char *buf)
if (!strncmp(name, "version.program", sizeof("version.program") - 1) || if (!strncmp(name, "version.program", sizeof("version.program") - 1) ||
!strncmp(name, "version.divelog", sizeof("version.divelog") - 1)) { !strncmp(name, "version.divelog", sizeof("version.divelog") - 1)) {
last_xml_version = atoi(buf); last_xml_version = atoi(buf);
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
// from reading the file for now
abort_read_of_old_file = true;
return false;
}
} }
if (in_userid) { if (in_userid) {
try_to_fill_userid(name, buf); try_to_fill_userid(name, buf);
@ -1996,7 +1985,6 @@ int parse_xml_buffer(const char *url, const char *buffer, int size,
} }
dive_end(); dive_end();
xmlFreeDoc(doc); xmlFreeDoc(doc);
imported_via_xslt = false;
return ret; return ret;
} }
@ -3213,7 +3201,6 @@ static xmlDoc *test_xslt_transforms(xmlDoc *doc, const char **params)
} }
free((void *)attribute); free((void *)attribute);
} }
imported_via_xslt = true;
xmlSubstituteEntitiesDefault(1); xmlSubstituteEntitiesDefault(1);
xslt = get_stylesheet(info->file); xslt = get_stylesheet(info->file);
if (xslt == NULL) { if (xslt == NULL) {

View file

@ -574,7 +574,6 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy)
void DiveLogImportDialog::on_buttonBox_accepted() void DiveLogImportDialog::on_buttonBox_accepted()
{ {
imported_via_xslt = true;
QStringList r = resultModel->result(); QStringList r = resultModel->result();
if (ui->knownImports->currentText() != "Manual import") { if (ui->knownImports->currentText() != "Manual import") {
for (int i = 0; i < fileNames.size(); ++i) { for (int i = 0; i < fileNames.size(); ++i) {
@ -594,7 +593,6 @@ void DiveLogImportDialog::on_buttonBox_accepted()
ui->CSVUnits->currentIndex(), ui->CSVUnits->currentIndex(),
delta.toUtf8().data() delta.toUtf8().data()
) < 0) { ) < 0) {
imported_via_xslt = false;
return; return;
} }
// Seabear CSV stores NDL and TTS in Minutes, not seconds // Seabear CSV stores NDL and TTS in Minutes, not seconds
@ -670,7 +668,6 @@ void DiveLogImportDialog::on_buttonBox_accepted()
} }
process_dives(true, false); process_dives(true, false);
MainWindow::instance()->refreshDisplay(); MainWindow::instance()->refreshDisplay();
imported_via_xslt = false;
} }
TagDragDelegate::TagDragDelegate(QObject *parent) : QStyledItemDelegate(parent) TagDragDelegate::TagDragDelegate(QObject *parent) : QStyledItemDelegate(parent)

View file

@ -237,11 +237,6 @@ void MainTab::enableGeoLookupEdition()
{ {
ui.waitingSpinner->stop(); ui.waitingSpinner->stop();
ui.addDiveSite->show(); ui.addDiveSite->show();
// if we showed an informational text about loading the files, hide it, but don't
// hide the message area if it contains other warnings
if (MainWindow::instance()->getNotificationWidget()->getNotificationText() ==
tr("Please Wait, Importing your files..."))
MainWindow::instance()->getNotificationWidget()->hideNotification();
} }
void MainTab::disableGeoLookupEdition() void MainTab::disableGeoLookupEdition()

View file

@ -1495,24 +1495,6 @@ void MainWindow::importTxtFiles(const QStringList fileNames)
refreshDisplay(); refreshDisplay();
} }
void MainWindow::showV2Dialog()
{
// here we need to ask the user if / how they want to do the reverse geo coding
//
// since the reverse geo coding now happens in its own thread the warning isn't needed
// anymore, but I'll leave this function / the logic to call it around because we are likely
// too have to add questions about how the user wants to do the reverse geo coding...
//
#if 0
QMessageBox d(QMessageBox::Information,
tr("Welcom to Subsurface %1").arg(subsurface_version()),
tr("Importing data files from earlier versions of Subsurface can take a significant amount of time"),
QMessageBox::Ok,
this);
d.exec();
#endif
}
void MainWindow::loadFiles(const QStringList fileNames) void MainWindow::loadFiles(const QStringList fileNames)
{ {
bool showWarning = false; bool showWarning = false;
@ -1537,14 +1519,6 @@ void MainWindow::loadFiles(const QStringList fileNames)
getNotificationWidget()->showNotification(warning , KMessageWidget::Information); getNotificationWidget()->showNotification(warning , KMessageWidget::Information);
} }
} else { } else {
if (!v2_question_shown && abort_read_of_old_file) {
v2_question_shown = true;
abort_read_of_old_file = false;
showV2Dialog();
getNotificationWidget()->showNotification(tr("Please Wait, Importing your files..."), KMessageWidget::Information);
i--; // so we re-try this file
continue;
}
failedParses.append(fileNames.at(i)); failedParses.append(fileNames.at(i));
} }
} }

View file

@ -92,7 +92,6 @@ public:
void printPlan(); void printPlan();
void checkSurvey(QSettings *s); void checkSurvey(QSettings *s);
void setApplicationState(const QByteArray& state); void setApplicationState(const QByteArray& state);
void showV2Dialog();
QUndoStack *undoStack; QUndoStack *undoStack;
NotificationWidget *getNotificationWidget(); NotificationWidget *getNotificationWidget();
void enableDisableCloudActions(); void enableDisableCloudActions();

View file

@ -6,8 +6,7 @@ void TestParse::testParseCSV()
{ {
// some basic file parsing tests // some basic file parsing tests
// //
// even with the V2 question not shown, CSV import should work // CSV import should work
v2_question_shown = false;
verbose = 1; verbose = 1;
QCOMPARE(parse_manual_file(SUBSURFACE_SOURCE "/dives/test41.csv", QCOMPARE(parse_manual_file(SUBSURFACE_SOURCE "/dives/test41.csv",
0, // tab separator 0, // tab separator
@ -21,25 +20,16 @@ void TestParse::testParseCSV()
void TestParse::testParseV2NoQuestion() void TestParse::testParseV2NoQuestion()
{ {
// but parsing of a V2 file should fail // parsing of a V2 file should work
v2_question_shown = false; QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/test40.xml"), 0);
QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/test40.xml"), -1);
} }
void TestParse::testParseV3() void TestParse::testParseV3()
{ {
// while parsing of a V3 files should succeed // parsing of a V3 files should succeed
v2_question_shown = false;
QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/test42.xml"), 0); QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/test42.xml"), 0);
} }
void TestParse::testParseV2YesQuestion()
{
// once we claim to have shown the V2 question, parsing the V2 file should work as well
v2_question_shown = true;
QCOMPARE(parse_file(SUBSURFACE_SOURCE "/dives/test40.xml"), 0);
}
void TestParse::testParseCompareOutput() void TestParse::testParseCompareOutput()
{ {
QCOMPARE(save_dives("./testout.ssrf"), 0); QCOMPARE(save_dives("./testout.ssrf"), 0);

View file

@ -8,7 +8,6 @@ class TestParse : public QObject{
private slots: private slots:
void testParseCSV(); void testParseCSV();
void testParseV2NoQuestion(); void testParseV2NoQuestion();
void testParseV2YesQuestion();
void testParseV3(); void testParseV3();
void testParseCompareOutput(); void testParseCompareOutput();
}; };