From d50a9bd5bf08e4dbd28986d72f022ac99b76a4bf Mon Sep 17 00:00:00 2001 From: Roman Pudashkin Date: Wed, 14 Dec 2022 14:05:32 +0200 Subject: [PATCH 1/5] fix #13867: deinit the plugin view before calling ~AbstractVstEditorView() --- src/framework/vst/view/abstractvsteditorview.cpp | 14 ++++++++++++++ src/framework/vst/view/abstractvsteditorview.h | 3 +++ 2 files changed, 17 insertions(+) diff --git a/src/framework/vst/view/abstractvsteditorview.cpp b/src/framework/vst/view/abstractvsteditorview.cpp index fa7d88af757aa..16c29829d007b 100644 --- a/src/framework/vst/view/abstractvsteditorview.cpp +++ b/src/framework/vst/view/abstractvsteditorview.cpp @@ -58,15 +58,22 @@ AbstractVstEditorView::AbstractVstEditorView(QWidget* parent) } AbstractVstEditorView::~AbstractVstEditorView() +{ + deinit(); +} + +void AbstractVstEditorView::deinit() { if (m_view) { m_view->setFrame(nullptr); m_view->removed(); + m_view = nullptr; } if (m_pluginPtr) { m_pluginPtr->loadingCompleted().resetOnNotify(this); m_pluginPtr->refreshConfig(); + m_pluginPtr = nullptr; } } @@ -165,6 +172,13 @@ void AbstractVstEditorView::showEvent(QShowEvent* ev) TopLevelDialog::showEvent(ev); } +void AbstractVstEditorView::closeEvent(QCloseEvent* ev) +{ + deinit(); + + TopLevelDialog::closeEvent(ev); +} + bool AbstractVstEditorView::event(QEvent* ev) { if (ev && ev->spontaneous() && ev->type() == QEvent::ShortcutOverride) { diff --git a/src/framework/vst/view/abstractvsteditorview.h b/src/framework/vst/view/abstractvsteditorview.h index 583733525a918..56263cf651d15 100644 --- a/src/framework/vst/view/abstractvsteditorview.h +++ b/src/framework/vst/view/abstractvsteditorview.h @@ -74,8 +74,11 @@ class AbstractVstEditorView : public uicomponents::TopLevelDialog, public Steinb void moveViewToMainWindowCenter(); void showEvent(QShowEvent* ev) override; + void closeEvent(QCloseEvent* ev) override; bool event(QEvent* ev) override; + void deinit(); + FIDString currentPlatformUiType() const; VstPluginPtr m_pluginPtr = nullptr; From 6b06c81cc77fc62e9c125c888ce562a0f3e38ab5 Mon Sep 17 00:00:00 2001 From: Roman Pudashkin Date: Fri, 16 Dec 2022 16:12:51 +0200 Subject: [PATCH 2/5] fixed a broken VST window after re-opening it on windows (the problem can be reproduced, for example, with Vital Audio or Valhalla Supermassive) --- src/framework/vst/internal/vstplugin.cpp | 12 ++---------- src/framework/vst/internal/vstplugin.h | 3 +-- src/framework/vst/view/abstractvsteditorview.cpp | 7 +++++-- 3 files changed, 8 insertions(+), 14 deletions(-) diff --git a/src/framework/vst/internal/vstplugin.cpp b/src/framework/vst/internal/vstplugin.cpp index bbe2d2e187337..a7eb11cbede39 100644 --- a/src/framework/vst/internal/vstplugin.cpp +++ b/src/framework/vst/internal/vstplugin.cpp @@ -125,7 +125,6 @@ void VstPlugin::unload() m_module = nullptr; m_pluginProvider = nullptr; m_classInfo = ClassInfo(); - m_pluginView = nullptr; m_isLoaded = false; m_unloadingCompleted.notify(); }, threadSecurer()->mainThreadId()); @@ -176,25 +175,18 @@ void VstPlugin::stateBufferFromString(VstMemoryStream& buffer, char* strData, co buffer.seek(0, Steinberg::IBStream::kIBSeekSet, nullptr); } -PluginViewPtr VstPlugin::view() const +PluginViewPtr VstPlugin::createView() const { ONLY_MAIN_THREAD(threadSecurer); std::lock_guard lock(m_mutex); - if (m_pluginView) { - return m_pluginView; - } - auto controller = m_pluginProvider->getController(); - if (!controller) { return nullptr; } - m_pluginView = owned(controller->createView(PluginEditorViewType::kEditor)); - - return m_pluginView; + return owned(controller->createView(PluginEditorViewType::kEditor)); } PluginProviderPtr VstPlugin::provider() const diff --git a/src/framework/vst/internal/vstplugin.h b/src/framework/vst/internal/vstplugin.h index 91eba46d51d3d..d9c2a2f70f0da 100644 --- a/src/framework/vst/internal/vstplugin.h +++ b/src/framework/vst/internal/vstplugin.h @@ -51,7 +51,7 @@ class VstPlugin : public async::Asyncable const audio::AudioResourceId& resourceId() const; const std::string& name() const; - PluginViewPtr view() const; + PluginViewPtr createView() const; PluginProviderPtr provider() const; bool isAbleForInput() const; @@ -77,7 +77,6 @@ class VstPlugin : public async::Asyncable PluginModulePtr m_module = nullptr; PluginProviderPtr m_pluginProvider = nullptr; - mutable PluginViewPtr m_pluginView = nullptr; ClassInfo m_classInfo; Steinberg::FUnknownPtr m_componentHandlerPtr = nullptr; diff --git a/src/framework/vst/view/abstractvsteditorview.cpp b/src/framework/vst/view/abstractvsteditorview.cpp index 16c29829d007b..74b5f88ba9458 100644 --- a/src/framework/vst/view/abstractvsteditorview.cpp +++ b/src/framework/vst/view/abstractvsteditorview.cpp @@ -115,11 +115,14 @@ void AbstractVstEditorView::wrapPluginView() void AbstractVstEditorView::attachView(VstPluginPtr pluginPtr) { - if (!pluginPtr || !pluginPtr->view()) { + if (!pluginPtr) { return; } - m_view = pluginPtr->view(); + m_view = pluginPtr->createView(); + if (!m_view) { + return; + } if (m_view->isPlatformTypeSupported(currentPlatformUiType()) != Steinberg::kResultTrue) { return; From b119ee7e8c2239e2c6315d3f292b792249d51d9b Mon Sep 17 00:00:00 2001 From: Roman Pudashkin Date: Wed, 14 Dec 2022 17:25:50 +0200 Subject: [PATCH 3/5] fix #14205: some VST plugins don't support more than 1 channel (we use 2 channels by default) --- src/framework/vst/internal/vstaudioclient.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/framework/vst/internal/vstaudioclient.cpp b/src/framework/vst/internal/vstaudioclient.cpp index 6e07517a5877d..36d4a74a4f4ba 100644 --- a/src/framework/vst/internal/vstaudioclient.cpp +++ b/src/framework/vst/internal/vstaudioclient.cpp @@ -316,9 +316,11 @@ void VstAudioClient::extractInputSamples(const audio::samples_t& sampleCount, co return; } + Steinberg::Vst::AudioBusBuffers& bus = m_processData.inputs[0]; + for (unsigned int i = 0; i < sampleCount; ++i) { - for (audio::audioch_t s = 0; s < m_audioChannelsCount; ++s) { - m_processData.inputs[0].channelBuffers32[s][i] = sourceBuffer[i * m_audioChannelsCount + s]; + for (audio::audioch_t s = 0; s < bus.numChannels; ++s) { + bus.channelBuffers32[s][i] = sourceBuffer[i * m_audioChannelsCount + s]; } } } From 23415d5fb48b806aa3335f40294cfa499f95c55c Mon Sep 17 00:00:00 2001 From: Roman Pudashkin Date: Thu, 15 Dec 2022 18:19:58 +0200 Subject: [PATCH 4/5] fixed a crash when using the "no effect" button on an effect that failed to load --- src/framework/vst/internal/vstmodulesrepository.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/framework/vst/internal/vstmodulesrepository.cpp b/src/framework/vst/internal/vstmodulesrepository.cpp index 474283aa2150f..4867e591541b2 100644 --- a/src/framework/vst/internal/vstmodulesrepository.cpp +++ b/src/framework/vst/internal/vstmodulesrepository.cpp @@ -110,7 +110,7 @@ void VstModulesRepository::removePluginModule(const audio::AudioResourceId& reso std::lock_guard lock(m_mutex); auto search = m_modules.find(resourceId); - if (search != m_modules.end()) { + if (search == m_modules.end()) { return; } From 7273044709ba6d8886e6c6d6686ccbcf6c695de1 Mon Sep 17 00:00:00 2001 From: Michele Spagnolo Date: Thu, 12 Jan 2023 10:52:47 +0100 Subject: [PATCH 5/5] Fix crash on deleting "system object" staff correction --- src/engraving/libmscore/edit.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/engraving/libmscore/edit.cpp b/src/engraving/libmscore/edit.cpp index 5083561629bed..3cea486476b85 100644 --- a/src/engraving/libmscore/edit.cpp +++ b/src/engraving/libmscore/edit.cpp @@ -5144,6 +5144,8 @@ void Score::undoRemoveStaff(Staff* staff) staff->undoUnlink(); + mu::remove_if(systemObjectStaves, [staff](Staff* s){ return s == staff; }); + undo(new RemoveStaff(staff)); }