File: 0006_qml-Viewfinder-fix-content-export-preview-corruption.patch

package info (click to toggle)
lomiri-camera-app 4.0.8%2Bdfsg-5
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 5,992 kB
  • sloc: cpp: 1,727; javascript: 27; makefile: 22; python: 22; sh: 12
file content (103 lines) | stat: -rw-r--r-- 4,196 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
From f3f7476729771137ea510f81357fef98d9d3b9bb Mon Sep 17 00:00:00 2001
From: Ratchanan Srirattanamet <ratchanan@ubports.com>
Date: Fri, 30 May 2025 20:56:44 +0700
Subject: [PATCH] qml/Viewfinder: fix content export preview corruption in
 !hasEXIF mode

Because of signal connection order, content export preview will start
rendering image while `deleteEXIF()` re-writes the file. This causes
preview image to corrupt.

Move all imageSaved() signal handler code from `ViewFinderOverlay` to
`ViewFinderView` so that we can control the ordering. Order it so that
(synchronous) `deleteEXIF()` happens before content export preview
renders image.

#While we're at it, remove call to non-existent `fileOperations.
#setEXIFData()` (which is redundant with another part of code in
#`ViewFinderOverlay`); the exception thrown will prevent the rest of the
#code to run.

Finally, add a few comments so that we turn `deleteEXIF()` to be
asynchronous in the future.

Fixes: https://gitlab.com/ubports/development/apps/lomiri-camera-app/-/issues/217
Fixes: e38dbba16647 ("add fixes to barcodereader app and drop obsolete imports")
Signed-off-by: Mike Gabriel <mike.gabriel@das-netzwerkteam.de>
---
 ViewFinderOverlay.qml | 35 ----------------------------
 ViewFinderView.qml    | 23 +++++++++++++++++-
 2 files changed, 22 insertions(+), 36 deletions(-)

--- a/ViewFinderOverlay.qml
+++ b/ViewFinderOverlay.qml
@@ -1008,10 +1008,6 @@
                                           position.horizontalAccuracy <= 100)
         }
 
-        PostProcessOperations {
-            id: postProcessOperations
-        }
-
         Connections {
             target: camera.imageCapture
             onReadyChanged: {
@@ -1021,19 +1017,6 @@
                     }
                 }
             }
-            onImageSaved : {
-                if(path &&!settings.hasEXIF)
-                {
-                    postProcessOperations.deleteEXIFdata(path);
-                }
-                if(path && settings.dateStampImages && !main.contentExportMode) {
-                    postProcessOperations.addDateStamp(path,
-                                                       viewFinderOverlay.settings.dateStampFormat,
-                                                       viewFinderOverlay.settings.dateStampColor,
-                                                       viewFinderOverlay.settings.dateStampOpacity,
-                                                       viewFinderOverlay.settings.dateStampAlign);
-                }
-            }
         }
 
         CircleButton {
--- a/ViewFinderView.qml
+++ b/ViewFinderView.qml
@@ -131,7 +131,24 @@
             }
 
             onImageSaved: {
-                if (main.contentExportMode) viewFinderExportConfirmation.mediaPath = path;
+                if(!viewFinderOverlay.settings.hasEXIF) {
+                    // TODO: make this operation asynchronous.
+                    postProcessOperations.deleteEXIFdata(path);
+                }
+
+                if(viewFinderOverlay.settings.dateStampImages && !main.contentExportMode) {
+                    postProcessOperations.addDateStamp(path,
+                                                       viewFinderOverlay.settings.dateStampFormat,
+                                                       viewFinderOverlay.settings.dateStampColor,
+                                                       viewFinderOverlay.settings.dateStampOpacity,
+                                                       viewFinderOverlay.settings.dateStampAlign);
+                }
+
+                // TODO: make it so that asynchronous operations signals to us
+                // on finished and only then proceed to the code below.
+
+                if (main.contentExportMode)
+                    viewFinderExportConfirmation.mediaPath = path;
 
                 viewFinderView.photoTaken(path);
                 metricPhotos.increment();
@@ -369,6 +386,10 @@
         sourceComponent: viewFinderExportConfirmationComp
     }
 
+    PostProcessOperations {
+        id: postProcessOperations
+    }
+
     property alias viewFinderExportConfirmation: viewFinderExportConfirmationLoader.item
 
     Component {