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
Scripting: BinaryFile in WriteOnly mode gives IODevice is not open
#2801
Comments
Could it be related to the use of QSaveFile in For binary files, QSaveFile is only used in WriteOnly mode. EDIT: Disabling the 'use safe writing of files' setting in Tiled's preferences dialog seems to fix the issue, confirming that this is likely related to QSaveFile. |
Whoops, good catch! So then, it remains to be investigated what we're doing wrong with |
ScriptBinaryFile::close was calling QIODevice::reset instead of std::unique_ptr::reset. Closes #2801
Trying to commit changes to a
BinaryFile
that was opened inWriteOnly
mode gives a warningQFileDevice::seek: IODevice is not open
. At least on my Linux machine, it does seem to write to the file anyway, but apparently in Windows it does not (or at least not always).TextFiles in WriteOnly mode and BinaryFiles in ReadWrite mode seem to work without warnings or problems.
The code below provides a minimal example. I tested this with the snap version snapshot 1506, as well as the precompiled Linux snapshot version 2020.05.07. OS is Ubuntu 18.04. Apparently it also happens on Windows with the 2020.05.07 version (cannot test myself though).
To run the example, save the code as test.js and put it in Tiled's extension folder.
Create a blank (or any) file with a .test extension (its contents are ignored), and try to open it in Tiled. The script will try to save 3 files in the same folder as the .test file; a TextFile in WriteOnly mode, a BinaryFile in ReadWrite mode, and a BinaryFile in WriteOnly mode. The first two succeed while the last one give the aforementioned warning.
The text was updated successfully, but these errors were encountered: