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

Unhandled exception bug report and possible solution #113

Closed
4294967296 opened this issue Aug 16, 2016 · 3 comments
Closed

Unhandled exception bug report and possible solution #113

4294967296 opened this issue Aug 16, 2016 · 3 comments
Labels
Milestone

Comments

@4294967296
Copy link

4294967296 commented Aug 16, 2016

I accidentally came across an unhandled exception while using the "Window adapt to image (Ctrl + M)" option over a small image, then exiting the application by pressing "Esc".

This does not have to do directly with the image sizing option, but with the window being resized manually or automatically to a small height.

When the application is exited, it seems to save some settings under the registry key "HKEY_CURRENT_USER\SOFTWARE\PhapSoftware\ImageGlass".

If the saved height is smaller than a certain value, that leads to an unhandled exception when you try to run the application again, stating that negative values are not valid for SplitterDistance.

Thankfully, you can click on Continue, and resize (increase) the window height to get around this problem.

Searching for the cause of this unhandled exception, I found out the following facts:

In the saved registry settings, there is a "WindowsBound" value, which is in the form of "a,b,c,d", containing the horizontal and vertical coordinates of the window, and the width and height of the window respectively.

The weird thing is that the problem arises only with the window height setting, not the window width one.

I have not inspected the source code, but I can verify by inspecting the registry that while starting up the application, the following things happen:

Window width saved setting:

If the saved width setting has a value larger than "136", then the saved value is retained and used by the application.

If the saved width setting has a value smaller than "136" (you can only set that manually in the registry, even a negative number), then the saved value is automatically adjusted to "136".

By using the user interface provided window resizing controls, and inspecting the registry after exiting the application, it seems that you can graphically reduce the window width as low as "136".

Window height saved setting:

If the saved height setting has a value larger than "100", then the saved value is retained and used by the application.

If the saved height setting has a value smaller than "100" (you can set that manually in the registry, even a negative number), then the saved value is automatically adjusted to "100".

By using the user interface provided window resizing controls, and inspecting the registry after exiting the application, it seems that you can graphically reduce the window height as low as "100".

The problem is that with any height value between "100" and "161", the application displays an unhandled exception while starting up.

This "161" threshold value is valid in my test case, under Windows 10, and it may be different under other setups or Windows versions.

Solution

As a solution to the unhandled exception, if the actual threshold value covering most cases is "xyz", you can either restrict the window height being resized below "xyz", or you can alternatively change the automatically adjusted height during starting up to "xyz" instead of "100".

I have not inspected the source code, so I cannot know whether this problem is caused by a combination of factors unrelated to the application code, so it would need some workaround, or if it is caused by the application code itself, which would be easier to address.


Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

@d2phap
Copy link
Owner

d2phap commented Jan 21, 2017

Hi @4294967296

I'm working on this bug however, I tried to reproduce the issue but there is no error in my machine (Win 10)

For the Width and Height values:

  • The minimum width of a window is 136px (by default)
  • The minimum height of a window is 100px (set in source code)

Therefore, if you set any value less than those values, it will get 136px for width and 100px for height.

Phap

@fire-eggs
Copy link
Collaborator

fire-eggs commented Apr 18, 2018

Just reproduced this problem on Windows 10, ImageGlass 5.0.4.18-Moon.

System.InvalidOperation: SplitterDistance must be between Panel1MinSize and Width - Panel2MinSize.

What I did was:

  1. Run imageglass. Open image. Show thumbnails, along bottom. Thumbnail size was 128.
  2. Shrunk the height of imageglass to really tiny. As short as I could make it (a little taller than the title bar + height of the toolbar). The stored frmMain.WindowsBound value was "280,125,1178,68". To wit, 68 pixels high.
  3. Shut down Imageglass.
    4 Run ImageGlass again.

In mnuMainThumbnailBar_Click, as invoked by LoadConfig, the code attempts to set sp1.SplitterDistance to 171. (frmMain.cs line 3291).

Here is my igconfig.xml file which causes the problem:
igconfig.zip

@fire-eggs
Copy link
Collaborator

Not reproducible in latest IG 5.0+

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

No branches or pull requests

3 participants