From 4d49de937ca2a631e23defa03ab75420e31bea9a Mon Sep 17 00:00:00 2001 From: itsmattkc Date: Tue, 29 Jan 2019 11:39:35 +1100 Subject: [PATCH] preserve vst data through saves even if vst is missing --- effects/internal/vsthost.cpp | 26 ++++++++++++++------------ effects/internal/vsthost.h | 2 ++ 2 files changed, 16 insertions(+), 12 deletions(-) diff --git a/effects/internal/vsthost.cpp b/effects/internal/vsthost.cpp index bdd007ecd..481341b15 100644 --- a/effects/internal/vsthost.cpp +++ b/effects/internal/vsthost.cpp @@ -281,9 +281,9 @@ void VSTHost::process_audio(double, double, quint8* samples, int nb_bytes, int) void VSTHost::custom_load(QXmlStreamReader &stream) { if (stream.name() == "plugindata") { stream.readNext(); - QByteArray b = QByteArray::fromBase64(stream.text().toUtf8()); + data_cache = QByteArray::fromBase64(stream.text().toUtf8()); if (plugin != nullptr) { - dispatcher(plugin, effSetChunk, 0, int32_t(b.size()), static_cast(b.data()), 0); + dispatcher(plugin, effSetChunk, 0, int32_t(data_cache.size()), static_cast(data_cache.data()), 0); } } } @@ -293,25 +293,27 @@ void VSTHost::save(QXmlStreamWriter &stream) { if (plugin != nullptr) { char* p = nullptr; int32_t length = int32_t(dispatcher(plugin, effGetChunk, 0, 0, &p, 0)); - QByteArray b(p, length); - stream.writeTextElement("plugindata", b.toBase64()); + data_cache = QByteArray(p, length); + } + if (data_cache.size() > 0) { + stream.writeTextElement("plugindata", data_cache.toBase64()); } } void VSTHost::show_interface(bool show) { - dialog->setVisible(show); + dialog->setVisible(show); - if (show) { + if (show) { #if defined(_WIN32) - dispatcher(plugin, effEditOpen, 0, 0, reinterpret_cast(dialog->windowHandle()->winId()), 0); + dispatcher(plugin, effEditOpen, 0, 0, reinterpret_cast(dialog->windowHandle()->winId()), 0); #elif defined(__APPLE__) - dispatcher(plugin, effEditOpen, 0, 0, reinterpret_cast(dialog->windowHandle()->winId()), 0); + dispatcher(plugin, effEditOpen, 0, 0, reinterpret_cast(dialog->windowHandle()->winId()), 0); #elif defined(__linux__) - dispatcher(plugin, effEditOpen, 0, 0, reinterpret_cast(dialog->windowHandle()->winId()), 0); + dispatcher(plugin, effEditOpen, 0, 0, reinterpret_cast(dialog->windowHandle()->winId()), 0); #endif - } else { - dispatcher(plugin, effEditClose, 0, 0, nullptr, 0); - } + } else { + dispatcher(plugin, effEditClose, 0, 0, nullptr, 0); + } } void VSTHost::uncheck_show_button() { diff --git a/effects/internal/vsthost.h b/effects/internal/vsthost.h index 25c4a2169..9fe6c0faf 100644 --- a/effects/internal/vsthost.h +++ b/effects/internal/vsthost.h @@ -45,6 +45,8 @@ private: float** outputs; QDialog* dialog; QPushButton* show_interface_btn; + QByteArray data_cache; + #if defined(__APPLE__) CFBundleRef bundle; #else