diff --git a/core/audio/plugin_host/plugin_host.cpp b/core/audio/plugin_host/plugin_host.cpp index 67761e5..7ff8510 100644 --- a/core/audio/plugin_host/plugin_host.cpp +++ b/core/audio/plugin_host/plugin_host.cpp @@ -50,7 +50,11 @@ void plugin_host::init_channel_interface() { void plugin_host::create_and_open_editor() { void* handle = get_window_manager()->create_plugin_window(this); - open_editor(handle); + if (!handle) { + spdlog::error("Failed to create plugin window"); + return; + } + on_open_editor(handle); } void plugin_host::destroy_editor() { diff --git a/core/audio/plugin_host/plugin_host.h b/core/audio/plugin_host/plugin_host.h index 874b0e1..6aeec3f 100644 --- a/core/audio/plugin_host/plugin_host.h +++ b/core/audio/plugin_host/plugin_host.h @@ -59,12 +59,13 @@ public: std::string vendor; channel_interface* channel = nullptr; std::vector owner_tracks; - bool editor_opened = false; std::shared_ptr ui_buffers; multicast_delegate on_param_changed; protected: void create_and_open_editor(); void destroy_editor(); - virtual void open_editor(void* window_handle) = 0; - virtual void close_editor() = 0; + virtual void on_open_editor(void* window_handle) = 0; + virtual void on_close_editor() = 0; +private: + bool editor_opened = false; }; diff --git a/core/audio/plugin_host/plugin_host_manager.h b/core/audio/plugin_host/plugin_host_manager.h index 643d6ba..1087c45 100644 --- a/core/audio/plugin_host/plugin_host_manager.h +++ b/core/audio/plugin_host/plugin_host_manager.h @@ -18,6 +18,7 @@ public: void remove_instrument_plugin_host(plugin_host* host); const std::vector& get_plugin_hosts() { return plugin_hosts_; } + const std::vector& get_instrument_hosts() { return instrument_plugins_; } void process(uint32_t in_frames); const char* get_name() override { return "plugin_host_manager"; } diff --git a/core/audio/plugin_host/vst2/vst2_plugin_host.cpp b/core/audio/plugin_host/vst2/vst2_plugin_host.cpp index 7c45521..6742804 100644 --- a/core/audio/plugin_host/vst2/vst2_plugin_host.cpp +++ b/core/audio/plugin_host/vst2/vst2_plugin_host.cpp @@ -261,13 +261,13 @@ std::string vst2_plugin_host::load_vendor() const { return buffer; } -void vst2_plugin_host::open_editor(void* window_handle) { +void vst2_plugin_host::on_open_editor(void* window_handle) { if (!has_editor()) return; dispatch(effEditOpen, 0, 0, window_handle); } -void vst2_plugin_host::close_editor() { +void vst2_plugin_host::on_close_editor() { if (!has_editor()) return; dispatch(effEditClose); diff --git a/core/audio/plugin_host/vst2/vst2_plugin_host.h b/core/audio/plugin_host/vst2/vst2_plugin_host.h index 89b1184..a8c26f7 100644 --- a/core/audio/plugin_host/vst2/vst2_plugin_host.h +++ b/core/audio/plugin_host/vst2/vst2_plugin_host.h @@ -35,8 +35,8 @@ public: [[nodiscard]] std::string load_name() const override; [[nodiscard]] std::string load_vendor() const override; protected: - void open_editor(void* window_handle) override; - void close_editor() override; + void on_open_editor(void* window_handle) override; + void on_close_editor() override; private: VstIntPtr dispatch(VstInt32 opcode, VstInt32 index = 0, VstIntPtr value = 0, void* ptr = nullptr, float opt = 0) const; AEffect* effect_; diff --git a/core/window/window_manager.cpp b/core/window/window_manager.cpp index bb86579..4815858 100644 --- a/core/window/window_manager.cpp +++ b/core/window/window_manager.cpp @@ -90,7 +90,8 @@ void window_manager::on_host_window_close(GLFWwindow* window) { return info.second.window.get() == window; }); if (f != host_infos_.end()) { - f->first->close_editor(); + f->first->editor_opened = false; + f->first->on_close_editor(); int x, y; glfwGetWindowPos(window, &x, &y); f->second.x = x;