Plugin UI deletion always on message thread?


I am wondering: is it safe to assume, that the DAW will always destroy the plugin UI on the message thread? I mean: will the AudioProcessorEditor always be deleted from the message thread?

I am wondering, because my plugin is using async callbacks to the message thread in some places. And I am curious, if the UI could be destroyed, while I am executing an async callback. If the UI were destroyed on the message thread, then it could not be destroyed, while executing my async message thread callback. That would be good. :slight_smile:

Yes, it has to. When a Component is destroyed, it starts removing child components. All methods that modify the children’s list (addChildComponent and removeChildComponent) or a Components bounds are changed require a lock on the message manager. So if a host would destroy the plugin editor on a background thread, you would get plenty asserts firing and in release it would be undefined behaviour.

But remember to capture WeakReferences/Component::SafePointer in your asynchronous lambdas, since they can still fire AFTER the destruction happened, but not in parallel.


Hi Daniel,

Thanks for the fast answer. That is interesting to hear. And good news :slight_smile: