libobs: Handle removed plugins for versioned sources

When someone adds a source and the plugin is removed for whatever
reason, it would cause a crash with the new source versioning system.
This fixes that by ensuring the unversioned id is also backed up along
with the normal id.
This commit is contained in:
jp9000
2020-03-09 16:53:44 -07:00
parent 8d5ab2be3b
commit 19068c2960
2 changed files with 8 additions and 1 deletions

View File

@@ -341,6 +341,7 @@ obs_source_create_internal(const char *id, const char *name,
source->info.id = bstrdup(id);
source->owns_info_id = true;
source->info.unversioned_id = bstrdup(source->info.id);
} else {
source->info = *info;
@@ -661,8 +662,10 @@ void obs_source_destroy(struct obs_source *source)
obs_data_release(source->private_settings);
obs_context_data_free(&source->context);
if (source->owns_info_id)
if (source->owns_info_id) {
bfree((void *)source->info.id);
bfree((void *)source->info.unversioned_id);
}
bfree(source);
}

View File

@@ -1839,6 +1839,10 @@ static obs_source_t *obs_load_source_type(obs_data_t *source_data)
source = obs_source_create_set_last_ver(v_id, name, settings, hotkeys,
prev_ver);
if (source->owns_info_id) {
bfree((void *)source->info.unversioned_id);
source->info.unversioned_id = bstrdup(id);
}
obs_data_release(hotkeys);