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
+17 -7
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);
// Creating the window and having the plugin embed in it should
// be done in the main UI thread
std::promise<tresult> attach_result{};
boost::asio::dispatch(main_context.context, [&]() {
Editor& editor_instance = Editor& editor_instance =
object_instances[request.owner_instance_id].editor.emplace( object_instances[request.owner_instance_id]
config, window_class, x11_handle); .editor.emplace(config, window_class, x11_handle);
const tresult result = const tresult result =
object_instances[request.owner_instance_id] object_instances[request.owner_instance_id]
.plug_view->attached(editor_instance.get_win32_handle(), .plug_view->attached(
editor_instance.get_win32_handle(),
type.c_str()); type.c_str());
// Get rid of the editor again if the plugin didn't embed itself // Get rid of the editor again if the plugin didn't embed
// in it // itself in it
if (result != Steinberg::kResultOk) { if (result != Steinberg::kResultOk) {
object_instances[request.owner_instance_id].editor.reset(); object_instances[request.owner_instance_id]
.editor.reset();
} }
return result; 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 =