diff --git a/CHANGELOG.md b/CHANGELOG.md index a5c0342f2..dfdf2ca08 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -46,6 +46,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/). - [SIL.Windows.Forms] Updated ImageToolbox UI to consistently use "image" (not "picture"). - [SIL.Windows.Forms.Keyboarding] Removed Timer-based deferred IME conversion status restore from WindowsKeyboardSwitchingAdapter, which disrupted active Chinese Pinyin IME compositions (LT-22442). Added diagnostic tracing for keyboard switching and IME state. - [SIL.DictionaryServices] Fix memory leak in LiftWriter +- [SIL.Windows.Forms] Fixed ImageCropper crash caused by its `Application.Idle` handler never being unsubscribed, so it could fire on a disposed instance - [SIL.Windows.Forms] Fixed ImageCropper not downscaling tall images before cropping (height condition was checking width) - [SIL.WritingSystems] Fix IetfLanguageTag.GetGeneralCode to handle cases when zh-CN or zh-TW is a prefix and not the whole string. - [SIL.WritingSystems] More fixes to consistently use 繁体中文 and 简体中文 for Traditional and Simplified Chinese native language names, and Chinese (Traditional) and Chinese (Simplified) for their English names. diff --git a/SIL.Windows.Forms.Tests/ImageToolbox/ImageCropperTests.cs b/SIL.Windows.Forms.Tests/ImageToolbox/ImageCropperTests.cs index 332b78d9e..238d7dba2 100644 --- a/SIL.Windows.Forms.Tests/ImageToolbox/ImageCropperTests.cs +++ b/SIL.Windows.Forms.Tests/ImageToolbox/ImageCropperTests.cs @@ -13,6 +13,26 @@ namespace SIL.Windows.Forms.Tests.ImageToolbox [TestFixture] public class ImageCropperTests { + [Test] + public void Dispose_CalledTwiceAfterSettingImage_DoesNotThrow() + { + using (var tempFile = TempFile.WithExtension(".png")) + { + using (var bmp = new Bitmap(100, 80)) + bmp.Save(tempFile.Path, ImageFormat.Png); + + using (var palasoImage = PalasoImage.FromFile(tempFile.Path)) + { + var cropper = new ImageCropper(); + cropper.Size = new Size(400, 300); + cropper.SetImage(palasoImage); + + Assert.DoesNotThrow(() => cropper.Dispose()); + Assert.DoesNotThrow(() => cropper.Dispose()); + } + } + } + [Test] public void SetImage_TallImage_DownscalesCroppingImage() { diff --git a/SIL.Windows.Forms/ImageToolbox/Cropping/ImageCropper.cs b/SIL.Windows.Forms/ImageToolbox/Cropping/ImageCropper.cs index 12205b807..5f816aa8c 100644 --- a/SIL.Windows.Forms/ImageToolbox/Cropping/ImageCropper.cs +++ b/SIL.Windows.Forms/ImageToolbox/Cropping/ImageCropper.cs @@ -482,6 +482,8 @@ protected override void Dispose(bool disposing) components = null; } + Application.Idle -= Application_Idle; + try { if (_savedOriginalImage != null)