Add GLShader dtor (fixes memory leak).
Also fix multiple memory leaks in effects. svn path=/branches/work/kwin_composite/; revision=658761
This commit is contained in:
parent
e85930ce1e
commit
24c8663923
6 changed files with 40 additions and 1 deletions
|
@ -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()
|
||||
{
|
||||
|
|
|
@ -28,6 +28,7 @@ class LiquidEffect : public Effect
|
|||
{
|
||||
public:
|
||||
LiquidEffect();
|
||||
~LiquidEffect();
|
||||
|
||||
virtual void prePaintScreen( int* mask, QRegion* region, int time );
|
||||
virtual void postPaintScreen();
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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 );
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -132,6 +132,7 @@ class KWIN_EXPORT GLShader
|
|||
{
|
||||
public:
|
||||
GLShader(const QString& vertexfile, const QString& fragmentfile);
|
||||
~GLShader();
|
||||
|
||||
bool isValid() const { return mValid; }
|
||||
void bind();
|
||||
|
|
Loading…
Reference in a new issue