EffectChain: remember original effect plugin data when loading dummy plugin
We don't want to loose the settings of an effect plugin even if it's not available and thus can't be instantiated. Therefore remember original settings data and save them back properly. Partly closes #733.
This commit is contained in:
@@ -82,9 +82,10 @@ public:
|
||||
class DummyEffect : public Effect
|
||||
{
|
||||
public:
|
||||
DummyEffect( Model * _parent ) :
|
||||
DummyEffect( Model * _parent, const QDomElement& originalPluginData ) :
|
||||
Effect( NULL, _parent, NULL ),
|
||||
m_controls( this )
|
||||
m_controls( this ),
|
||||
m_originalPluginData( originalPluginData )
|
||||
{
|
||||
}
|
||||
|
||||
@@ -102,9 +103,16 @@ public:
|
||||
return false;
|
||||
}
|
||||
|
||||
const QDomElement& originalPluginData() const
|
||||
{
|
||||
return m_originalPluginData;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private:
|
||||
DummyEffectControls m_controls;
|
||||
const QDomElement m_originalPluginData;
|
||||
|
||||
} ;
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Effect.cpp - base-class for effects
|
||||
*
|
||||
* Copyright (c) 2006-2007 Danny McRae <khjklujn/at/users.sourceforge.net>
|
||||
* Copyright (c) 2006-2009 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
* Copyright (c) 2006-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
|
||||
*
|
||||
* This file is part of Linux MultiMedia Studio - http://lmms.sourceforge.net
|
||||
*
|
||||
@@ -23,7 +23,6 @@
|
||||
*
|
||||
*/
|
||||
|
||||
|
||||
#include <QtXml/QDomElement>
|
||||
|
||||
#include <cstdio>
|
||||
@@ -31,8 +30,8 @@
|
||||
|
||||
#include "Effect.h"
|
||||
#include "engine.h"
|
||||
#include "DummyEffect.h"
|
||||
#include "EffectChain.h"
|
||||
#include "EffectControls.h"
|
||||
#include "EffectView.h"
|
||||
|
||||
|
||||
@@ -110,11 +109,11 @@ void Effect::loadSettings( const QDomElement & _this )
|
||||
|
||||
|
||||
|
||||
Effect * Effect::instantiate( const QString & _plugin_name,
|
||||
Effect * Effect::instantiate( const QString& pluginName,
|
||||
Model * _parent,
|
||||
Descriptor::SubPluginFeatures::Key * _key )
|
||||
{
|
||||
Plugin * p = Plugin::instantiate( _plugin_name, _parent, _key );
|
||||
Plugin * p = Plugin::instantiate( pluginName, _parent, _key );
|
||||
// check whether instantiated plugin is an effect
|
||||
if( dynamic_cast<Effect *>( p ) != NULL )
|
||||
{
|
||||
@@ -124,9 +123,10 @@ Effect * Effect::instantiate( const QString & _plugin_name,
|
||||
return effect;
|
||||
}
|
||||
|
||||
// not quite... so delete plugin and return dummy effect
|
||||
// not quite... so delete plugin and leave it up to the caller to instantiate a DummyEffect
|
||||
delete p;
|
||||
return new DummyEffect( _parent );
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -56,12 +56,19 @@ void EffectChain::saveSettings( QDomDocument & _doc, QDomElement & _this )
|
||||
{
|
||||
_this.setAttribute( "enabled", m_enabledModel.value() );
|
||||
_this.setAttribute( "numofeffects", m_effects.count() );
|
||||
for( EffectList::Iterator it = m_effects.begin();
|
||||
it != m_effects.end(); it++ )
|
||||
|
||||
for( EffectList::Iterator it = m_effects.begin(); it != m_effects.end(); it++ )
|
||||
{
|
||||
QDomElement ef = ( *it )->saveState( _doc, _this );
|
||||
ef.setAttribute( "name", ( *it )->descriptor()->name );
|
||||
ef.appendChild( ( *it )->key().saveXML( _doc ) );
|
||||
if( dynamic_cast<DummyEffect *>( *it ) )
|
||||
{
|
||||
_this.appendChild( dynamic_cast<DummyEffect *>( *it )->originalPluginData() );
|
||||
}
|
||||
else
|
||||
{
|
||||
QDomElement ef = ( *it )->saveState( _doc, _this );
|
||||
ef.setAttribute( "name", ( *it )->descriptor()->name );
|
||||
ef.appendChild( ( *it )->key().saveXML( _doc ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -82,26 +89,23 @@ void EffectChain::loadSettings( const QDomElement & _this )
|
||||
{
|
||||
if( node.isElement() && node.nodeName() == "effect" )
|
||||
{
|
||||
QDomElement cn = node.toElement();
|
||||
const QString name = cn.attribute( "name" );
|
||||
EffectKey key( cn.elementsByTagName( "key" ).
|
||||
item( 0 ).toElement() );
|
||||
Effect * e = Effect::instantiate( name, this, &key );
|
||||
if( e->isOkay() )
|
||||
QDomElement effectData = node.toElement();
|
||||
|
||||
const QString name = effectData.attribute( "name" );
|
||||
EffectKey key( effectData.elementsByTagName( "key" ).item( 0 ).toElement() );
|
||||
|
||||
Effect* e = Effect::instantiate( name, this, &key );
|
||||
|
||||
if( e != NULL && e->isOkay() && e->nodeName() == node.nodeName() )
|
||||
{
|
||||
if( node.isElement() )
|
||||
{
|
||||
if( e->nodeName() == node.nodeName() )
|
||||
{
|
||||
e->restoreState( node.toElement() );
|
||||
}
|
||||
}
|
||||
e->restoreState( effectData );
|
||||
}
|
||||
else
|
||||
{
|
||||
delete e;
|
||||
e = new DummyEffect( parentModel() );
|
||||
e = new DummyEffect( parentModel(), effectData );
|
||||
}
|
||||
|
||||
m_effects.push_back( e );
|
||||
++fx_loaded;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user