adventuregamestudio / ags

AGS editor and engine source code
Other
701 stars 160 forks source link

Error when restoring editor window #781

Closed alkhimey closed 1 year ago

alkhimey commented 5 years ago

AGS 4.3.4

I get the error when minimising and restoring the editor window. Started after importing a TTF font. I discarded the changes and restarted editor. Could not reproduce after that.

Also notice that error reporting is not working (can open separate issue if required)

ags_error1 ags_error2

Error: Parameter is not valid. Version: AGS 3.4.3.1

System.ArgumentException: Parameter is not valid. at System.Drawing.Bitmap..ctor(Int32 width, Int32 height, PixelFormat format) at System.Drawing.Bitmap..ctor(Int32 width, Int32 height) at AGS.Editor.FontEditor.PaintFont() at AGS.Editor.FontEditor.imagePanel_SizeChanged(Object sender, EventArgs e) at System.Windows.Forms.Control.OnSizeChanged(EventArgs e) at System.Windows.Forms.Control.UpdateBounds(Int32 x, Int32 y, Int32 width, Int32 height, Int32 clientWidth, Int32 clientHeight) at System.Windows.Forms.Control.UpdateBounds(Int32 x, Int32 y, Int32 width, Int32 height) at System.Windows.Forms.Control.SetBoundsCore(Int32 x, Int32 y, Int32 width, Int32 height, BoundsSpecified specified) at System.Windows.Forms.Control.System.Windows.Forms.Layout.IArrangedElement.SetBounds(Rectangle bounds, BoundsSpecified specified) at System.Windows.Forms.Layout.DefaultLayout.ApplyCachedBounds(IArrangedElement container) at System.Windows.Forms.Layout.DefaultLayout.xLayout(IArrangedElement container, Boolean measureOnly, Size& preferredSize) at System.Windows.Forms.Layout.DefaultLayout.LayoutCore(IArrangedElement container, LayoutEventArgs args) at System.Windows.Forms.Layout.LayoutEngine.Layout(Object container, LayoutEventArgs layoutEventArgs) at System.Windows.Forms.Control.OnLayout(LayoutEventArgs levent) at System.Windows.Forms.Control.PerformLayout(LayoutEventArgs args) at System.Windows.Forms.Control.System.Windows.Forms.Layout.IArrangedElement.PerformLayout(IArrangedElement affectedElement, String affectedProperty) at System.Windows.Forms.Layout.LayoutTransaction.DoLayout(IArrangedElement elementToLayout, IArrangedElement elementCausingLayout, String property) at System.Windows.Forms.Control.OnResize(EventArgs e) at System.Windows.Forms.Control.OnSizeChanged(EventArgs e) at System.Windows.Forms.Control.UpdateBounds(Int32 x, Int32 y, Int32 width, Int32 height, Int32 clientWidth, Int32 clientHeight) at System.Windows.Forms.Control.UpdateBounds(Int32 x, Int32 y, Int32 width, Int32 height) at System.Windows.Forms.Control.SetBoundsCore(Int32 x, Int32 y, Int32 width, Int32 height, BoundsSpecified specified) at System.Windows.Forms.Control.System.Windows.Forms.Layout.IArrangedElement.SetBounds(Rectangle bounds, BoundsSpecified specified) at System.Windows.Forms.Layout.DefaultLayout.ApplyCachedBounds(IArrangedElement container) at System.Windows.Forms.Layout.DefaultLayout.xLayout(IArrangedElement container, Boolean measureOnly, Size& preferredSize) at System.Windows.Forms.Layout.DefaultLayout.LayoutCore(IArrangedElement container, LayoutEventArgs args) at System.Windows.Forms.Layout.LayoutEngine.Layout(Object container, LayoutEventArgs layoutEventArgs) at System.Windows.Forms.Control.OnLayout(LayoutEventArgs levent) at System.Windows.Forms.ScrollableControl.OnLayout(LayoutEventArgs levent) at System.Windows.Forms.ContainerControl.OnLayout(LayoutEventArgs e) at System.Windows.Forms.Control.PerformLayout(LayoutEventArgs args) at System.Windows.Forms.Control.System.Windows.Forms.Layout.IArrangedElement.PerformLayout(IArrangedElement affectedElement, String affectedProperty) at System.Windows.Forms.Layout.LayoutTransaction.DoLayout(IArrangedElement elementToLayout, IArrangedElement elementCausingLayout, String property) at System.Windows.Forms.Control.OnResize(EventArgs e) at System.Windows.Forms.UserControl.OnResize(EventArgs e) at System.Windows.Forms.Control.OnSizeChanged(EventArgs e) at System.Windows.Forms.Control.UpdateBounds(Int32 x, Int32 y, Int32 width, Int32 height, Int32 clientWidth, Int32 clientHeight) at System.Windows.Forms.Control.UpdateBounds(Int32 x, Int32 y, Int32 width, Int32 height) at System.Windows.Forms.Control.SetBoundsCore(Int32 x, Int32 y, Int32 width, Int32 height, BoundsSpecified specified) at System.Windows.Forms.Control.System.Windows.Forms.Layout.IArrangedElement.SetBounds(Rectangle bounds, BoundsSpecified specified) at System.Windows.Forms.Layout.DefaultLayout.xLayoutDockedControl(IArrangedElement element, Rectangle newElementBounds, Boolean measureOnly, Size& preferredSize, Rectangle& remainingBounds) at System.Windows.Forms.Layout.DefaultLayout.LayoutDockedControls(IArrangedElement container, Boolean measureOnly) at System.Windows.Forms.Layout.DefaultLayout.xLayout(IArrangedElement container, Boolean measureOnly, Size& preferredSize) at System.Windows.Forms.Layout.DefaultLayout.LayoutCore(IArrangedElement container, LayoutEventArgs args) at System.Windows.Forms.Layout.LayoutEngine.Layout(Object container, LayoutEventArgs layoutEventArgs) at System.Windows.Forms.Control.OnLayout(LayoutEventArgs levent) at System.Windows.Forms.ScrollableControl.OnLayout(LayoutEventArgs levent) at System.Windows.Forms.Form.OnLayout(LayoutEventArgs levent) at System.Windows.Forms.Control.PerformLayout(LayoutEventArgs args) at System.Windows.Forms.Control.System.Windows.Forms.Layout.IArrangedElement.PerformLayout(IArrangedElement affectedElement, String affectedProperty) at System.Windows.Forms.Layout.LayoutTransaction.DoLayout(IArrangedElement elementToLayout, IArrangedElement elementCausingLayout, String property) at System.Windows.Forms.Control.OnResize(EventArgs e) at System.Windows.Forms.Form.OnResize(EventArgs e) at System.Windows.Forms.Control.OnSizeChanged(EventArgs e) at WeifenLuo.WinFormsUI.Docking.DockContent.OnSizeChanged(EventArgs e) at System.Windows.Forms.Control.UpdateBounds(Int32 x, Int32 y, Int32 width, Int32 height, Int32 clientWidth, Int32 clientHeight) at System.Windows.Forms.Control.UpdateBounds(Int32 x, Int32 y, Int32 width, Int32 height) at System.Windows.Forms.Control.SetBoundsCore(Int32 x, Int32 y, Int32 width, Int32 height, BoundsSpecified specified) at System.Windows.Forms.Form.SetBoundsCore(Int32 x, Int32 y, Int32 width, Int32 height, BoundsSpecified specified) at System.Windows.Forms.Control.SetBounds(Int32 x, Int32 y, Int32 width, Int32 height, BoundsSpecified specified) at System.Windows.Forms.Control.set_Bounds(Rectangle value) at WeifenLuo.WinFormsUI.Docking.DockPane.SetContentBounds() at WeifenLuo.WinFormsUI.Docking.DockPane.OnLayout(LayoutEventArgs levent) at System.Windows.Forms.Control.PerformLayout(LayoutEventArgs args) at System.Windows.Forms.Control.System.Windows.Forms.Layout.IArrangedElement.PerformLayout(IArrangedElement affectedElement, String affectedProperty) at System.Windows.Forms.Layout.LayoutTransaction.DoLayout(IArrangedElement elementToLayout, IArrangedElement elementCausingLayout, String property) at System.Windows.Forms.Control.OnResize(EventArgs e) at System.Windows.Forms.UserControl.OnResize(EventArgs e) at System.Windows.Forms.Control.OnSizeChanged(EventArgs e) at System.Windows.Forms.Control.UpdateBounds(Int32 x, Int32 y, Int32 width, Int32 height, Int32 clientWidth, Int32 clientHeight) at System.Windows.Forms.Control.UpdateBounds() at System.Windows.Forms.Control.WmWindowPosChanged(Message& m) at System.Windows.Forms.Control.WndProc(Message& m) at System.Windows.Forms.ScrollableControl.WndProc(Message& m) at System.Windows.Forms.ContainerControl.WndProc(Message& m) at System.Windows.Forms.UserControl.WndProc(Message& m) at WeifenLuo.WinFormsUI.Docking.DockPane.WndProc(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.OnMessage(Message& m) at System.Windows.Forms.Control.ControlNativeWindow.WndProc(Message& m) at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)

ivan-mogilko commented 1 year ago

This is old...

From the call stack it looks like a problem with the Font preview, specifically in FontEditor.PaintFont().

I'd rather give this a quick look to see if it's possible to reproduce at least artificially (by emulating incorrect parameters); and add some safety checks there. Given this was not repeating for the user, and we dont get reports like this often, it's not worth spending too much time on this (also Font preview may have to be rewritten after we support Unicode)

ivan-mogilko commented 1 year ago

Hmm, I think I've already added the least of the safety fixes recently: 54a8a38882fd3633c472f62079e72873bba40f40 could be that was done for this ticket, but I forgot to close.