ImageGlass icon indicating copy to clipboard operation
ImageGlass copied to clipboard

Image doesn't reload when all files are deleted and then replaced

Open NathanSweet opened this issue 6 years ago • 6 comments

System information:

  • Windows OS version: Windows 10
  • ImageGlass version: 5.5.7.26

To Reproduce

Steps to reproduce the behavior:

  1. Open a PNG file with ImageGlass.
  2. Rewrite the image with an external tool. In my case, I am using Spine to pack a texture atlas. Spine deletes the image file, performs texture packing (which can take between milliseconds to a couple seconds), then a new image is written.

Actual behavior:

ImageGlass goes blank, then either reloads the file and shows the new content (as desired), or does nothing and stays blank (not desired). It stays blank about 33% of the time. This is very frustrating, as I have to go to the file on disk and open it again.

Expected behavior:

I expect ImageGlass to always reload the file and show the new content, never to stay blank.

Additional context:

My guess is that ImageGlass sees the image has been deleted, then gives up too quickly. When the new image file is created with the same name, ImageGlass has already given up and doesn't load it. It would be great if, when ImageGlass sees the file it has loaded has been deleted, that ImageGlass would continue looking for that file in case it comes back.

If there must be a timeout, it could be quite long (maybe 5-10 seconds), but I don't think it ever needs to timeout. If the file ever comes back, it should be reloaded.

BTW, thank you again for all the effort you put into ImageGlass!

NathanSweet avatar Dec 21 '18 08:12 NathanSweet

Thanks @NathanSweet Firstly, please try the latest build of ImageGlass Moon of the issue still persists? https://imageglass.org/moon

d2phap avatar Dec 21 '18 09:12 d2phap

I tried 5.5.12.20 and saw almost the same behavior: about 1/3 of the time ImageGlass goes blank instead of loading the new image. There was one difference: in 5.5.7.26 once it goes blank, if I save a new file again it stays blank. In 5.5.12.20, if it goes blank and I save a new file again, it usually (but not always!) loads the new file.

NathanSweet avatar Dec 21 '18 12:12 NathanSweet

Gonna dig into this, but in the meantime, do either of the Refresh (F5) or Reload (Ctrl+F5) commands "fix" the problem? (I.e. they should re-display the now-edited image without you having to go back to File Explorer)

fire-eggs avatar Feb 21 '19 15:02 fire-eggs

I reproduced it again to answer your question. Some findings:

  • If the folder has a single image, it seems to work as expected: the image is reloaded when Spine replaces it.
  • If the folder has multiple images and ImageGlass is showing the first one, when Spine replaces the image files, ImageGlass goes blank. The ImageGlass title bar no longer shows a filename (just says "ImageGlass"). Pressing F5 changes the titlebar to show the filename of the last loaded file and says "1/4 file(s)" but ImageGlass remains blank. If I instead press ctrl+F5 then ImageGlass does show the file, but the title bar remains blank.
  • Interestingly, if the folder has multiple images and ImageGlass is showing any of them that is not the first one, then ImageGlass does not go blank but also does not reload the image. Pressing F5 does not reload the image but ctrl+F5 does.

Please let me know if you need more info!

NathanSweet avatar Feb 22 '19 09:02 NathanSweet

Great, thank you for the additional details!

Pondering this, I think IG might go blank because all the images in the folder have disappeared from IG's view. Could you confirm Spine's behavior:

  1. Is Spine reworking all the images in the folder?
  2. Is Spine deleting all the images first, then recreating them? Or one-at-a-time?

It feels to me like IG is not recovering after a full delete and multiple files.

fire-eggs avatar Feb 22 '19 15:02 fire-eggs

Spine deletes all the images, then writes new ones. Your theory may be sound, though (as described above) when there is only one image it behaves differently (correctly).

NathanSweet avatar Feb 22 '19 15:02 NathanSweet