Restore actual plugin-preset on session-load
authorRobin Gareus <robin@gareus.org>
Sun, 2 Dec 2018 00:36:32 +0000 (01:36 +0100)
committerRobin Gareus <robin@gareus.org>
Sun, 2 Dec 2018 00:36:32 +0000 (01:36 +0100)
This checks if the preset is actually available on the given system
and also sets the user-flag correctly.

libs/ardour/plugin.cc

index f3d66971b813e1618eb76389cca38b86e6a7468e..fceb87ee8057b926f140e805aa3dab7c0bdf3a3e 100644 (file)
@@ -475,9 +475,18 @@ Plugin::parameter_changed_externally (uint32_t which, float /* value */)
 int
 Plugin::set_state (const XMLNode& node, int /*version*/)
 {
-       node.get_property (X_("last-preset-uri"), _last_preset.uri);
-       node.get_property (X_("last-preset-label"), _last_preset.label);
-       node.get_property (X_("parameter-changed-since-last-preset"), _parameter_changed_since_last_preset);
+       std::string preset_uri;
+       const Plugin::PresetRecord* r = 0;
+       if (node.get_property (X_("last-preset-uri"), preset_uri)) {
+               r = preset_by_uri (preset_uri);
+       }
+       if (r) {
+               _last_preset = *r;
+               node.get_property (X_("parameter-changed-since-last-preset"), _parameter_changed_since_last_preset); // XXX
+       } else {
+               _last_preset.uri = "";
+               _last_preset.valid = false;
+       }
        return 0;
 }