From c896938f7a5f1cf99a9792233ab1164cb7cd8585 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Tue, 13 Mar 2018 09:44:48 +0100 Subject: Dive pictures: If EXIF data couldn't be parsed, use creation date This is a preparation for supporting videos. Some video formats may not possess such meta data, or we may not yet be able to parse them. In such a case, use the file creation date. Signed-off-by: Berthold Stoeger Signed-off-by: Dirk Hohndel --- core/qthelper.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/core/qthelper.cpp b/core/qthelper.cpp index 03d10fed9..0d072b461 100644 --- a/core/qthelper.cpp +++ b/core/qthelper.cpp @@ -402,8 +402,12 @@ static int parseExif(const QString &filename, easyexif::EXIFInfo &exif) extern "C" timestamp_t picture_get_timestamp(const char *filename) { easyexif::EXIFInfo exif; - if (parseExif(localFilePath(QString(filename)), exif) != PARSE_EXIF_SUCCESS) - return 0; + if (parseExif(localFilePath(QString(filename)), exif) != PARSE_EXIF_SUCCESS) { + // If we couldn't parse EXIF data, use file creation date. + // TODO: QFileInfo::created is deprecated in newer Qt versions. + QDateTime created = QFileInfo(QString(filename)).created(); + return created.toSecsSinceEpoch(); + } return exif.epoch(); } -- cgit v1.2.3-70-g09d2