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

External Editor stops working after save #223

Closed
RobertBColton opened this Issue Sep 5, 2015 · 0 comments

Comments

Projects
None yet
1 participant
@RobertBColton
Collaborator

RobertBColton commented Sep 5, 2015

If you use an external editor like GIMP or PDN to edit and then save the background/sprite image or subimage after the first time you save it will no longer be loaded back into LGM. I believe this is because LGM has a listener somewhere for the temp file and only listens for the first save to the file. This is a total pain because I can't save changes and then preview them in LGM without closing and reopening my image editor for multiple manipulations. I've yet to test how GM behaves with an external image editor. This applies to external editors in general too though, not just the external image editor.

This is not a regression and exists pre-1.8.2

The issue is caused by improperly closed file handles. When LGM is done reading the file, it should close the file handle/input stream. I will address this in the next release.

img = ImageIO.read(new FileInputStream(monitor.file));

There was originally an issue noticed by me with Paint.NET with this solution. Hitting the external edit button twice would open two sessions that could simultaneously edit the file and save it concurrently without exception. So the second time I hit edit, even though the temp file did not change, Paint.NET would open the same file _again_ in a second session. Josh confirmed this also with GIMP when importing PNG's, but if the file is an XCF then GIMP will keep track. Ideally this is the fault of the external program which should be keeping track of the files it has open. Notepad++ is one such program that keeps track of open files so this does not occur when externally editing scripts, a second hit of the edit externally button in the script editor will refocus the existing session or start a new one if the old one closed. However because LGM writes the file on every click of the button, even though nothing changed, Notepad++ can detect and warns you that the file was changed asking you if you want to reload it.

There is little else that can be done to mitigate these slight inconsistencies besides tracking the external process. It is possible with Runtime.getRuntime().exec to check the return process for isAlive() on future clicks of the button that opens the external editor. This is generally an issue with many programs and to avoid over engineering the solution I believe we will not fix this. For example, in Eclipse I can right click a file and open it more than once in the system editor. The difference being that LGM is only temporarily storing the image as a temp file on disk until the project is actually later saved to the disk in the case of a GMX.

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