Use const_iterators for our Effect iterators

We never modify the list, so we don't need the mutuable iterator. This
ensures that the data doesn't get detached.
This commit is contained in:
Martin Gräßlin 2013-07-19 11:34:01 +02:00
parent 4ab0a6a223
commit 13ad458cca
2 changed files with 29 additions and 27 deletions

View file

@ -223,7 +223,7 @@ EffectsHandlerImpl::EffectsHandlerImpl(Compositor *compositor, Scene *scene)
dbus.registerObject("/Effects", this);
dbus.registerService("org.kde.kwin.Effects");
// init is important, otherwise causes crashes when quads are build before the first painting pass start
m_currentBuildQuadsIterator = m_activeEffects.end();
m_currentBuildQuadsIterator = m_activeEffects.constEnd();
Workspace *ws = Workspace::self();
VirtualDesktopManager *vds = VirtualDesktopManager::self();
@ -358,7 +358,7 @@ void EffectsHandlerImpl::slotEffectsQueried()
// the idea is that effects call this function again which calls the next one
void EffectsHandlerImpl::prePaintScreen(ScreenPrePaintData& data, int time)
{
if (m_currentPaintScreenIterator != m_activeEffects.end()) {
if (m_currentPaintScreenIterator != m_activeEffects.constEnd()) {
(*m_currentPaintScreenIterator++)->prePaintScreen(data, time);
--m_currentPaintScreenIterator;
}
@ -367,7 +367,7 @@ void EffectsHandlerImpl::prePaintScreen(ScreenPrePaintData& data, int time)
void EffectsHandlerImpl::paintScreen(int mask, QRegion region, ScreenPaintData& data)
{
if (m_currentPaintScreenIterator != m_activeEffects.end()) {
if (m_currentPaintScreenIterator != m_activeEffects.constEnd()) {
(*m_currentPaintScreenIterator++)->paintScreen(mask, region, data);
--m_currentPaintScreenIterator;
} else
@ -382,8 +382,8 @@ void EffectsHandlerImpl::paintDesktop(int desktop, int mask, QRegion region, Scr
m_currentRenderedDesktop = desktop;
m_desktopRendering = true;
// save the paint screen iterator
QList<Effect*>::iterator savedIterator = m_currentPaintScreenIterator;
m_currentPaintScreenIterator = m_activeEffects.begin();
EffectsIterator savedIterator = m_currentPaintScreenIterator;
m_currentPaintScreenIterator = m_activeEffects.constBegin();
effects->paintScreen(mask, region, data);
// restore the saved iterator
m_currentPaintScreenIterator = savedIterator;
@ -392,7 +392,7 @@ void EffectsHandlerImpl::paintDesktop(int desktop, int mask, QRegion region, Scr
void EffectsHandlerImpl::postPaintScreen()
{
if (m_currentPaintScreenIterator != m_activeEffects.end()) {
if (m_currentPaintScreenIterator != m_activeEffects.constEnd()) {
(*m_currentPaintScreenIterator++)->postPaintScreen();
--m_currentPaintScreenIterator;
}
@ -401,7 +401,7 @@ void EffectsHandlerImpl::postPaintScreen()
void EffectsHandlerImpl::prePaintWindow(EffectWindow* w, WindowPrePaintData& data, int time)
{
if (m_currentPaintWindowIterator != m_activeEffects.end()) {
if (m_currentPaintWindowIterator != m_activeEffects.constEnd()) {
(*m_currentPaintWindowIterator++)->prePaintWindow(w, data, time);
--m_currentPaintWindowIterator;
}
@ -410,7 +410,7 @@ void EffectsHandlerImpl::prePaintWindow(EffectWindow* w, WindowPrePaintData& dat
void EffectsHandlerImpl::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{
if (m_currentPaintWindowIterator != m_activeEffects.end()) {
if (m_currentPaintWindowIterator != m_activeEffects.constEnd()) {
(*m_currentPaintWindowIterator++)->paintWindow(w, mask, region, data);
--m_currentPaintWindowIterator;
} else
@ -419,7 +419,7 @@ void EffectsHandlerImpl::paintWindow(EffectWindow* w, int mask, QRegion region,
void EffectsHandlerImpl::paintEffectFrame(EffectFrame* frame, QRegion region, double opacity, double frameOpacity)
{
if (m_currentPaintEffectFrameIterator != m_activeEffects.end()) {
if (m_currentPaintEffectFrameIterator != m_activeEffects.constEnd()) {
(*m_currentPaintEffectFrameIterator++)->paintEffectFrame(frame, region, opacity, frameOpacity);
--m_currentPaintEffectFrameIterator;
} else {
@ -430,7 +430,7 @@ void EffectsHandlerImpl::paintEffectFrame(EffectFrame* frame, QRegion region, do
void EffectsHandlerImpl::postPaintWindow(EffectWindow* w)
{
if (m_currentPaintWindowIterator != m_activeEffects.end()) {
if (m_currentPaintWindowIterator != m_activeEffects.constEnd()) {
(*m_currentPaintWindowIterator++)->postPaintWindow(w);
--m_currentPaintWindowIterator;
}
@ -447,7 +447,7 @@ Effect *EffectsHandlerImpl::provides(Effect::Feature ef)
void EffectsHandlerImpl::drawWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{
if (m_currentDrawWindowIterator != m_activeEffects.end()) {
if (m_currentDrawWindowIterator != m_activeEffects.constEnd()) {
(*m_currentDrawWindowIterator++)->drawWindow(w, mask, region, data);
--m_currentDrawWindowIterator;
} else
@ -458,14 +458,14 @@ void EffectsHandlerImpl::buildQuads(EffectWindow* w, WindowQuadList& quadList)
{
static bool initIterator = true;
if (initIterator) {
m_currentBuildQuadsIterator = m_activeEffects.begin();
m_currentBuildQuadsIterator = m_activeEffects.constBegin();
initIterator = false;
}
if (m_currentBuildQuadsIterator != m_activeEffects.end()) {
if (m_currentBuildQuadsIterator != m_activeEffects.constEnd()) {
(*m_currentBuildQuadsIterator++)->buildQuads(w, quadList);
--m_currentBuildQuadsIterator;
}
if (m_currentBuildQuadsIterator == m_activeEffects.begin())
if (m_currentBuildQuadsIterator == m_activeEffects.constBegin())
initIterator = true;
}
@ -488,15 +488,15 @@ bool EffectsHandlerImpl::decorationSupportsBlurBehind() const
void EffectsHandlerImpl::startPaint()
{
m_activeEffects.clear();
for(QVector< KWin::EffectPair >::iterator it = loaded_effects.begin(); it != loaded_effects.end(); ++it) {
for(QVector< KWin::EffectPair >::const_iterator it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it) {
if (it->second->isActive()) {
m_activeEffects << it->second;
}
}
m_currentDrawWindowIterator = m_activeEffects.begin();
m_currentPaintWindowIterator = m_activeEffects.begin();
m_currentPaintScreenIterator = m_activeEffects.begin();
m_currentPaintEffectFrameIterator = m_activeEffects.begin();
m_currentDrawWindowIterator = m_activeEffects.constBegin();
m_currentPaintWindowIterator = m_activeEffects.constBegin();
m_currentPaintScreenIterator = m_activeEffects.constBegin();
m_currentPaintEffectFrameIterator = m_activeEffects.constBegin();
}
void EffectsHandlerImpl::slotClientMaximized(KWin::Client *c, KDecorationDefines::MaximizeMode maxMode)
@ -752,7 +752,7 @@ void* EffectsHandlerImpl::getProxy(QString name)
// All effects start with "kwin4_effect_", prepend it to the name
name.prepend("kwin4_effect_");
for (QVector< EffectPair >::iterator it = loaded_effects.begin(); it != loaded_effects.end(); ++it)
for (QVector< EffectPair >::const_iterator it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it)
if ((*it).first == name)
return (*it).second->proxy();
@ -1512,7 +1512,7 @@ void EffectsHandlerImpl::unloadEffect(const QString& name)
void EffectsHandlerImpl::reconfigureEffect(const QString& name)
{
for (QVector< EffectPair >::iterator it = loaded_effects.begin(); it != loaded_effects.end(); ++it)
for (QVector< EffectPair >::const_iterator it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it)
if ((*it).first == name) {
(*it).second->reconfigure(Effect::ReconfigureAll);
return;
@ -1531,7 +1531,7 @@ bool EffectsHandlerImpl::isEffectLoaded(const QString& name) const
void EffectsHandlerImpl::reloadEffect(Effect *effect)
{
QString effectName;
for (QVector< EffectPair >::iterator it = loaded_effects.begin(); it != loaded_effects.end(); ++it) {
for (QVector< EffectPair >::const_iterator it = loaded_effects.constBegin(); it != loaded_effects.constEnd(); ++it) {
if ((*it).second == effect) {
effectName = (*it).first;
break;

View file

@ -254,11 +254,13 @@ private Q_SLOTS:
private:
QList< Effect* > m_activeEffects;
QList< Effect* >::iterator m_currentDrawWindowIterator;
QList< Effect* >::iterator m_currentPaintWindowIterator;
QList< Effect* >::iterator m_currentPaintEffectFrameIterator;
QList< Effect* >::iterator m_currentPaintScreenIterator;
QList< Effect* >::iterator m_currentBuildQuadsIterator;
typedef QList< Effect*> EffectsList;
typedef EffectsList::const_iterator EffectsIterator;
EffectsIterator m_currentDrawWindowIterator;
EffectsIterator m_currentPaintWindowIterator;
EffectsIterator m_currentPaintEffectFrameIterator;
EffectsIterator m_currentPaintScreenIterator;
EffectsIterator m_currentBuildQuadsIterator;
typedef QHash< QByteArray, QList< Effect*> > PropertyEffectMap;
PropertyEffectMap m_propertiesForEffects;
QHash<QByteArray, qulonglong> m_managedProperties;