Check whether the ShaderManager is valid in Explosion effect

The effect did not check whether the ShaderManager is valid causing
a null pointer access when trying to use the shader.

Additionally this change moves the Shader init into the close window
slot as close window referrenced windows without checking whether the
effect would work. If the effect would not work each closed window
would be referrenced without any chance to being unreffed again as this
code is in a block checking whether the effect is valid.

BUG: 291390
FIXED-IN: 4.8.0
This commit is contained in:
Martin Gräßlin 2012-01-13 09:01:36 +01:00
parent 788f32cceb
commit 07685da24e

View file

@ -67,6 +67,9 @@ bool ExplosionEffect::supported()
bool ExplosionEffect::loadData()
{
mInited = true;
if (!ShaderManager::instance()->isValid()) {
return false;
}
QString shadername("explosion");
const QString fragmentshader = KGlobal::dirs()->findResource("data", "kwin/explosion.frag");
QString starttexture = KGlobal::dirs()->findResource("data", "kwin/explosion-start.png");
@ -113,8 +116,6 @@ void ExplosionEffect::prePaintScreen(ScreenPrePaintData& data, int time)
void ExplosionEffect::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
{
if (mWindows.contains(w)) {
if (mValid && !mInited)
mValid = loadData();
if (mValid) {
mWindows[ w ] += time / animationTime(700.0); // complete change in 700ms
if (mWindows[ w ] < 1) {
@ -190,6 +191,12 @@ void ExplosionEffect::slotWindowClosed(EffectWindow* c)
if (e && e != this)
return;
if (c->isOnCurrentDesktop() && !c->isMinimized()) {
if (mValid && !mInited)
mValid = loadData();
if (!mValid) {
// don't add to list as we cannot animate this window;
return;
}
mWindows[ c ] = 0; // count up to 1
c->addRepaintFull();
c->refWindow();