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

Text tool's bounding rect is lost in serialization roundtrip #21

Closed
jeffstay opened this issue Apr 28, 2019 · 7 comments
Closed

Text tool's bounding rect is lost in serialization roundtrip #21

jeffstay opened this issue Apr 28, 2019 · 7 comments
Labels
bug Something isn't working

Comments

@jeffstay
Copy link

Loading a json file back in to the Drawing view works with the exception of Text objects and Ngon shapes. The text objects don't render and the Ngon shapes raise exception. It looks like the sides property is erroring on a nil exception.

@iain-reid
Copy link

I'm having the same issue - is there a workaround?

@stevelandeyasana stevelandeyasana added the bug Something isn't working label May 29, 2019
@stevelandeyasana
Copy link
Collaborator

Thanks for the reports and your patience. I'll look at this next time I do a maintenance pass.

@SanjeevSundaravarathan
Copy link

SanjeevSundaravarathan commented Jun 17, 2019

I'm facing same problem, and addition to that is I load data, made some changes and tries to save it its not working either. Can you please check this issue too ? Is there any work around ? can you please let us know ?

@eimlaymaire
Copy link

I'm facing same problem, and addition to that is I load data, made some changes and tries to save it its not working either. Can you please check this issue too ? Is there any work around ? can you please let us know ?

Sanjeev. I have a hacky solution to edit saved data. Try encoding the shapes individually like this
let penShapes = drawView.drawing.shapes.filter { $0 as? PenShape != nil }.map { $0 as! PenShape }
let data = try JSONEncoder().encode(penShapes)

And then decoding them individually as well, like this:
let penShapes = JSONDecoder().decode([PenShape].self, from: data)

Shapes that encode/decode properly should be editable. You can add your decoded shapes to your drawing like this:
penShapes.forEach { drawing.add($0) }

@stevelandeyasana
Copy link
Collaborator

I fixed the bug with Ngons, but I couldn't reproduce issues with text yet. A PR and release will come this week.

@stevelandeyasana
Copy link
Collaborator

I captured the idea from @elian3's comment in #30 as a general enhancement.

@stevelandeyasana
Copy link
Collaborator

The bug with the text tool is that the bounding rect isn't saved, and it isn't derived at load time either.

@stevelandeyasana stevelandeyasana changed the title Issue loading saved drawing from json Text tool's bounding rect is lost in serialization roundtrip Jul 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

No branches or pull requests

5 participants