fix a bunch of memory leaks
[ardour.git] / libs / ardour / windows_vst_plugin.cc
index 9fe9ba0049b876415d6f299029fe46992c0280c6..03170e0d04a6db3a25889c9adf53d2b3a704cb15 100644 (file)
@@ -28,12 +28,14 @@ using namespace std;
 using namespace ARDOUR;
 using namespace PBD;
 
-WindowsVSTPlugin::WindowsVSTPlugin (AudioEngine& e, Session& session, VSTHandle* h)
+WindowsVSTPlugin::WindowsVSTPlugin (AudioEngine& e, Session& session, VSTHandle* h, int unique_id)
        : VSTPlugin (e, session, h)
 {
+       Session::vst_current_loading_id = unique_id;
        if ((_state = fst_instantiate (_handle, Session::vst_callback, this)) == 0) {
                throw failed_constructor();
        }
+       Session::vst_current_loading_id = 0;
 
        set_plugin (_state->plugin);
 }
@@ -43,9 +45,11 @@ WindowsVSTPlugin::WindowsVSTPlugin (const WindowsVSTPlugin &other)
 {
        _handle = other._handle;
 
+       Session::vst_current_loading_id = PBD::atoi(other.unique_id());
        if ((_state = fst_instantiate (_handle, Session::vst_callback, this)) == 0) {
                throw failed_constructor();
        }
+       Session::vst_current_loading_id = 0;
        
        _plugin = _state->plugin;
 }
@@ -70,7 +74,7 @@ WindowsVSTPluginInfo::load (Session& session)
                        if ((int) handle == -1) {
                                error << string_compose(_("VST: cannot load module from \"%1\""), path) << endmsg;
                        } else {
-                               plugin.reset (new WindowsVSTPlugin (session.engine(), session, handle));
+                               plugin.reset (new WindowsVSTPlugin (session.engine(), session, handle, PBD::atoi(unique_id)));
                        }
                } else {
                        error << _("You asked ardour to not use any VST plugins") << endmsg;