Skip to content

Commit

Permalink
fix winforms shutdown crashes
Browse files Browse the repository at this point in the history
  • Loading branch information
ctacke committed Feb 13, 2024
1 parent 9e16609 commit 7b6085d
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 12 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public virtual bool IsVisible
/// <summary>
/// Gets or sets the left coordinate of the control.
/// </summary>
public int Left
public virtual int Left
{
get => _left;
set => SetInvalidatingProperty(ref _left, value);
Expand All @@ -88,7 +88,7 @@ public int Left
/// <summary>
/// Gets or sets the top coordinate of the control.
/// </summary>
public int Top
public virtual int Top
{
get => _top;
set => SetInvalidatingProperty(ref _top, value);
Expand All @@ -97,7 +97,7 @@ public int Top
/// <summary>
/// Gets or sets the width of the control.
/// </summary>
public int Width
public virtual int Width
{
get => _width;
set => SetInvalidatingProperty(ref _width, value);
Expand All @@ -106,7 +106,7 @@ public int Width
/// <summary>
/// Gets or sets the height of the control.
/// </summary>
public int Height
public virtual int Height
{
get => _height;
set => SetInvalidatingProperty(ref _height, value);
Expand All @@ -115,12 +115,12 @@ public int Height
/// <summary>
/// Gets the bottom coordinate of the control.
/// </summary>
public int Bottom => Top + Height;
public virtual int Bottom => Top + Height;

/// <summary>
/// Gets the right coordinate of the control.
/// </summary>
public int Right => Left + Width;
public virtual int Right => Left + Width;

/// <summary>
/// Refreshes the control by redrawing it on the specified <see cref="MicroGraphics"/> surface.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,15 +87,26 @@ protected override void OnClick(EventArgs e)
/// </summary>
void IPixelDisplay.Show()
{
this.Invalidate(true);
if (this.IsDisposed)
{
return;
}

if (InvokeRequired)
try
{
Invoke(Update);
this.Invalidate(true);
if (InvokeRequired)
{
Invoke(Update);
}
else
{
this.Update();
}
}
else
catch (ObjectDisposedException)
{
this.Update();
// NOP - can happen when quitting application
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,9 +108,13 @@ public void Fill(int originX, int originY, int width, int height, Color color)
}
}
}
catch (ArgumentException)
{
// NOP - can happen on app shutdown
}
catch (InvalidOperationException)
{
// NOP
// NOP - can happen on app shutdown
}
}

Expand Down

0 comments on commit 7b6085d

Please sign in to comment.