| 218 | } |
| 219 | |
| 220 | OptionalMessage Effect::LoadSettingsFromString( |
| 221 | const wxString & parms, EffectSettings &settings) const |
| 222 | { |
| 223 | // If the string starts with one of certain significant substrings, |
| 224 | // then the rest of the string is reinterpreted as part of a registry key, |
| 225 | // and a user or factory preset is then loaded. |
| 226 | // (Where did these prefixes come from? See EffectPresetsDialog; and |
| 227 | // ultimately the uses of it by EffectManager::GetPreset, which is used by |
| 228 | // the macro management dialog) |
| 229 | wxString preset = parms; |
| 230 | OptionalMessage result; |
| 231 | if (preset.StartsWith(kUserPresetIdent)) |
| 232 | { |
| 233 | preset.Replace(kUserPresetIdent, wxEmptyString, false); |
| 234 | result = LoadUserPreset(UserPresetsGroup(preset), settings); |
| 235 | } |
| 236 | else if (preset.StartsWith(kFactoryPresetIdent)) |
| 237 | { |
| 238 | preset.Replace(kFactoryPresetIdent, wxEmptyString, false); |
| 239 | auto presets = GetFactoryPresets(); |
| 240 | result = LoadFactoryPreset( |
| 241 | make_iterator_range( presets ).index( preset ), settings ); |
| 242 | } |
| 243 | else if (preset.StartsWith(kCurrentSettingsIdent)) |
| 244 | { |
| 245 | preset.Replace(kCurrentSettingsIdent, wxEmptyString, false); |
| 246 | result = LoadUserPreset(CurrentSettingsGroup(), settings); |
| 247 | } |
| 248 | else if (preset.StartsWith(kFactoryDefaultsIdent)) |
| 249 | { |
| 250 | preset.Replace(kFactoryDefaultsIdent, wxEmptyString, false); |
| 251 | result = LoadUserPreset(FactoryDefaultsGroup(), settings); |
| 252 | } |
| 253 | else |
| 254 | { |
| 255 | // If the string did not start with any of the significant substrings, |
| 256 | // then use VisitSettings or LoadSettings to reinterpret it, |
| 257 | // or use LoadSettings. |
| 258 | // This interprets what was written by SaveSettings, above. |
| 259 | CommandParameters eap(parms); |
| 260 | ShuttleSetAutomation S; |
| 261 | S.SetForValidating( &eap ); |
| 262 | // VisitSettings returns false if not defined for this effect. |
| 263 | // To do: fix const_cast in use of VisitSettings |
| 264 | if ( !const_cast<Effect*>(this)->VisitSettings(S, settings) ) { |
| 265 | // the old method... |
| 266 | if (LoadSettings(eap, settings)) |
| 267 | return { nullptr }; |
| 268 | } |
| 269 | else if( !S.bOK ) |
| 270 | result = {}; |
| 271 | else{ |
| 272 | result = { nullptr }; |
| 273 | S.SetForWriting( &eap ); |
| 274 | const_cast<Effect*>(this)->VisitSettings(S, settings); |
| 275 | } |
| 276 | } |
| 277 |
nothing calls this directly
no test coverage detected