Add GLShader dtor (fixes memory leak).

Also fix multiple memory leaks in effects.

svn path=/branches/work/kwin_composite/; revision=658761
icc-effect-5.14.5
Rivo Laks 2007-04-28 13:19:36 +00:00
parent e85930ce1e
commit 24c8663923
6 changed files with 40 additions and 1 deletions

View File

@ -29,9 +29,19 @@ KWIN_EFFECT_SUPPORTED( Demo_Liquid, LiquidEffect::supported() );
LiquidEffect::LiquidEffect() : Effect()
{
mTexture = 0;
mRenderTarget = 0;
mShader = 0;
mTime = 0.0f;
mValid = loadData();
}
LiquidEffect::~LiquidEffect()
{
delete mTexture;
delete mRenderTarget;
delete mShader;
}
bool LiquidEffect::loadData()
{

View File

@ -28,6 +28,7 @@ class LiquidEffect : public Effect
{
public:
LiquidEffect();
~LiquidEffect();
virtual void prePaintScreen( int* mask, QRegion* region, int time );
virtual void postPaintScreen();

View File

@ -28,12 +28,23 @@ KWIN_EFFECT_SUPPORTED( Explosion, ExplosionEffect::supported() );
ExplosionEffect::ExplosionEffect() : Effect()
{
mShader = 0;
mStartOffsetTex = 0;
mEndOffsetTex = 0;
mActiveAnimations = 0;
mValid = true;
mInited = false;
}
bool ExplosionEffect::supported()
ExplosionEffect::~ExplosionEffect()
{
delete mShader;
delete mStartOffsetTex;
delete mEndOffsetTex;
}
bool ExplosionEffect::supported()
{
return GLShader::fragmentShaderSupported() &&
(effects->compositingType() == OpenGLCompositing);

View File

@ -30,6 +30,7 @@ class ExplosionEffect
{
public:
ExplosionEffect();
~ExplosionEffect();
virtual void prePaintScreen( int* mask, QRegion* region, int time );
virtual void prePaintWindow( EffectWindow* w, int* mask, QRegion* paint, QRegion* clip, int time );

View File

@ -495,10 +495,25 @@ GLShader::GLShader(const QString& vertexfile, const QString& fragmentfile)
{
mValid = false;
mVariableLocations = 0;
mProgram = 0;
loadFromFiles(vertexfile, fragmentfile);
}
GLShader::~GLShader()
{
if(mVariableLocations)
{
mVariableLocations->clear();
delete mVariableLocations;
}
if(mProgram)
{
glDeleteProgram(mProgram);
}
}
bool GLShader::loadFromFiles(const QString& vertexfile, const QString& fragmentfile)
{
QFile vf(vertexfile);

View File

@ -132,6 +132,7 @@ class KWIN_EXPORT GLShader
{
public:
GLShader(const QString& vertexfile, const QString& fragmentfile);
~GLShader();
bool isValid() const { return mValid; }
void bind();