summaryrefslogtreecommitdiffstats
path: root/core/qthelper.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-03-13 09:44:48 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-03-19 13:14:54 -0700
commitc896938f7a5f1cf99a9792233ab1164cb7cd8585 (patch)
tree4059b6fba02ee6752aef1e7ec071a9f8aa9102e0 /core/qthelper.cpp
parentd9b502f0c7445e6e1cdb91dd270da205e2e833c4 (diff)
downloadsubsurface-c896938f7a5f1cf99a9792233ab1164cb7cd8585.tar.gz
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 <bstoeger@mail.tuwien.ac.at> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'core/qthelper.cpp')
-rw-r--r--core/qthelper.cpp8
1 files 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();
}