Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Images won't open in config.xml presence #765

Closed
siomekziomek opened this issue Apr 30, 2020 · 7 comments · Fixed by #783
Closed

Images won't open in config.xml presence #765

siomekziomek opened this issue Apr 30, 2020 · 7 comments · Fixed by #783

Comments

@siomekziomek
Copy link

System information:

  • Windows OS version: Windows 10 v1909
  • ImageGlass version: 7.6.4.30

To Reproduce

  1. Create folder with image file associated with IG and .xml file named "config" at the same location.
  2. Try to open the image.

Actual behavior:

Nothing happens, IG won't start. But if xml file is deleted or renamed, image opens in IG with no problem.

Expected behavior:

IG should start.

Additional context:

"RMB -> Open with -> ImageGlass" works nonetheless.

@d2phap
Copy link
Owner

d2phap commented Apr 30, 2020

I just tried, ImageGlass can still open.
Can you give more details or steps?

Thank you

image

@siomekziomek
Copy link
Author

Sorry, I don't know what else to say. It behaves exactly like I said. When I try to open the image, cursor just thinks for a second and that's it. I tried with different locations, folder contents, image types, config contents (it can even be empty file), no difference. And once config is renamed, moved or deleted, image opens immidiately.

obraz

@siomekziomek
Copy link
Author

Hmmm, it works in presence of IG theme config though. If I had to guess, I'd say IG confuses them somehow?

@TheDL98
Copy link
Contributor

TheDL98 commented May 16, 2020

I have the same issue. I tested it with two computers.
IG seems to work just fine with commit 24750e6. The problem probably starts with 6ce677d (I couldn't build it due to some error hence probably, but the next commit 9c51ff9 builds just fine).

@fire-eggs
Copy link
Collaborator

Interesting bug. Easy enough to repro. Thank you for the report!

The trick is that the config.xml file must be empty, or invalid. The problem does not manifest if a correct config.xml file is used.

The first problem is in Theme.cs, LoadTheme().

When double-clicking on a file to open it using IG as the associated viewer, the current working directory for IG is the folder where the image resides. The first time LoadTheme() is invoked, the input path is empty. In this case, if a (bogus) file named config.xml is in the image folder, it will be found, IG will try to use it, throw an exception, and shut down.

So issue #1: LoadTheme needs exception handling for a bogus XML file.

[Side note: when IG is invoked via RMB->Open With..., the current working directory is "C:\windows\system32". So an empty/bogus config.xml file in that folder would cause the same problem.]

Issue #2: the second time LoadTheme() is called, the full path to the Themes folder relative to the App Directory is provided. So, why is LoadTheme() called twice? Why is the first call with an empty path? [In my case I'm not using the Default theme.]

Issue #3: what happens if the theme config.xml file in the installation folder is deleted or corrupted? IG behaves the same as in the original report: falls over silently.

As I'm not in a position to attempt to solve any of these right now, here are my suggestions:

  • re-examine passing an empty path to LoadTheme, or using the current working directory
  • re-examine calling LoadTheme twice
  • add try / catch in theme loading. Attempt to use the install folder theme if the provided theme path fails
  • consider using a less generic filename instead of "config.xml", e.g. "igtheme.xml"
  • consider a diagnostic message when IG encounters a "I can't continue" scenario. In this case, something along the line of "theme config file at location is corrupt or missing", rather than fail silently

@TheDL98
Copy link
Contributor

TheDL98 commented May 17, 2020

@fire-eggs I worked on your forth suggestion. changed every reference from config.xml to igtheme.xml and changed the file name under path ImageGlass\Setup\Assets\DefaultTheme\ to igtheme.xml.
I will create a pull request in develop branch since I don't know if this will break something else.

@d2phap d2phap linked a pull request Jun 2, 2020 that will close this issue
@d2phap d2phap added this to the Issues 7.6.4.30 milestone Jun 2, 2020
d2phap added a commit that referenced this issue Jun 2, 2020
Issue #765 Images won't open in config.xml presence
@d2phap
Copy link
Owner

d2phap commented Jul 10, 2020

Shipped in IG Moon: https://imageglass.org/moon

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants