Screentogif: Recent change in ApplicationViewModel closes the app with error 2

Created on 10 Aug 2018  路  5Comments  路  Source: NickeManarin/ScreenToGif

There is a recent change in the ApplicationViewModel file that is checking if the current window is loaded; if not, it closes the application. This is preventing the editor from opening on my computer.

Previous code:

if (Application.Current.Windows.Count == 0)
  Application.Current.Shutdown(2);

New code:

if (Application.Current.Windows.Cast<Window>().Where(window => window.IsLoaded && window.HasContent).Count() == 0)
  Application.Current.Shutdown(2);

I believe that change should be reverted.

Commit: https://github.com/vmrocha/ScreenToGif/commit/3e0076a875f511445c05b047cc29948def7d6220

馃悶 bug

Most helpful comment

Changing the code to:

if (Application.Current.Windows.Cast<Window>().Count(window => window.HasContent) == 0)
    Application.Current.Shutdown(2);

fixed the issue on my computer.

Window Version: 10.0.16299 Build 16299
.NET Framework Version installed: 4.7.02556

All 5 comments

Thank you for finding it out what is happening!

In a few hours, I'll release a new version with this fix.
(v2.14.1)

I got a feedback from another user that has a Windows 7 machine with the same problem.
I could not get to reproduce this bug with my computer (with Windows 10).

I'm running Windows 10.

I believe that the person who wrote the new code wanted to check if the window that loaded had no content. On my computer, the Editor window has content, but it didn't finish loading yet.

I changed that code because in my case (Windows 10) the app didn't close even after all windows were closed. Why? Because there actually were abstract windows (like Adorner): they don't have content.

I think the best solution would be to change window => window.IsLoaded && window.HasContent to just window => window.HasContent. I can't test that now, but I think it makes sense.

Changing the code to:

if (Application.Current.Windows.Cast<Window>().Count(window => window.HasContent) == 0)
    Application.Current.Shutdown(2);

fixed the issue on my computer.

Window Version: 10.0.16299 Build 16299
.NET Framework Version installed: 4.7.02556

Was this page helpful?
0 / 5 - 0 ratings