Instantiate the editor within the main context

Otherwise it of course won't work.
This commit is contained in:
Robbert van der Helm
2020-12-20 00:34:51 +01:00
parent 36c2d877c2
commit 66450407f0
+23 -13
View File
@@ -429,22 +429,32 @@ void Vst3Bridge::run() {
const std::string window_class = const std::string window_class =
"yabridge plugin " + sockets.base_dir.string() + " " + "yabridge plugin " + sockets.base_dir.string() + " " +
std::to_string(request.owner_instance_id); std::to_string(request.owner_instance_id);
Editor& editor_instance =
object_instances[request.owner_instance_id].editor.emplace(
config, window_class, x11_handle);
const tresult result = // Creating the window and having the plugin embed in it should
object_instances[request.owner_instance_id] // be done in the main UI thread
.plug_view->attached(editor_instance.get_win32_handle(), std::promise<tresult> attach_result{};
type.c_str()); boost::asio::dispatch(main_context.context, [&]() {
Editor& editor_instance =
object_instances[request.owner_instance_id]
.editor.emplace(config, window_class, x11_handle);
// Get rid of the editor again if the plugin didn't embed itself const tresult result =
// in it object_instances[request.owner_instance_id]
if (result != Steinberg::kResultOk) { .plug_view->attached(
object_instances[request.owner_instance_id].editor.reset(); editor_instance.get_win32_handle(),
} type.c_str());
return result; // Get rid of the editor again if the plugin didn't embed
// itself in it
if (result != Steinberg::kResultOk) {
object_instances[request.owner_instance_id]
.editor.reset();
}
attach_result.set_value(result);
});
return attach_result.get_future().get();
}, },
[&](YaPlugView::GetSize& request) -> YaPlugView::GetSize::Response { [&](YaPlugView::GetSize& request) -> YaPlugView::GetSize::Response {
const tresult result = const tresult result =