From dffd9ecfbe659b198954caff45172af91400742e Mon Sep 17 00:00:00 2001 From: Tobias Doerffel Date: Tue, 7 Jul 2009 21:18:27 +0200 Subject: [PATCH] RemoteVstPlugin: prefer chunks over parameters for settings When saving or restoring settings, prefer chunks over parameters. This fixes some problems with plugins which get confused e.g. if you restore individual parameters rather than the whole chunk. Signed-off-by: Tobias Doerffel --- plugins/vst_base/vst_plugin.cpp | 35 +++++++++++++++++++++------------ 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/plugins/vst_base/vst_plugin.cpp b/plugins/vst_base/vst_plugin.cpp index e0f143a87..d3fcf5995 100644 --- a/plugins/vst_base/vst_plugin.cpp +++ b/plugins/vst_base/vst_plugin.cpp @@ -241,8 +241,15 @@ void vstPlugin::loadSettings( const QDomElement & _this ) } const int num_params = _this.attribute( "numparams" ).toInt(); - if( num_params > 0 ) + // if it exists try to load settings chunk + if( _this.hasAttribute( "chunk" ) ) { + loadChunk( QByteArray::fromBase64( + _this.attribute( "chunk" ).toAscii() ) ); + } + else if( num_params > 0 ) + { + // no chunk, restore individual parameters QMap dump; for( int i = 0; i < num_params; ++i ) { @@ -253,11 +260,6 @@ void vstPlugin::loadSettings( const QDomElement & _this ) setParameterDump( dump ); } - if( _this.hasAttribute( "chunk" ) ) - { - loadChunk( QByteArray::fromBase64( - _this.attribute( "chunk" ).toAscii() ) ); - } } @@ -269,18 +271,25 @@ void vstPlugin::saveSettings( QDomDocument & _doc, QDomElement & _this ) { _this.setAttribute( "guivisible", pluginWidget()->isVisible() ); } - const QMap & dump = parameterDump(); - _this.setAttribute( "numparams", dump.size() ); - for( QMap::const_iterator it = dump.begin(); - it != dump.end(); ++it ) - { - _this.setAttribute( it.key(), it.value() ); - } + + // try to save all settings in a chunk QByteArray chunk = saveChunk(); if( !chunk.isEmpty() ) { _this.setAttribute( "chunk", QString( chunk.toBase64() ) ); } + else + { + // plugin doesn't seem to support chunks, therefore save + // individual parameters + const QMap & dump = parameterDump(); + _this.setAttribute( "numparams", dump.size() ); + for( QMap::const_iterator it = dump.begin(); + it != dump.end(); ++it ) + { + _this.setAttribute( it.key(), it.value() ); + } + } }