fixed a broken VST window after re-opening it on windows (the problem can be reproduced, for example, with Vital Audio or Valhalla Supermassive)

This commit is contained in:
Roman Pudashkin 2022-12-16 16:12:51 +02:00
parent 5c1a04ef1d
commit bb08f4c466
3 changed files with 8 additions and 14 deletions

View file

@ -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, static_cast<size_t>(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

View file

@ -51,7 +51,7 @@ public:
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 @@ private:
PluginModulePtr m_module = nullptr;
PluginProviderPtr m_pluginProvider = nullptr;
mutable PluginViewPtr m_pluginView = nullptr;
ClassInfo m_classInfo;
Steinberg::FUnknownPtr<VstComponentHandler> m_componentHandlerPtr = nullptr;

View file

@ -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;