Bugfix/fix reuse last entered value - #4668
Open
xkello wants to merge 4 commits into
Open
Conversation
📦 Build Artifacts Ready
|
Coverage Report for CI Build 32851633524Warning No base build found for commit Coverage: 59.064%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsRequires a base build to compare against. How to fix this → Coverage Stats
💛 - Coveralls |
📦 Build Artifacts Ready
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Fixes a bug where enabling "Use last entered value" on a photo/file field causes the previous feature's photo file to be corrupted, renamed, or orphaned when reused by a new feature - most visibly when a custom filename expression is set in QGIS, where the previous feature's file gets physically renamed and reassigned to the new feature, leaving the previous feature with a broken/missing image.
Fixes: #4487
What changed
AttributeController::updateOnFeatureChange()now clones the underlying file when a photo/file field's value is reused, instead of just copying the path string. Each feature gets its own independent file from the moment the drawer opens, so it's never possible for two features to end up sharing (and therefore corrupting) the same photo.FormItem(isReusedValue(),reusedCopyPath()) so it can be cleaned up if it's never actually needed:AttributeController::discardReusedPhotoCopies()deletes it if the draft feature is discarded (cancel/rollback), or if the photo is deleted or replaced before the feature is saved.renamePhotos()now evaluates the project's custom filename expression fresh against the clone (instead of skipping reused fields entirely), so a reused photo gets a correctly computed, per-feature filename rather than a generic incremented name. A static expression that collides with an existing file still gets a proper incremental suffix.recalculateDefaultValues()no longer lets a QGIS field-level Default Value expression overwrite a value that was just populated by "reuse last entered value" while the form is open.InputUtils::resolveTargetDir()now resolves a relative root path expression/Default Path against the project home path. Previously a relative path (e.g.'photos/' + @layer_name) was used as-is, which could resolve to the wrong location on disk and produce a broken/missing image.MMActivity.importImage) and iOS (IOSGalleryPickerDelegate) gallery import now create the destination directory before copying the picked image, matching what capture-from-camera already did.Behaviour
TLDR @Withalion
"Use last entered value" on a photo field now clones the file per feature instead of sharing/renaming the original, so reused photos never corrupt or orphan another feature's image, on save or on cancel.