Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## [Unreleased]

### Fixed
- [SIL.Windows.Forms] Prevent BetterLabel from responding to OnTextChanged when it has been disposed.

### Changed

- [SIL.Windows.Forms] BREAKING CHANGE: Upgraded to L10nSharp v9. Any clients which also use L10nSharp must also upgrade to v9.
Expand Down
6 changes: 5 additions & 1 deletion SIL.Windows.Forms/Widgets/BetterLabel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -134,9 +134,11 @@ protected override void OnParentChanged(EventArgs e)

protected override void OnTextChanged(EventArgs e)
{
if (IsDisposed)
return; // This has happened in Bloom (BL-15424) and caused a crash.
//this is apparently dangerous to do in the constructor
//Font = new Font(SystemFonts.MessageBoxFont.FontFamily, Font.Size, Font.Style);
if(Font==SystemFonts.DefaultFont)
if (Font==SystemFonts.DefaultFont)
Font = SystemFonts.MessageBoxFont;//sets the default, which can then be customized in the designer

DetermineHeight();
Expand All @@ -145,6 +147,8 @@ protected override void OnTextChanged(EventArgs e)

private void DetermineHeight()
{
if (IsDisposed)
return; // This has happened in Bloom (BL-15424) and caused a crash.
using (var g = this.CreateGraphics())
{
// Use this rather than MeasureString, which uses the obsolete GDI+ and can crash on some
Expand Down
Loading