Skip to content

Add a section about keeping locks while emitting signals #392

@Hofer-Julian

Description

@Hofer-Julian

To cite @sdroege here

It's worth a note in the clicked function that you should really never ever keep a mutex (or refcell) locked/borrowed while: emitting signals, notifying property changes, anything that can cause these to happen. Because that will call into external code, and that external code might call back into your object, trying to use the same mutex/refcell and then you have a problem :)

Until recently we had an example here.
However, I don't think I embedded it nicely in the chapter.
Now that we use Cell instead RefCell for Copy types it definitely does not work anymore.

I suggest to add a small section about this topic, most probably at the end of the signal chapter.
Ideally, it would be a small self-contained example which demonstrates the problem.
Then we explain it and solve it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions