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

Complex data in messages #58

Open
piegamesde opened this issue Aug 25, 2020 · 2 comments
Open

Complex data in messages #58

piegamesde opened this issue Aug 25, 2020 · 2 comments

Comments

@piegamesde
Copy link

How are messages handled internally? Why do they require Send and Clone?

My concrete problem is that I have some images, stored as gdk_pixbuf::Pixbuf in the model. When clicking on a button, a new image is selected then loaded. So I thought I'd put the new Pixbuf into some AddImage message. But I cannot do this because Message requires Send. Also since Message is Clone I'm starting to doubt if putting big data into it is a good idea at all.

So, how should I go about this? How can I still communicated with and update my model?

@wmww
Copy link

wmww commented Aug 25, 2020

I'm sorry if this is irrelevant and/or dumb, but would putting an Arc<Mutex<gdk_pixbuf::Pixbuf>> in the message solve your problem?

@piegamesde
Copy link
Author

It's neither nor. The problem with glib types is they are internally Rc<RefCell> wrapped. They all have inner mutability and can be cloned and passed around freely. From a Rust perspective, this means that you have absolutely no control over the data in the inner and a Mutex sadly won't change that.

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

No branches or pull requests

2 participants