-
Notifications
You must be signed in to change notification settings - Fork 1
Fix crop bug #71
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fix crop bug #71
Changes from all commits
a103105
fc90b1e
9ef5b22
4c2f57e
87fdb51
1f30ecc
ee7171f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -2021,39 +2021,39 @@ def _on_save_finished(self, save_result: dict): | |
| if save_result.get("started_from_restore_override"): | ||
| self._clear_variant_override() | ||
|
|
||
| # 2. Update variants and re-select index | ||
| # Refresh list to pick up new backup files and update variant map | ||
| self.refresh_image_list() | ||
| # Record current path to stay on it after refresh (since index may shift) | ||
| preserved_path = None | ||
| if 0 <= self.current_index < len(self.image_files): | ||
| preserved_path = self.image_files[self.current_index].path | ||
|
|
||
| # Find and re-select the saved image | ||
| new_index = self.current_index | ||
| # 1. Update sidecar metadata FIRST so all following refreshes see it | ||
| if saved_path: | ||
| self.sidecar.update_metadata(saved_path, {"edited": True}) | ||
|
Comment on lines
+2029
to
+2031
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Persist the full edited metadata and make it undoable. These writes only set Also applies to: 7376-7377, 7621-7622, 7717-7718, 7866-7867 🤖 Prompt for AI Agents |
||
|
|
||
| if saved_path: | ||
| target_key = self._key(saved_path) | ||
| for i, img in enumerate(self.image_files): | ||
| if self._key(img.path) == target_key: | ||
| new_index = i | ||
| break | ||
|
|
||
| self.current_index = new_index | ||
| # 2. Update variants and re-select index | ||
| self.refresh_image_list() | ||
|
|
||
| # Force UI Sync / Prefetch | ||
| if still_on_same_session: | ||
| # Still viewing the saved image — pin index and force sync | ||
| self._reindex_after_save(saved_path) | ||
| self.image_cache.clear() | ||
| self.prefetcher.cancel_all() | ||
| self.prefetcher.update_prefetch(self.current_index) | ||
| self.sync_ui_state() | ||
| else: | ||
| # User navigated away — clear stale cache entry | ||
| # User navigated away — re-find new index for preserved_path and drop stale cache | ||
| if preserved_path: | ||
| self._reindex_after_save(preserved_path) | ||
| if saved_path: | ||
| self.image_cache.pop_path(saved_path) | ||
|
|
||
| # Always emit badge update — backup file was created | ||
| if self.ui_state: | ||
| self.ui_state.variantBadgesChanged.emit() | ||
|
|
||
| self.update_status_message("Image saved") | ||
| else: | ||
| self.update_status_message("Failed to save image") | ||
| # Success reported but result shape unexpected | ||
| log.warning("Save finished with unexpected result shape: %r", result) | ||
|
Comment on lines
+2055
to
+2056
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Clear the stuck “Saving...” status on malformed success results. This branch only logs, so the UI can remain on the no-timeout Proposed fix else:
# Success reported but result shape unexpected
log.warning("Save finished with unexpected result shape: %r", result)
+ self.update_status_message(
+ "Save finished, but the result could not be processed.",
+ timeout=5000,
+ )🤖 Prompt for AI Agents |
||
|
|
||
| # --- Actions --- | ||
|
|
||
|
|
@@ -7373,6 +7373,9 @@ def execute_crop(self): | |
| ("crop", (str(saved_path), str(backup_path)), timestamp) | ||
| ) | ||
|
|
||
| # Mark as edited in sidecar | ||
| self.sidecar.update_metadata(saved_path, {"edited": True}) | ||
|
|
||
| # Exit crop mode | ||
| self.ui_state.isCropping = False | ||
| self.ui_state.currentCropBox = (0, 0, 1000, 1000) | ||
|
|
@@ -7615,6 +7618,12 @@ def quick_auto_levels(self): | |
| ("auto_levels", (saved_path, backup_path), timestamp) | ||
| ) | ||
|
|
||
| # 1. Update sidecar metadata FIRST so all following refreshes see it | ||
| self.sidecar.update_metadata(saved_path, {"edited": True}) | ||
|
|
||
| # 2. Update list and model to pick up changes | ||
| self.refresh_image_list() | ||
|
|
||
| # Force reload to ensure disk consistency | ||
| self.image_editor.clear() | ||
|
|
||
|
|
@@ -7704,6 +7713,10 @@ def _apply_auto_levels_at_index(self, index: int) -> bool: | |
| if save_result: | ||
| saved_path, backup_path = save_result | ||
| timestamp = time.time() | ||
|
|
||
| # Mark as edited in sidecar | ||
| self.sidecar.update_metadata(saved_path, {"edited": True}) | ||
|
|
||
| self.undo_history.append( | ||
| ("auto_levels", (saved_path, backup_path), timestamp) | ||
| ) | ||
|
|
@@ -7849,17 +7862,23 @@ def quick_auto_white_balance(self): | |
|
|
||
| if save_result: | ||
| saved_path, backup_path = save_result | ||
| # Track this action for undo | ||
| timestamp = time.time() | ||
| # 1. Update sidecar metadata FIRST so all following refreshes see it | ||
| self.sidecar.update_metadata(saved_path, {"edited": True}) | ||
|
|
||
| # 2. Update list and model to pick up changes | ||
| self.refresh_image_list() | ||
|
|
||
| # Re-derive current_index | ||
| self._reindex_after_save(saved_path) | ||
|
|
||
| self.undo_history.append( | ||
| ("auto_white_balance", (saved_path, backup_path), timestamp) | ||
| ) | ||
|
|
||
| # Force the image editor to clear its current state so it reloads fresh | ||
| self.image_editor.clear() | ||
|
|
||
| # Re-derive current_index (backup is excluded from visible list) | ||
| self._reindex_after_save(saved_path) | ||
| t_list = time.perf_counter() | ||
|
|
||
| # Invalidate cache for the edited image so it's reloaded from disk | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_on_save_finishednow unconditionally callsself.sidecar.update_metadata(saved_path, {"edited": True}), butsave_edited_imageexplicitly allows users to keep navigating while the background save runs, and_switch_to_directoryreplacesself.sidecarwhen folders change. If a save started in folder A finishes after the user moved to folder B, this line writes an absolute-key metadata entry into folder B’sfaststack.jsoninstead of updating folder A, which corrupts sidecar data and leaves the actual saved image unmarked in its own folder.Useful? React with 👍 / 👎.