Commit ebcb531e authored by Hugo Beauzée-Luyssen's avatar Hugo Beauzée-Luyssen

Effects: Force a copy of the parameters strings.

Some of the strings are computed by frei0r using std::string::c_str()
which is not guaranteed to live though the whole program's life time.
parent e13fcab7
......@@ -91,8 +91,9 @@ Effect::load()
}
for ( qint32 i = 0; i < m_nbParams; ++i )
{
f0r_param_info_t *param = new f0r_param_info_t;
m_f0r_get_param_info( param, i );
f0r_param_info_t fParam;
m_f0r_get_param_info( &fParam, i );
Parameter *param = new Parameter( fParam.name, fParam.explanation, fParam.type );
m_params.push_back( param );
}
return true;
......
......@@ -40,7 +40,16 @@ class Effect : public QLibrary
Mixer2 = F0R_PLUGIN_TYPE_MIXER2,
Mixer3 = F0R_PLUGIN_TYPE_MIXER3
};
typedef QList<f0r_param_info_t*> ParamList;
struct Parameter
{
char* name;
char* desc;
int type;
Parameter( const char *_name, const char* _desc, int _type ) :
name( strdup( _name ) ), desc( strdup( _desc ) ), type( _type ) {}
};
typedef QList<Parameter*> ParamList;
typedef int (*f0r_init_t)();
typedef void (*f0r_deinit_t)();
......
......@@ -41,7 +41,7 @@ EffectInstance::EffectInstance( Effect *effect ) :
while ( it != ite )
{
f0r_param_info_t *info = *it;
Effect::Parameter *info = *it;
m_params[info->name] = settingValueFactory( info, i );
++it;
++i;
......@@ -54,14 +54,14 @@ EffectInstance::~EffectInstance()
}
EffectSettingValue*
EffectInstance::settingValueFactory( f0r_param_info_t *info, quint32 index )
EffectInstance::settingValueFactory( Effect::Parameter *info, quint32 index )
{
SettingValue::Flag flags = SettingValue::Nothing;
if ( info->type == F0R_PARAM_DOUBLE )
flags = SettingValue::Clamped;
EffectSettingValue *val = new EffectSettingValue( EffectSettingValue::frei0rToVlmc( info->type ),
this, index, info->name, info->explanation );
this, index, info->name, info->desc );
if ( info->type == F0R_PARAM_DOUBLE )
val->setLimits( 0.0, 1.0 );
return val;
......
......@@ -23,9 +23,10 @@
#ifndef EFFECTINSTANCE_H
#define EFFECTINSTANCE_H
class Effect;
class EffectSettingValue;
#include "Effect.h"
#include <QHash>
#include "frei0r.h"
......@@ -45,7 +46,7 @@ class EffectInstance
protected:
EffectInstance( Effect *effect );
virtual ~EffectInstance();
EffectSettingValue* settingValueFactory( f0r_param_info_t* info, quint32 index );
EffectSettingValue* settingValueFactory( Effect::Parameter* info, quint32 index );
protected:
Effect *m_effect;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment