From 0424c5cec8892280f3bca27c7e041e755e50bdb9 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 (cherry picked from commit dffd9ecfbe659b198954caff45172af91400742e) --- 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 ec04b5e34..16308530e 100644 --- a/plugins/vst_base/vst_plugin.cpp +++ b/plugins/vst_base/vst_plugin.cpp @@ -240,8 +240,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 ) { @@ -252,11 +259,6 @@ void vstPlugin::loadSettings( const QDomElement & _this ) setParameterDump( dump ); } - if( _this.hasAttribute( "chunk" ) ) - { - loadChunk( QByteArray::fromBase64( - _this.attribute( "chunk" ).toAscii() ) ); - } } @@ -268,18 +270,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() ); + } + } }