Skip to content

Commit

Permalink
Fix issue when clearing non-existing photo ref
Browse files Browse the repository at this point in the history
  • Loading branch information
tomasMizera committed May 24, 2024
1 parent 50a86f8 commit 117db08
Showing 1 changed file with 11 additions and 12 deletions.
23 changes: 11 additions & 12 deletions app/qml/form/editors/MMFormPhotoEditor.qml
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,8 @@ MMFormPhotoViewer {
photoUrl: internal.absoluteImagePath
hasCameraCapability: __androidUtils.isAndroid || __iosUtils.isIos

on_FieldValueChanged: internal.calculateAbsoluteImagePath()
on_FieldValueChanged: internal.setAbsoluteImagePath()
on_FieldValueIsNullChanged: internal.setAbsoluteImagePath()

onCapturePhotoClicked: internal.capturePhoto()
onChooseFromGalleryClicked: internal.chooseFromGallery()
Expand Down Expand Up @@ -200,27 +201,25 @@ MMFormPhotoViewer {

property string imageSourceToDelete // used to postpone image deletion to when the form is saved

function calculateAbsoluteImagePath() {
//
// Sets path of the assigned photo to the absoluteImagePath.
// - absoluteImagePath is the actual path on the device and is used by QML Image to show the image
//
function setAbsoluteImagePath() {
let absolutePath = __inputUtils.getAbsolutePath( root._fieldValue, internal.prefixToRelativePath )

if ( root.photoComponent.status === Image.Error ) {
root.photoState = "notAvailable"
if ( !root._fieldValue || root._fieldValueIsNull ) {
root.photoState = "notSet"
absoluteImagePath = ""
return
}
else if ( root._fieldValue && __inputUtils.fileExists( absolutePath ) ) {
root.photoState = "valid"
absoluteImagePath = "file://" + absolutePath
return
}
else if ( !root._fieldValue || root._fieldValueIsNullfield ) {
root.photoState = "notSet"
else {
root.photoState = "notAvailable"
absoluteImagePath = ""
return
}

root.photoState = "notAvailable"
absoluteImagePath = "file://" + absolutePath
}

/**
Expand Down

1 comment on commit 117db08

@inputapp-bot
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

iOS - version 24.5.623811 just submitted!

Please sign in to comment.