Fix crash when ending magnifier effect

How did I test that?...
This commit is contained in:
Martin Gräßlin 2011-09-07 09:31:31 +02:00
parent 0740a01c6a
commit 4ed28ed2b0

View file

@ -85,8 +85,16 @@ void MagnifierEffect::prePaintScreen(ScreenPrePaintData& data, int time)
double diff = time / animationTime(500.0); double diff = time / animationTime(500.0);
if (target_zoom > zoom) if (target_zoom > zoom)
zoom = qMin(zoom * qMax(1 + diff, 1.2), target_zoom); zoom = qMin(zoom * qMax(1 + diff, 1.2), target_zoom);
else else {
zoom = qMax(zoom * qMin(1 - diff, 0.8), target_zoom); zoom = qMax(zoom * qMin(1 - diff, 0.8), target_zoom);
if (zoom == 1.0) {
// zoom ended - delete FBO and texture
delete m_fbo;
delete m_texture;
m_fbo = NULL;
m_texture = NULL;
}
}
} }
effects->prePaintScreen(data, time); effects->prePaintScreen(data, time);
if (zoom != 1.0) if (zoom != 1.0)
@ -188,11 +196,13 @@ void MagnifierEffect::zoomOut()
polling = false; polling = false;
effects->stopMousePolling(); effects->stopMousePolling();
} }
if (zoom == target_zoom) {
delete m_fbo; delete m_fbo;
delete m_texture; delete m_texture;
m_fbo = NULL; m_fbo = NULL;
m_texture = NULL; m_texture = NULL;
} }
}
effects->addRepaint(magnifierArea().adjusted(-FRAME_WIDTH, -FRAME_WIDTH, FRAME_WIDTH, FRAME_WIDTH)); effects->addRepaint(magnifierArea().adjusted(-FRAME_WIDTH, -FRAME_WIDTH, FRAME_WIDTH, FRAME_WIDTH));
} }
@ -215,10 +225,6 @@ void MagnifierEffect::toggle()
polling = false; polling = false;
effects->stopMousePolling(); effects->stopMousePolling();
} }
delete m_fbo;
delete m_texture;
m_fbo = NULL;
m_texture = NULL;
} }
effects->addRepaint(magnifierArea().adjusted(-FRAME_WIDTH, -FRAME_WIDTH, FRAME_WIDTH, FRAME_WIDTH)); effects->addRepaint(magnifierArea().adjusted(-FRAME_WIDTH, -FRAME_WIDTH, FRAME_WIDTH, FRAME_WIDTH));
} }