[vlmc-devel] commit: Effects: Force a copy of the parameters strings. ( Hugo Beauzée-Luyssen )
git at videolan.org
git at videolan.org
Sat Sep 4 22:22:42 CEST 2010
vlmc | branch: master | Hugo Beauzée-Luyssen <beauze.h at gmail.com> | Sat Sep 4 21:41:05 2010 +0200| [ebcb531e3ac0cea7201afa200270b43380eef639] | committer: 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.
> http://git.videolan.org/gitweb.cgi/vlmc.git/?a=commit;h=ebcb531e3ac0cea7201afa200270b43380eef639
---
src/EffectsEngine/Effect.cpp | 5 +++--
src/EffectsEngine/Effect.h | 11 ++++++++++-
src/EffectsEngine/EffectInstance.cpp | 6 +++---
src/EffectsEngine/EffectInstance.h | 5 +++--
4 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/src/EffectsEngine/Effect.cpp b/src/EffectsEngine/Effect.cpp
index 2279d72..56d49cf 100644
--- a/src/EffectsEngine/Effect.cpp
+++ b/src/EffectsEngine/Effect.cpp
@@ -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;
diff --git a/src/EffectsEngine/Effect.h b/src/EffectsEngine/Effect.h
index 30e706e..e250036 100644
--- a/src/EffectsEngine/Effect.h
+++ b/src/EffectsEngine/Effect.h
@@ -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)();
diff --git a/src/EffectsEngine/EffectInstance.cpp b/src/EffectsEngine/EffectInstance.cpp
index d609bef..c9cbfba 100644
--- a/src/EffectsEngine/EffectInstance.cpp
+++ b/src/EffectsEngine/EffectInstance.cpp
@@ -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;
diff --git a/src/EffectsEngine/EffectInstance.h b/src/EffectsEngine/EffectInstance.h
index 65e04b0..5aed39b 100644
--- a/src/EffectsEngine/EffectInstance.h
+++ b/src/EffectsEngine/EffectInstance.h
@@ -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;
More information about the Vlmc-devel
mailing list