Fix ImageCropper crash and resource leaks#1530
Conversation
Return the cropped bitmap as a stand-alone copy instead of round-tripping through a MemoryStream that had to outlive it; unsubscribe the disposed Application.Idle handler; dispose and null out prior image state before re-assignment; and fix a height-vs-width typo that skipped downscaling of tall images. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Palaso Tests 4 files ± 0 4 suites ±0 10m 9s ⏱️ +31s Results for commit 384aae8. ± Comparison against base commit ba68a4a. This pull request removes 1 and adds 7 tests. Note that renamed tests count towards both.♻️ This comment has been updated with latest results. |
ShowToolboxWith_PreExisting_EnsureRawFormatUnchanged asserted that cropping preserves the original RawFormat, which no longer holds now that GetCroppedImage intentionally returns a stand-alone bitmap. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
Claude summary of a Devin flag In the Claude rebuttal Reaching that state requires |
…ea fix (BL-1275) Strengthen the double-dispose and reassignment tests to actually exercise and verify cleanup (temp file and cropping image disposal) instead of only asserting no exception is thrown, and add a regression test for the height/width downscaling typo. Add the missing CHANGELOG entry for the null-guard in CalculateSourceImageArea, and trim stale comments in GetCroppedImage describing the removed JPEG re-encoding approach. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
| // without disposing the previous instances, leaking the temp file and the cropping bitmap. | ||
| Assert.That(File.Exists(firstSavedOriginalPath), Is.False, | ||
| "Previous saved-original temp file should have been disposed (and deleted) on reassignment"); | ||
| Assert.Throws<ArgumentException>(() => { var _ = firstCroppingImage.Width; }, |
Return the cropped bitmap as a stand-alone copy instead of round-tripping through a MemoryStream that had to outlive it; unsubscribe the disposed Application.Idle handler; dispose and null out prior image state before re-assignment; and fix a height-vs-width typo that skipped downscaling of tall images.
Fixes #1275
Devin review: https://app.devin.ai/review/sillsdev/libpalaso/pull/1530
This change is