NickeManarin / ScreenToGif

🎬 ScreenToGif allows you to record a selected area of your screen, edit and save it as a gif or video.
http://www.screentogif.com
Microsoft Public License
23.06k stars 2.15k forks source link

[Bug] Unhandled Exception: "Cannot set visibility or call Show, ShowDialog ... after a Window has closed" #1243

Open Emxm3 opened 8 months ago

Emxm3 commented 8 months ago

Describe the bug Stopping a recording when the recorders window is not shown throws an unhandled exception

To Reproduce Steps to reproduce the behavior:

  1. Go to "Options" > "Recorder" > [ X ] Enable selection panning
  2. Set a shortcut key to enable panning while recording.
  3. Move the mouse in a way that moves the window's location to a new location (this makes the window disappear until the mouse stops).
  4. As the window disappears, quickly press F8 (stops recording)
  5. An error will be thrown. recording is fine and no data is lost, but is a bit of an annoyance

Expected behavior Recording should stop and application flow should continue as normal with no unexpected pop-ups

Screenshots image

Desktop (please complete the following information):

Additional context

System.InvalidOperationException: Cannot set Visibility or call Show, ShowDialog, or WindowInteropHelper.EnsureHandle after a Window has closed.
   at System.Windows.Window.VerifyCanShow()
   at System.Windows.Window.Show()
   at ScreenToGif.Windows.Other.RegionSelection.Select(Nullable`1 mode, Rect region, Monitor monitor) in C:\Users\nicke\source\repos\ScreenToGif\ScreenToGif\Windows\Other\RegionSelection.xaml.cs:line 197
   at ScreenToGif.Windows.NewRecorder.DisplaySelection(Nullable`1 mode, Monitor display) in C:\Users\nicke\source\repos\ScreenToGif\ScreenToGif\Windows\NewRecorder.xaml.cs:line 1483
   at ScreenToGif.Windows.NewRecorder.ShowBorderTimer_Tick(Object sender, EventArgs e) in C:\Users\nicke\source\repos\ScreenToGif\ScreenToGif\Windows\NewRecorder.xaml.cs:line 717
   at System.Windows.Forms.Timer.TimerNativeWindow.WndProc(Message& m)
   at System.Windows.Forms.NativeWindow.Callback(IntPtr hWnd, WM msg, IntPtr wparam, IntPtr lparam)