Skip to content
Permalink
Browse files

Scripting: Made TextFile.commit and BinaryFile.commit close as well

Usually commit() would also close the device, except when save writing
of files is disabled. Make sure the device is always closed.
  • Loading branch information
bjorn committed Mar 2, 2020
1 parent 2883ae3 commit 0f1e566c7b5e0f3acfb98322ea6947f2b8e6173d
Showing with 11 additions and 6 deletions.
  1. +7 −6 docs/reference/scripting.rst
  2. +4 −0 src/tiled/scriptfile.cpp
@@ -1542,9 +1542,9 @@ TextFile.writeLine(text : string) : void
Writes a string to the file and appends a newline character.

TextFile.commit() : void
Commits all written text to disk. Should be called when writing to files in
WriteOnly mode. Failing to call this function will result in cancelling the
operation, unless safe writing to files is disabled.
Commits all written text to disk and closes the file. Should be called when
writing to files in WriteOnly mode. Failing to call this function will
result in cancelling the operation, unless safe writing to files is disabled.

TextFile.close() : void
Closes the file. It is recommended to always call this function as soon as
@@ -1598,9 +1598,10 @@ BinaryFile.write(data : ArrayBuffer) : void
Writes *data* into the file at the current position.

BinaryFile.commit() : void
Commits all written data to disk. Should be called when writing to files in
WriteOnly mode. Failing to call this function will result in cancelling the
operation, unless safe writing to files is disabled.
Commits all written data to disk and closes the file. Should be called when
writing to files in WriteOnly mode. Failing to call this function will
result in cancelling the operation, unless safe writing to files is
disabled.

BinaryFile.close() : void
Closes the file. It is recommended to always call this function as soon as
@@ -178,6 +178,8 @@ void ScriptBinaryFile::commit()
"Could not write to '%1': %2").arg(m_file->fileName(),
m_file->errorString()));
}

close();
}

void ScriptBinaryFile::close()
@@ -317,6 +319,8 @@ void ScriptTextFile::commit()
"Could not write to '%1': %2").arg(m_file->fileName(),
m_file->errorString()));
}

close();
}

void ScriptTextFile::close()

0 comments on commit 0f1e566

Please sign in to comment.
You can’t perform that action at this time.