greenshot / greenshot

Greenshot for Windows - Report bugs & features go here: https://greenshot.atlassian.net or look for information on:
https://getgreenshot.org
GNU General Public License v3.0
4k stars 578 forks source link

error on duplicating an ellipse #322

Closed mischlrebl closed 3 years ago

mischlrebl commented 3 years ago

happens with ellipses (normal, circle round) directly after selecting the tool as well as when selecting later (after other tools). does NOT happen with all other shapes: r, l, a, f, t, s

Software version: 1.3.205 - 3350120b55 (64 bit) .NET runtime version: 4.0.30319.42000+ Time: 2021-07-05 14:19:54 +02:00 OS: Windows 10 1909 x64 build 18363 GDI object count: 137 User object count: 88

Exception: System.InvalidOperationException Message: Sequence contains no elements

Stack: at System.Linq.Enumerable.Max(IEnumerable`1 source) at Greenshot.Editor.Drawing.DrawableContainer.get_DrawingBounds() in D:\a\1\s\src\Greenshot.Editor\Drawing\DrawableContainer.cs:line 321 at Greenshot.Editor.Drawing.DrawableContainerList.Invalidate() in D:\a\1\s\src\Greenshot.Editor\Drawing\DrawableContainerList.cs:line 362 at Greenshot.Editor.Drawing.DrawableContainerList.MoveBy(Int32 dx, Int32 dy) in D:\a\1\s\src\Greenshot.Editor\Drawing\DrawableContainerList.cs:line 180 at Greenshot.Editor.Drawing.Surface.DuplicateSelectedElements() in D:\a\1\s\src\Greenshot.Editor\Drawing\Surface.cs:line 2041 at Greenshot.Editor.Forms.ImageEditorForm.DuplicateToolStripMenuItemClick(Object sender, EventArgs e) in D:\a\1\s\src\Greenshot.Editor\Forms\ImageEditorForm.cs:line 819 at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e) at System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e) at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e) at System.Windows.Forms.ToolStripMenuItem.ProcessCmdKey(Message& m, Keys keyData) at System.Windows.Forms.ToolStripManager.ProcessShortcut(Message& m, Keys shortcut) at System.Windows.Forms.Form.ProcessCmdKey(Message& msg, Keys keyData) at System.Windows.Forms.Control.ProcessCmdKey(Message& msg, Keys keyData) at System.Windows.Forms.ContainerControl.ProcessCmdKey(Message& msg, Keys keyData) at System.Windows.Forms.Control.ProcessCmdKey(Message& msg, Keys keyData) at System.Windows.Forms.Control.ProcessCmdKey(Message& msg, Keys keyData) at System.Windows.Forms.Control.ProcessCmdKey(Message& msg, Keys keyData) at System.Windows.Forms.Control.ProcessCmdKey(Message& msg, Keys keyData) at System.Windows.Forms.Control.PreProcessMessage(Message& msg) at System.Windows.Forms.Control.PreProcessControlMessageInternal(Control target, Message& msg) at System.Windows.Forms.Application.ThreadContext.PreTranslateMessage(MSG& msg)

Configuration dump:

mischlrebl commented 3 years ago

same with h Highlight tool

Software version: 1.3.206 - e9d1e278e6 (64 bit) .NET runtime version: 4.0.30319.42000+ Time: 2021-08-18 10:27:07 +02:00 OS: Windows 10 2004 x64 build 19041 GDI object count: 143 User object count: 104

Exception: System.InvalidOperationException Message: Sequence contains no elements

Stack: at System.Linq.Enumerable.Max(IEnumerable`1 source) at Greenshot.Editor.Drawing.DrawableContainer.get_DrawingBounds() in C:\projects\greenshot\src\Greenshot.Editor\Drawing\DrawableContainer.cs:line 321 at Greenshot.Editor.Drawing.DrawableContainerList.Invalidate() in C:\projects\greenshot\src\Greenshot.Editor\Drawing\DrawableContainerList.cs:line 363 at Greenshot.Editor.Drawing.DrawableContainerList.MoveBy(Int32 dx, Int32 dy) in C:\projects\greenshot\src\Greenshot.Editor\Drawing\DrawableContainerList.cs:line 181 at Greenshot.Editor.Drawing.Surface.DuplicateSelectedElements() in C:\projects\greenshot\src\Greenshot.Editor\Drawing\Surface.cs:line 2041 at Greenshot.Editor.Forms.ImageEditorForm.DuplicateToolStripMenuItemClick(Object sender, EventArgs e) in C:\projects\greenshot\src\Greenshot.Editor\Forms\ImageEditorForm.cs:line 819 at System.Windows.Forms.ToolStripItem.RaiseEvent(Object key, EventArgs e) at System.Windows.Forms.ToolStripMenuItem.OnClick(EventArgs e) at System.Windows.Forms.ToolStripItem.HandleClick(EventArgs e) at System.Windows.Forms.ToolStripMenuItem.ProcessCmdKey(Message& m, Keys keyData) at System.Windows.Forms.ToolStripManager.ProcessShortcut(Message& m, Keys shortcut) at System.Windows.Forms.Form.ProcessCmdKey(Message& msg, Keys keyData) at System.Windows.Forms.Control.ProcessCmdKey(Message& msg, Keys keyData) at System.Windows.Forms.ContainerControl.ProcessCmdKey(Message& msg, Keys keyData) at System.Windows.Forms.Control.ProcessCmdKey(Message& msg, Keys keyData) at System.Windows.Forms.Control.ProcessCmdKey(Message& msg, Keys keyData) at System.Windows.Forms.Control.ProcessCmdKey(Message& msg, Keys keyData) at System.Windows.Forms.Control.ProcessCmdKey(Message& msg, Keys keyData) at System.Windows.Forms.Control.PreProcessMessage(Message& msg) at System.Windows.Forms.Control.PreProcessControlMessageInternal(Control target, Message& msg) at System.Windows.Forms.Application.ThreadContext.PreTranslateMessage(MSG& msg)

Configuration dump:

Ishmaeel commented 3 years ago

This happens because Adorners are not created for Ellipses after deserialization. The cloned DrawableContainer will have zero adorners which will trigger this Linq error.

Looks like a simple fix, I'll be submitting a PR soon, if anybody is not already working on it.

Lakritzator commented 3 years ago

https://github.com/greenshot/greenshot/releases/tag/v1.3.211

mischlrebl commented 3 years ago

thanks a lot for your efforts!

mischlrebl commented 3 years ago

tested with 1.3.218, works now, thank you again

@Lakritzator somehow it is not mentioned in the stability fixes section of the release notes

Lakritzator commented 3 years ago

I know it's not in the release notes, the notes are for the differences between 1.2 and 1.3. But I will mention @Ishmaeel in the notes, to thank him for his support fixing it, it was his work.