From 1952d1c187d7f7f544d74b9291a91447a32f1c67 Mon Sep 17 00:00:00 2001 From: Richard Fuchs Date: Sat, 27 Jan 2024 09:14:12 -0500 Subject: [PATCH] downloader: check for parsing failure Don't continue if the dive log could not be loaded. Otherwise we end up writing out an empty dive log. Signed-off-by: Richard Fuchs --- subsurface-downloader-main.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/subsurface-downloader-main.cpp b/subsurface-downloader-main.cpp index a71d5d4b1..6966f1125 100644 --- a/subsurface-downloader-main.cpp +++ b/subsurface-downloader-main.cpp @@ -91,7 +91,10 @@ int main(int argc, char **argv) filesOnCommandLine = !files.isEmpty() || !importedFiles.isEmpty(); if (!files.isEmpty()) { qDebug() << "loading dive data from" << files; - parse_file(qPrintable(files.first()), &divelog); + if (parse_file(qPrintable(files.first()), &divelog) < 0) { + printf("Failed to load dives from file '%s', aborting.\n", qPrintable(files.first())); + exit(1); + } } print_files(); if (!quit) {