From 0501aefd695802eb3d382c9786dbd1dc8deea244 Mon Sep 17 00:00:00 2001 From: Robbert van der Helm Date: Sun, 12 Mar 2023 13:29:03 +0100 Subject: [PATCH] Allow missing Compatibility sections in moduleinfo Don't know why anyone would do this though. --- CHANGELOG.md | 7 +++++++ tools/yabridgectl/src/vst3_moduleinfo.rs | 17 ++++++++++++----- 2 files changed, 19 insertions(+), 5 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index c0a4a868..17b18bae 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,13 @@ Versioning](https://semver.org/spec/v2.0.0.html). makes sure that Wine will keep using X11 even if Wayland support becomes available at some point. +### yabridgectl + +- VST 3.7.5 `moduleinfo.json` files without a `Compatibility` field are now + supported. Previously this would result in a parsing error because the whole + point of the `moduleinfo.json` files is to provide `Compatibility` mappings + for older VST2 plugins. + ## [5.0.4] - 2023-02-23 ### Fixed diff --git a/tools/yabridgectl/src/vst3_moduleinfo.rs b/tools/yabridgectl/src/vst3_moduleinfo.rs index e9d8b8a4..4a2f7f99 100644 --- a/tools/yabridgectl/src/vst3_moduleinfo.rs +++ b/tools/yabridgectl/src/vst3_moduleinfo.rs @@ -28,8 +28,12 @@ use std::fmt::Write; pub struct ModuleInfo { #[serde(rename = "Classes")] classes: Vec, + // The whole point of moduleinfo.json is so plugins can provide these compatibility mappings, + // but apparently there are now plugins that have a moduleinfo file without compatibility + // mappings + #[serde(skip_serializing_if = "Option::is_none")] #[serde(rename = "Compatibility")] - compatibility_mappings: Vec, + compatibility_mappings: Option>, #[serde(flatten)] other: serde_jsonrc::Map, } @@ -64,10 +68,13 @@ impl ModuleInfo { class.cid = encode_hex_uid(&rewrite_uid_byte_order(&decode_hex_uid(&class.cid)?)); } - for mapping in &mut self.compatibility_mappings { - mapping.new = encode_hex_uid(&rewrite_uid_byte_order(&decode_hex_uid(&mapping.new)?)); - for cid in &mut mapping.old { - *cid = encode_hex_uid(&rewrite_uid_byte_order(&decode_hex_uid(cid)?)) + if let Some(compatibility_mappings) = &mut self.compatibility_mappings { + for mapping in compatibility_mappings { + mapping.new = + encode_hex_uid(&rewrite_uid_byte_order(&decode_hex_uid(&mapping.new)?)); + for cid in &mut mapping.old { + *cid = encode_hex_uid(&rewrite_uid_byte_order(&decode_hex_uid(cid)?)) + } } }