Browse Source

AUv3: Avoid calling setFullState: on the superclass during state restoration

On some platforms, the superclass implementation can throw if it detects
that the preset data is malformed, but it's not clear exactly how the
system determines this.

We now apply only the JUCE state.
v7.0.9
reuk 2 years ago
parent
commit
8c97b09d83
No known key found for this signature in database GPG Key ID: FCB43929F012EE5C
1 changed files with 16 additions and 37 deletions
  1. +16
    -37
      modules/juce_audio_plugin_client/juce_audio_plugin_client_AUv3.mm

+ 16
- 37
modules/juce_audio_plugin_client/juce_audio_plugin_client_AUv3.mm View File

@@ -245,16 +245,8 @@ public:
if (state.getSize() > 0)
{
NSData* ourState = [[NSData alloc] initWithBytes: state.getData()
length: state.getSize()];
NSString* nsKey = [[NSString alloc] initWithUTF8String: JUCE_STATE_DICTIONARY_KEY];
[retval setObject: ourState
forKey: nsKey];
[nsKey release];
[ourState release];
[retval setObject: [[NSData alloc] initWithBytes: state.getData() length: state.getSize()]
forKey: @JUCE_STATE_DICTIONARY_KEY];
}
return [retval autorelease];
@@ -265,39 +257,26 @@ public:
if (state == nullptr)
return;
NSMutableDictionary<NSString*, id>* modifiedState = [[NSMutableDictionary<NSString*, id> alloc] init];
[modifiedState addEntriesFromDictionary: state];
NSObject* obj = [state objectForKey: @JUCE_STATE_DICTIONARY_KEY];
NSString* nsPresetKey = [[NSString alloc] initWithUTF8String: kAUPresetDataKey];
[modifiedState removeObjectForKey: nsPresetKey];
[nsPresetKey release];
if (obj == nullptr || ! [obj isKindOfClass: [NSData class]])
return;
ObjCMsgSendSuper<AUAudioUnit, void> (au, @selector (setFullState:), state);
auto* data = reinterpret_cast<NSData*> (obj);
const auto numBytes = static_cast<int> ([data length]);
NSString* nsKey = [[NSString alloc] initWithUTF8String: JUCE_STATE_DICTIONARY_KEY];
NSObject* obj = [modifiedState objectForKey: nsKey];
[nsKey release];
if (numBytes <= 0)
return;
if (obj != nullptr)
{
if ([obj isKindOfClass:[NSData class]])
{
NSData* data = reinterpret_cast<NSData*> (obj);
const int numBytes = static_cast<int> ([data length]);
const juce::uint8* const rawBytes = reinterpret_cast< const juce::uint8* const> ([data bytes]);
auto* rawBytes = reinterpret_cast<const juce::uint8* const> ([data bytes]);
if (numBytes > 0)
{
#if JUCE_AU_WRAPPERS_SAVE_PROGRAM_STATES
getAudioProcessor().setCurrentProgramStateInformation (rawBytes, numBytes);
#else
getAudioProcessor().setStateInformation (rawBytes, numBytes);
#endif
}
}
}
ScopedKeyChange scope (au, @"allParameterValues");
[modifiedState release];
#if JUCE_AU_WRAPPERS_SAVE_PROGRAM_STATES
getAudioProcessor().setCurrentProgramStateInformation (rawBytes, numBytes);
#else
getAudioProcessor().setStateInformation (rawBytes, numBytes);
#endif
}
AUParameterTree* getParameterTree() const


Loading…
Cancel
Save