From 7e5107d4317d45c2fa3b6947011f3e44dedabdee Mon Sep 17 00:00:00 2001 From: Christopher Snowhill Date: Sat, 29 Jan 2022 16:38:53 -0800 Subject: [PATCH] User Settings: Obey standards Replace "midi.plugin" with "midiPlugin", as per the value naming conventions that Apple set out. Migrate the old value if found. Signed-off-by: Christopher Snowhill --- Application/AppController.m | 12 +++++++++--- Plugins/MIDI/MIDI/MIDIDecoder.mm | 4 ++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/Application/AppController.m b/Application/AppController.m index 87502ef39..9012ebd02 100644 --- a/Application/AppController.m +++ b/Application/AppController.m @@ -485,7 +485,7 @@ void* kAppControllerContext = &kAppControllerContext; [userDefaultsValuesDict setObject:[NSNumber numberWithInteger:-1] forKey:@"lastTrackPlaying"]; [userDefaultsValuesDict setObject:[NSNumber numberWithDouble:0] forKey:@"lastTrackPosition"]; - [userDefaultsValuesDict setObject:@"dls appl" forKey:@"midi.plugin"]; + [userDefaultsValuesDict setObject:@"dls appl" forKey:@"midiPlugin"]; [userDefaultsValuesDict setObject:@"default" forKey:@"midi.flavor"]; @@ -507,8 +507,14 @@ void* kAppControllerContext = &kAppControllerContext; [[NSUserDefaults standardUserDefaults] setValue:feedURLdefault forKey:@"SUFeedURL"]; } - if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"midi.plugin"] isEqualToString:@"BASSMIDI"]) { - [[NSUserDefaults standardUserDefaults] setValue:@"FluidSynth" forKey:@"midi.plugin"]; + if ([[[NSUserDefaults standardUserDefaults] stringForKey:@"midiPlugin"] isEqualToString:@"BASSMIDI"]) { + [[NSUserDefaults standardUserDefaults] setValue:@"FluidSynth" forKey:@"midiPlugin"]; + } + + NSString * oldMidiPlugin = [[NSUserDefaults standardUserDefaults] stringForKey:@"midi.plugin"]; + if (oldMidiPlugin) { + [[NSUserDefaults standardUserDefaults] setValue:oldMidiPlugin forKey:@"midiPlugin"]; + [[NSUserDefaults standardUserDefaults] removeObjectForKey:@"midi.plugin"]; } } diff --git a/Plugins/MIDI/MIDI/MIDIDecoder.mm b/Plugins/MIDI/MIDI/MIDIDecoder.mm index af7541669..ae2957916 100755 --- a/Plugins/MIDI/MIDI/MIDIDecoder.mm +++ b/Plugins/MIDI/MIDI/MIDIDecoder.mm @@ -183,13 +183,13 @@ static OSType getOSType(const char * in_) [[NSUserDefaults standardUserDefaults] setValue:globalSoundFontPath forKey:@"soundFontPath"]; } - NSString * plugin = [[NSUserDefaults standardUserDefaults] stringForKey:@"midi.plugin"]; + NSString * plugin = [[NSUserDefaults standardUserDefaults] stringForKey:@"midiPlugin"]; // Then detect if we should force the DLSMusicSynth, which has its own bank if (!plugin || [plugin isEqualToString:@"FluidSynth"]) { if (!globalSoundFontPath || [globalSoundFontPath isEqualToString:@""]) { plugin = @"dls appl"; // Apple DLSMusicSynth if soundfont doesn't exist - [[NSUserDefaults standardUserDefaults] setValue:plugin forKey:@"midi.plugin"]; + [[NSUserDefaults standardUserDefaults] setValue:plugin forKey:@"midiPlugin"]; } }