The old code trusted in Windows new lines with length of 3. The new code strips out spaces and line ending chars resulting in empty line being of length 0.
Signed-off-by: Miika Turkia <[email protected]> --- qt-ui/divelogimportdialog.cpp | 4 ++-- tests/testparse.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/qt-ui/divelogimportdialog.cpp b/qt-ui/divelogimportdialog.cpp index 29138da..3a34023 100644 --- a/qt-ui/divelogimportdialog.cpp +++ b/qt-ui/divelogimportdialog.cpp @@ -397,7 +397,7 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy) * the interval value is missing from the header. */ - while ((firstLine = f.readLine()).length() > 3 && !f.atEnd()) { + while ((firstLine = f.readLine().trimmed()).length() > 0 && !f.atEnd()) { if (firstLine.contains("//Hardware Version: ")) { hw = firstLine.replace(QString::fromLatin1("//Hardware Version: "), QString::fromLatin1("\"Seabear ")).trimmed().append("\""); break; @@ -408,7 +408,7 @@ void DiveLogImportDialog::loadFileContents(int value, whatChanged triggeredBy) * Note that we scan over the "Log interval" on purpose */ - while ((firstLine = f.readLine()).length() > 3 && !f.atEnd()) { + while ((firstLine = f.readLine().trimmed()).length() > 0 && !f.atEnd()) { if (firstLine.contains("//Log interval: ")) delta = firstLine.remove(QString::fromLatin1("//Log interval: ")).trimmed().remove(QString::fromLatin1(" s")); } diff --git a/tests/testparse.cpp b/tests/testparse.cpp index 9288baf..fa1d6d2 100644 --- a/tests/testparse.cpp +++ b/tests/testparse.cpp @@ -166,7 +166,7 @@ void TestParse::testParseNewFormat() */ f.open(QFile::ReadOnly); - while ((firstLine = f.readLine()).length() > 3 && !f.atEnd()) { + while ((firstLine = f.readLine().trimmed()).length() > 0 && !f.atEnd()) { if (firstLine.contains("//Log interval: ")) delta = firstLine.remove(QString::fromLatin1("//Log interval: ")).trimmed().remove(QString::fromLatin1(" s")); } -- 2.1.4 _______________________________________________ subsurface mailing list [email protected] http://lists.subsurface-divelog.org/cgi-bin/mailman/listinfo/subsurface
