Fix Ellipse and Highlight duplication bug (#322). (#331)

Fixes #322.

Ellipse only created default adorners in constructor, never after deserialization. Having zero adorners triggered a Linq exception down the code path. Fixed by duplicating the deserialization logic from RectangleContainer.

Highlight also failed to create its default adorners. Fixed by just adding a correct call to CreateDefaultAdorners call in the existing Init method.
This commit is contained in:
Ishmaeel 2021-10-02 21:56:46 +03:00 committed by GitHub
commit f71499c9c6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 13 additions and 0 deletions

View file

@ -22,6 +22,7 @@
using System; using System;
using System.Drawing; using System.Drawing;
using System.Drawing.Drawing2D; using System.Drawing.Drawing2D;
using System.Runtime.Serialization;
using Greenshot.Base.Interfaces.Drawing; using Greenshot.Base.Interfaces.Drawing;
using Greenshot.Editor.Drawing.Fields; using Greenshot.Editor.Drawing.Fields;
using Greenshot.Editor.Helpers; using Greenshot.Editor.Helpers;
@ -35,6 +36,17 @@ namespace Greenshot.Editor.Drawing
public class EllipseContainer : DrawableContainer public class EllipseContainer : DrawableContainer
{ {
public EllipseContainer(Surface parent) : base(parent) public EllipseContainer(Surface parent) : base(parent)
{
Init();
}
protected override void OnDeserialized(StreamingContext streamingContext)
{
base.OnDeserialized(streamingContext);
Init();
}
private void Init()
{ {
CreateDefaultAdorners(); CreateDefaultAdorners();
} }

View file

@ -56,6 +56,7 @@ namespace Greenshot.Editor.Drawing
{ {
FieldChanged += HighlightContainer_OnFieldChanged; FieldChanged += HighlightContainer_OnFieldChanged;
ConfigurePreparedFilters(); ConfigurePreparedFilters();
CreateDefaultAdorners();
} }
protected void HighlightContainer_OnFieldChanged(object sender, FieldChangedEventArgs e) protected void HighlightContainer_OnFieldChanged(object sender, FieldChangedEventArgs e)