mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-28 09:27:39 +01:00
VST3: do not create persistent view to test has_editor()
This is a better variant of 05d2a0f4a4. Mainly becuase
some plugins crash when view->remove() is called for a
view that was never attached.
This commit is contained in:
parent
05d2a0f4a4
commit
c069709939
2 changed files with 46 additions and 20 deletions
|
|
@ -77,6 +77,7 @@ public:
|
|||
tresult PLUGIN_API resizeView (IPlugView* view, ViewRect* newSize) SMTG_OVERRIDE;
|
||||
|
||||
/* GUI */
|
||||
bool has_editor () const;
|
||||
IPlugView* view ();
|
||||
void close_view ();
|
||||
PBD::Signal2<void, int, int> OnResizeView;
|
||||
|
|
@ -152,6 +153,8 @@ private:
|
|||
|
||||
void terminate ();
|
||||
|
||||
IPlugView* try_create_view () const;
|
||||
|
||||
bool connect_components ();
|
||||
bool disconnect_components ();
|
||||
|
||||
|
|
|
|||
|
|
@ -226,17 +226,7 @@ VST3Plugin::possible_output () const
|
|||
bool
|
||||
VST3Plugin::has_editor () const
|
||||
{
|
||||
IPlugView* view = const_cast<VST3PI*>(_plug)->view ();
|
||||
if (view){
|
||||
#ifdef PLATFORM_WINDOWS
|
||||
return kResultOk == view->isPlatformTypeSupported ("HWND");
|
||||
#elif defined (__APPLE__)
|
||||
return kResultOk == view->isPlatformTypeSupported ("NSView");
|
||||
#else
|
||||
return kResultOk == view->isPlatformTypeSupported ("X11EmbedWindowID");
|
||||
#endif
|
||||
}
|
||||
return false;
|
||||
return _plug->has_editor ();
|
||||
}
|
||||
|
||||
Steinberg::IPlugView*
|
||||
|
|
@ -1106,8 +1096,7 @@ VST3PI::unit_data ()
|
|||
void
|
||||
VST3PI::terminate ()
|
||||
{
|
||||
close_view ();
|
||||
|
||||
assert (!_view);
|
||||
/* disable all MIDI busses */
|
||||
set_event_bus_state (false);
|
||||
|
||||
|
|
@ -2209,17 +2198,27 @@ VST3PI::save_state (RAMStream& stream)
|
|||
* GUI
|
||||
*/
|
||||
|
||||
IPlugView*
|
||||
VST3PI::try_create_view () const
|
||||
{
|
||||
IPlugView* view = _controller->createView (Vst::ViewType::kEditor);
|
||||
if (!view) {
|
||||
view = _controller->createView (0);
|
||||
}
|
||||
if (!view) {
|
||||
view = FUnknownPtr<IPlugView> (_controller);
|
||||
if (view) {
|
||||
view->addRef ();
|
||||
}
|
||||
}
|
||||
return view;
|
||||
}
|
||||
|
||||
IPlugView*
|
||||
VST3PI::view ()
|
||||
{
|
||||
if (!_view) {
|
||||
_view = _controller->createView (Vst::ViewType::kEditor);
|
||||
if (!_view) {
|
||||
_view = _controller->createView (0);
|
||||
}
|
||||
if (!_view) {
|
||||
_view = FUnknownPtr<IPlugView> (_controller);
|
||||
}
|
||||
_view = try_create_view ();
|
||||
if (_view) {
|
||||
_view->setFrame (this);
|
||||
}
|
||||
|
|
@ -2239,6 +2238,30 @@ VST3PI::close_view ()
|
|||
_view = 0;
|
||||
}
|
||||
|
||||
bool
|
||||
VST3PI::has_editor () const
|
||||
{
|
||||
IPlugView* view = _view;
|
||||
if (!view){
|
||||
view = try_create_view ();
|
||||
}
|
||||
|
||||
bool rv = false;
|
||||
if (view) {
|
||||
#ifdef PLATFORM_WINDOWS
|
||||
rv = kResultOk == view->isPlatformTypeSupported (kPlatformTypeHWND);
|
||||
#elif defined (__APPLE__)
|
||||
rv = kResultOk == view->isPlatformTypeSupported (kPlatformTypeNSView);
|
||||
#else
|
||||
rv = kResultOk == view->isPlatformTypeSupported (kPlatformTypeX11EmbedWindowID);
|
||||
#endif
|
||||
if (!_view) {
|
||||
view->release ();
|
||||
}
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
#if SMTG_OS_LINUX
|
||||
void
|
||||
VST3PI::set_runloop (Linux::IRunLoop* run_loop)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue