Fixes external editors by closing file handles #247

Merged
merged 2 commits into from Feb 2, 2016

Conversation

Projects
None yet
1 participant
@RobertBColton
Collaborator

RobertBColton commented Feb 2, 2016

The external editors were never closing open file input streams after loading the data back into the IDE. This made it impossible to save more than once from the external editor without closing and reopening from inside LGM. Fixes all four frames with external editors including sprite editor, background editor, sound editor, and code/script editor. This fully addresses #223 as I did in master.

I also refined the exception catching to protect against certain faults. There are 3 different scenarios to consider. I tested extensively to ensure what I believe to be the correct behavior and to prevent dangling file handles. The only way the file wouldn't exist in any of these cases is if the user cleared their temporary files, in which case these handlers delete their reference to the file so it is safe.

Opening File Input Stream

  1. The file doesn't exist or for some reason a FileInputStream can't be created.
  2. Print the exception.
  3. The FileInputStream will be null.
  4. Return

Reading File

  1. The file existed and there is a valid FileInputStream but for some reason it fails to be read possibly because it is not a supported file format.
  2. Print the exception.
  3. The FileInputStream is valid and non-null so try to close it.
    • It fails so print the exception.
    • It succeeds.
  4. Return possibly with a dangling file handle if it couldn't be closed.

Closing File

  1. The file exists and is read successfully.
  2. The FileInputStream is valid and non-null so try to close it.
    • It fails so print the exception
    • It succeeds.
  3. Put the data into the resource/property map and update the components.
  4. Return possibly with a dangling file handle if it couldn't be closed.

RobertBColton added some commits Feb 2, 2016

Fixes external editors by closing file handles
The external editors were never closing open file input streams after
loading the data back into the IDE. This made it impossible to save more
than once from the external editor without closing and reopening from
inside LGM.

RobertBColton added a commit that referenced this pull request Feb 2, 2016

Merge pull request #247 from RobertBColton/16b5
Fixes external editors by closing file handles

@RobertBColton RobertBColton merged commit 2e74667 into IsmAvatar:16b5 Feb 2, 2016

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