From 9c3c2edd6fe1611bbabb26b3e5a135c2f7a07bab Mon Sep 17 00:00:00 2001 From: PatTheMav Date: Tue, 20 Sep 2022 13:20:01 +0200 Subject: [PATCH] obs-vst: Allow fetching source properties without source Per OBS API documentation, `get_properties` can be used to get the properties of a source, but also of a source type. The latter would pass a NULL pointer for a given source. This adds the necessary change to avoid crashing OBS by passing such a null pointer. --- plugins/obs-vst/obs-vst.cpp | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/plugins/obs-vst/obs-vst.cpp b/plugins/obs-vst/obs-vst.cpp index 590610cfd..d72bdfd68 100644 --- a/plugins/obs-vst/obs-vst.cpp +++ b/plugins/obs-vst/obs-vst.cpp @@ -285,7 +285,6 @@ static void fill_out_plugins(obs_property_t *list) static obs_properties_t *vst_properties(void *data) { - VSTPlugin *vstPlugin = (VSTPlugin *)data; obs_properties_t *props = obs_properties_create(); obs_property_t *list = obs_properties_add_list(props, "plugin_path", PLUG_IN_NAME, @@ -299,14 +298,21 @@ static obs_properties_t *vst_properties(void *data) obs_properties_add_button(props, CLOSE_VST_SETTINGS, CLOSE_VST_TEXT, close_editor_button_clicked); - if (vstPlugin->isEditorOpen()) { - obs_property_set_visible( - obs_properties_get(props, OPEN_VST_SETTINGS), false); - } else { - obs_property_set_visible( - obs_properties_get(props, CLOSE_VST_SETTINGS), false); + bool open_settings_vis = true; + bool close_settings_vis = false; + if (data) { + VSTPlugin *vstPlugin = (VSTPlugin *)data; + if (vstPlugin->isEditorOpen()) { + close_settings_vis = true; + open_settings_vis = false; + } } + obs_property_set_visible(obs_properties_get(props, OPEN_VST_SETTINGS), + open_settings_vis); + obs_property_set_visible(obs_properties_get(props, CLOSE_VST_SETTINGS), + close_settings_vis); + obs_properties_add_bool(props, OPEN_WHEN_ACTIVE_VST_SETTINGS, OPEN_WHEN_ACTIVE_VST_TEXT);