diff --git a/modules/juce_audio_plugin_client/juce_audio_plugin_client_AU_1.mm b/modules/juce_audio_plugin_client/juce_audio_plugin_client_AU_1.mm index a781b0f60c..7d6f7aa822 100644 --- a/modules/juce_audio_plugin_client/juce_audio_plugin_client_AU_1.mm +++ b/modules/juce_audio_plugin_client/juce_audio_plugin_client_AU_1.mm @@ -785,6 +785,27 @@ public: // Remove the data entry from the state to prevent the superclass loading the parameters CFUniquePtr copyWithoutData (CFDictionaryCreateMutableCopy (nullptr, 0, (CFDictionaryRef) inData)); CFDictionaryRemoveValue (copyWithoutData.get(), CFSTR (kAUPresetDataKey)); + + auto* originalVersion = static_cast (CFDictionaryGetValue (copyWithoutData.get(), CFSTR (kAUPresetVersionKey))); + if (originalVersion != nullptr && CFGetTypeID (originalVersion) == CFNumberGetTypeID()) + { + SInt32 value = 0; + CFNumberGetValue (originalVersion, kCFNumberSInt32Type, &value); + + // Data with a version of "1" is generated by AUv3 plug-ins. + // This data appears to be compatible with RestoreState below, but RestoreState + // fails when "version" is not 0. + // We only overwrite the version if it is 1 so that if future preset versions are + // completely incompatible, RestoreState will be bypassed rather than passed data + // which could put the plugin into a broken state. + if (value == 1) + { + const SInt32 zero = 0; + CFUniquePtr newVersion (CFNumberCreate (nullptr, kCFNumberSInt32Type, &zero)); + CFDictionarySetValue (copyWithoutData.get(), CFSTR (kAUPresetVersionKey), newVersion.get()); + } + } + ComponentResult err = MusicDeviceBase::RestoreState (copyWithoutData.get()); if (err != noErr)