From 90b089a80b0df3a4f1f9227a73ca9ead6c435443 Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Fri, 22 Mar 2019 23:19:01 +1100 Subject: [PATCH] fixed VST loading --- effects/effect.cpp | 3 +++ effects/fields/filefield.cpp | 11 +++++++++++ effects/fields/filefield.h | 1 + effects/internal/vsthost.cpp | 14 ++++++++++++-- effects/internal/vsthost.h | 2 ++ 5 files changed, 29 insertions(+), 2 deletions(-) diff --git a/effects/effect.cpp b/effects/effect.cpp index 60d09f2a4..8e29a468c 100644 --- a/effects/effect.cpp +++ b/effects/effect.cpp @@ -597,6 +597,9 @@ void Effect::load(QXmlStreamReader& stream) { field->keyframes.append(key); } } + + field->Changed(); + } } } diff --git a/effects/fields/filefield.cpp b/effects/fields/filefield.cpp index bf5125ae8..4e4eab335 100644 --- a/effects/fields/filefield.cpp +++ b/effects/fields/filefield.cpp @@ -1,5 +1,7 @@ #include "filefield.h" +#include + #include "ui/embeddedfilechooser.h" FileField::FileField(EffectRow* parent, const QString &id) : @@ -23,6 +25,15 @@ QWidget *FileField::CreateWidget(QWidget *existing) return efc; } +void FileField::UpdateWidgetValue(QWidget *widget, double timecode) +{ + EmbeddedFileChooser* efc = static_cast(widget); + + efc->blockSignals(true); + efc->setFilename(GetFileAt(timecode)); + efc->blockSignals(false); +} + void FileField::UpdateFromWidget(const QString &s) { KeyframeDataChange* kdc = new KeyframeDataChange(this); diff --git a/effects/fields/filefield.h b/effects/fields/filefield.h index 88c3f0237..317e324bf 100644 --- a/effects/fields/filefield.h +++ b/effects/fields/filefield.h @@ -12,6 +12,7 @@ public: QString GetFileAt(double timecode); virtual QWidget* CreateWidget(QWidget *existing = nullptr) override; + virtual void UpdateWidgetValue(QWidget *widget, double timecode) override; private slots: void UpdateFromWidget(const QString &s); }; diff --git a/effects/internal/vsthost.cpp b/effects/internal/vsthost.cpp index 8a07f69dc..7fe21df0f 100644 --- a/effects/internal/vsthost.cpp +++ b/effects/internal/vsthost.cpp @@ -189,6 +189,7 @@ void VSTHost::loadPlugin() { void VSTHost::freePlugin() { if (plugin != nullptr) { stopPlugin(); + data_cache.clear(); #if defined(__APPLE__) CFBundleUnloadExecutable(bundle); CFRelease(bundle); @@ -268,6 +269,11 @@ void VSTHost::CreateDialogIfNull() } } +void VSTHost::send_data_cache_to_plugin() +{ + dispatcher(plugin, effSetChunk, 0, int32_t(data_cache.size()), static_cast(data_cache.data()), 0); +} + VSTHost::VSTHost(Clip* c, const EffectMeta *em) : Effect(c, em), plugin(nullptr), @@ -284,7 +290,7 @@ VSTHost::VSTHost(Clip* c, const EffectMeta *em) : EffectRow* file_row = new EffectRow(this, tr("Plugin"), true, false); file_field = new FileField(file_row, "filename"); - connect(file_field, SIGNAL(Changed()), this, SLOT(change_plugin())); + connect(file_field, SIGNAL(Changed()), this, SLOT(change_plugin()), Qt::QueuedConnection); EffectRow* interface_row = new EffectRow(this, tr("Interface"), false, false); @@ -346,7 +352,7 @@ void VSTHost::custom_load(QXmlStreamReader &stream) { stream.readNext(); data_cache = QByteArray::fromBase64(stream.text().toUtf8()); if (plugin != nullptr) { - dispatcher(plugin, effSetChunk, 0, int32_t(data_cache.size()), static_cast(data_cache.data()), 0); + send_data_cache_to_plugin(); } } } @@ -394,6 +400,10 @@ void VSTHost::change_plugin() { VSTRect* eRect = nullptr; plugin->dispatcher(plugin, effEditGetRect, 0, 0, &eRect, 0); + if (!data_cache.isEmpty()) { + send_data_cache_to_plugin(); + } + CreateDialogIfNull(); dialog->setFixedSize(eRect->right - eRect->left, eRect->bottom - eRect->top); diff --git a/effects/internal/vsthost.h b/effects/internal/vsthost.h index 5dc06a0cf..9d3b46e21 100644 --- a/effects/internal/vsthost.h +++ b/effects/internal/vsthost.h @@ -68,6 +68,8 @@ private: QDialog* dialog; QByteArray data_cache; + void send_data_cache_to_plugin(); + #if defined(__APPLE__) CFBundleRef bundle; #else