Merge lp:~artmello/gallery-app/gallery-app-check_file_metadata into lp:gallery-app

Proposed by Arthur Mello
Status: Merged
Approved by: Bill Filler
Approved revision: 1123
Merged at revision: 1123
Proposed branch: lp:~artmello/gallery-app/gallery-app-check_file_metadata
Merge into: lp:gallery-app
Diff against target: 80 lines (+38/-14)
2 files modified
src/content-communicator.cpp (+4/-2)
src/medialoader/photo-metadata.cpp (+34/-12)
To merge this branch: bzr merge lp:~artmello/gallery-app/gallery-app-check_file_metadata
Reviewer Review Type Date Requested Status
Bill Filler (community) Approve
PS Jenkins bot continuous-integration Needs Fixing
Review via email: mp+244980@code.launchpad.net

Commit message

Add some checks to make sure the file has good metadata before changing it

Description of the change

Add some checks to make sure the file has good metadata before changing it

To post a comment you must log in.
Revision history for this message
PS Jenkins bot (ps-jenkins) wrote :
review: Needs Fixing (continuous-integration)
Revision history for this message
Bill Filler (bfiller) wrote :

approved

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'src/content-communicator.cpp'
2--- src/content-communicator.cpp 2014-11-12 22:27:21 +0000
3+++ src/content-communicator.cpp 2014-12-17 12:59:43 +0000
4@@ -94,8 +94,10 @@
5 // to show up on imported date Event
6 QFileInfo destfi(destination);
7 PhotoMetadata* metadata = PhotoMetadata::fromFile(destfi);
8- metadata->setDateTimeDigitized(QDateTime::currentDateTime());
9- metadata->save();
10+ if (metadata != NULL) {
11+ metadata->setDateTimeDigitized(QDateTime::currentDateTime());
12+ metadata->save();
13+ }
14 }
15 }
16 // Allow content-hub to clean up temporary files in .cache/ once we've
17
18=== modified file 'src/medialoader/photo-metadata.cpp'
19--- src/medialoader/photo-metadata.cpp 2014-10-24 18:25:32 +0000
20+++ src/medialoader/photo-metadata.cpp 2014-12-17 12:59:43 +0000
21@@ -215,12 +215,23 @@
22 */
23 void PhotoMetadata::setOrientation(Orientation orientation)
24 {
25- Exiv2::ExifData& exif_data = m_image->exifData();
26-
27- exif_data[EXIF_ORIENTATION_KEY] = orientation;
28-
29- if (!m_keysPresent.contains(EXIF_ORIENTATION_KEY))
30- m_keysPresent.insert(EXIF_ORIENTATION_KEY);
31+ try {
32+ if (!m_image->good()) {
33+ qDebug("Do not set Orientation, invalid image metadata.");
34+ return;
35+ }
36+
37+ Exiv2::ExifData& exif_data = m_image->exifData();
38+
39+ exif_data[EXIF_ORIENTATION_KEY] = orientation;
40+
41+ if (!m_keysPresent.contains(EXIF_ORIENTATION_KEY))
42+ m_keysPresent.insert(EXIF_ORIENTATION_KEY);
43+
44+ } catch (Exiv2::AnyError& e) {
45+ qDebug("Do not set Orientation, error reading image metadata; %s", e.what());
46+ return;
47+ }
48 }
49
50 /*!
51@@ -229,12 +240,23 @@
52 */
53 void PhotoMetadata::setDateTimeDigitized(const QDateTime& digitized)
54 {
55- Exiv2::ExifData& exif_data = m_image->exifData();
56-
57- exif_data[EXIF_DATETIMEDIGITIZED_KEY] = digitized.toString("yyyy:MM:dd hh:mm:ss").toStdString();
58-
59- if (!m_keysPresent.contains(EXIF_DATETIMEDIGITIZED_KEY))
60- m_keysPresent.insert(EXIF_DATETIMEDIGITIZED_KEY);
61+ try {
62+ if (!m_image->good()) {
63+ qDebug("Do not set DateTimeDigitized, invalid image metadata.");
64+ return;
65+ }
66+
67+ Exiv2::ExifData& exif_data = m_image->exifData();
68+
69+ exif_data[EXIF_DATETIMEDIGITIZED_KEY] = digitized.toString("yyyy:MM:dd hh:mm:ss").toStdString();
70+
71+ if (!m_keysPresent.contains(EXIF_DATETIMEDIGITIZED_KEY))
72+ m_keysPresent.insert(EXIF_DATETIMEDIGITIZED_KEY);
73+
74+ } catch (Exiv2::AnyError& e) {
75+ qDebug("Do not set DateTimeDigitized, error reading image metadata; %s", e.what());
76+ return;
77+ }
78 }
79
80 /*!

Subscribers

People subscribed via source and target branches