Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
External Editor stops working after save #223
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.
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.