dziemborowicz / hourglass

The simple countdown timer for Windows.
MIT License
631 stars 112 forks source link

Crash loop if Hourglass closed while full screen with no title option enabled #208

Closed dziemborowicz closed 2 years ago

dziemborowicz commented 2 years ago

The current development version of Hourglass at 71636240bcff8b09a1eda2f7472f661cb7fe945a crashes if the saved state indicates that the window should be full screen and have no title.

Repro steps:

  1. Delete all Hourglass settings.
  2. Launch Hourglass.
  3. Right-click and set "Advanced options" > "Window title" > "None".
  4. Right-click and set "Full screen".
  5. Right-click and "Close" to close Hourglass while it's still full screen.
  6. Relaunch Hourglass.
System.NullReferenceException: Object reference not set to an instance of an object.
   at System.Windows.Shell.WindowChromeWorker._ExtendGlassFrame()
   at System.Windows.Shell.WindowChromeWorker._UpdateFrameState(Boolean force)
   at System.Windows.Shell.WindowChromeWorker._ApplyNewCustomChrome()
   at System.Windows.Shell.WindowChromeWorker._WindowSourceInitialized(Object sender, EventArgs e)
   at System.Windows.Window.OnSourceInitialized(EventArgs e)
   at System.Windows.Window.CreateSourceWindow(Boolean duringShow)
   at System.Windows.Window.ShowHelper(Object booleanBox)
   at Hourglass.AppEntry.ShowNewTimerWindow(CommandLineArguments arguments) in C:\Users\Chris\Developer\hourglass\Hourglass\AppEntry.cs:line 136
   at Hourglass.AppEntry.ShowTimerWindowsForArguments(CommandLineArguments arguments) in C:\Users\Chris\Developer\hourglass\Hourglass\AppEntry.cs:line 122
   at Hourglass.AppEntry.<>c__DisplayClass3_0.<OnStartup>b__0(Object sender, StartupEventArgs args) in C:\Users\Chris\Developer\hourglass\Hourglass\AppEntry.cs:line 77
   at System.Windows.Application.OnStartup(StartupEventArgs e)
   at System.Windows.Application.<.ctor>b__1_0(Object unused)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.DispatcherOperation.InvokeImpl()
   at System.Threading.ExecutionContext.RunInternal(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean preserveSyncCtx)
   at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
   at MS.Internal.CulturePreservingExecutionContext.Run(CulturePreservingExecutionContext executionContext, ContextCallback callback, Object state)
   at System.Windows.Threading.DispatcherOperation.Invoke()
   at System.Windows.Threading.Dispatcher.ProcessQueue()
   at System.Windows.Threading.Dispatcher.WndProcHook(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
   at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
   at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
   at System.Windows.Application.RunDispatcher(Object ignore)
   at System.Windows.Application.RunInternal(Window window)
   at Hourglass.AppEntry.OnStartup(StartupEventArgs e) in C:\Users\Chris\Developer\hourglass\Hourglass\AppEntry.cs:line 80
   at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.DoApplicationModel()
   at Microsoft.VisualBasic.ApplicationServices.WindowsFormsApplicationBase.Run(String[] commandLine)
   at Hourglass.AppEntry.Main(String[] args) in C:\Users\Chris\Developer\hourglass\Hourglass\AppEntry.cs:line 51

Bisection shows that this was introduced by commit 1361c7f13293bed65e6b1113ce80804ce7b819ce.