Skip to content

Commit

Permalink
moved buffer deletion in __save_to_file to finally block
Browse files Browse the repository at this point in the history
  • Loading branch information
stoozey committed Oct 16, 2022
1 parent 67605ec commit 67833ee
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions scripts/scr_ssave/scr_ssave.gml
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ function SSave(_name = "data", _protection = SSAVE_PROTECTION_DEFAULT) construct

static __save_to_file = function(_filename)
{
var _buffer, _data;
var _success, _buffer, _data;
try
{
var _save = __generate_output_struct();
Expand Down Expand Up @@ -105,12 +105,12 @@ function SSave(_name = "data", _protection = SSAVE_PROTECTION_DEFAULT) construct
buffer_save(_buffer, _filename);

__ssave_print("saved file to: ", _filename);
return true;
_success = true;
}
catch (_e)
{
__ssave_print("error saving file \"", _filename, "\" | ", _e.message);
return false;
_success = false;
}
finally
{
Expand All @@ -120,6 +120,8 @@ function SSave(_name = "data", _protection = SSAVE_PROTECTION_DEFAULT) construct
if (buffer_exists(_data))
buffer_delete(_data);
}

return _success;
}

static __load_from_file = function(_filename)
Expand Down

0 comments on commit 67833ee

Please sign in to comment.