mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
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.
This commit is contained in:
parent
e637073228
commit
8c97b09d83
1 changed files with 16 additions and 37 deletions
|
|
@ -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…
Add table
Add a link
Reference in a new issue