Skip to content
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

Fix project saving #150

Closed
codefrau opened this issue Oct 1, 2023 · 3 comments
Closed

Fix project saving #150

codefrau opened this issue Oct 1, 2023 · 3 comments
Labels

Comments

@codefrau
Copy link
Owner

codefrau commented Oct 1, 2023

ImageSegment store primitive is missing

@codefrau codefrau added the bug label Oct 1, 2023
@codefrau codefrau changed the title Implement project saving Fix project saving Oct 4, 2023
@codefrau
Copy link
Owner Author

codefrau commented Oct 4, 2023

Implemented the primitive in e20591b (for non-Spur images).
It's working correctly according to ImageSegment>>deepCopyTest:.

However, while saving an Etoys project succeeds now, loading it back in still fails with an error. Since loading existing projects works fine, the problem must be in saving.

I assume there is a bug in writing the SmartRefStream. This could be the same issue as mentioned in #146 (comment) where saving a Scratch Project works only if the sounds are removed.

The actual error happens when loading a Bitmap from the Etoys project's SmartRefStream. I don't know the error in Scratch but sounds are related to binary objects too so that seems to be an area worth investigating.

@codefrau
Copy link
Owner Author

The load error happens when the ImageSegment's WordArrayForSegment is read from the SmartRefStream because there are not enough bytes. E.g. a project just containing an ellipse is written as a 6520 byte segment (i.e. the WordArray created by storeImageSegment()). But when loading it, the byteSize is read correctly as 6520 but only 3269 bytes are available before the end of the stream.

That means for some reason, storing of the ImageSegment's WordArray in the SmartRefStream failed, or maybe it was cut short when writing it to the zip (.pr files are actually .zip files containing the actual project and other files).

@codefrau
Copy link
Owner Author

Fixed the file writing bug in d94aaed.
The segment is stored as words in the file but primitiveFileWrite took the word count as bytes so it only stored the first quarter of the segment.
Works in release 1.1.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant