Construct and destruct IPlugView from GUI thread

This commit is contained in:
Robbert van der Helm
2020-12-20 12:06:21 +01:00
parent 703b6d9285
commit f2153148b2
+16 -4
View File
@@ -66,9 +66,15 @@ void Vst3Bridge::run() {
overload{ overload{
[&](const Vst3PlugViewProxy::Destruct& request) [&](const Vst3PlugViewProxy::Destruct& request)
-> Vst3PlugViewProxy::Destruct::Response { -> Vst3PlugViewProxy::Destruct::Response {
// When the pointer gets dropped by the host, we want to drop it // XXX: Not sure if his has to be run form the UI thread
// here as well main_context
object_instances[request.owner_instance_id].plug_view.reset(); .run_in_context([&]() {
// When the pointer gets dropped by the host, we want to
// drop it here as well
object_instances[request.owner_instance_id]
.plug_view.reset();
})
.wait();
return Ack{}; return Ack{};
}, },
@@ -376,10 +382,16 @@ void Vst3Bridge::run() {
}, },
[&](const YaEditController::CreateView& request) [&](const YaEditController::CreateView& request)
-> YaEditController::CreateView::Response { -> YaEditController::CreateView::Response {
// Instantiate the object from the GUI thread
main_context
.run_in_context([&]() {
object_instances[request.instance_id].plug_view = object_instances[request.instance_id].plug_view =
Steinberg::owned( Steinberg::owned(
object_instances[request.instance_id] object_instances[request.instance_id]
.edit_controller->createView(request.name.c_str())); .edit_controller->createView(
request.name.c_str()));
})
.wait();
// We'll create a proxy so the host can call functions on this // We'll create a proxy so the host can call functions on this
// `IPlugView` object // `IPlugView` object