From c82fed057ffd825268ff0f7bdf491d249915a0b4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Sat, 2 Apr 2011 19:01:16 +0200 Subject: [PATCH] Verify that Shadow pixmaps are valid At least in rekonq the shadow pixmaps are not valid causing an exception to be thrown and crashing kwin. --- shadow.cpp | 11 +++++++++-- shadow.h | 2 +- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/shadow.cpp b/shadow.cpp index 422313e1e6..5f3fa4de56 100644 --- a/shadow.cpp +++ b/shadow.cpp @@ -52,7 +52,10 @@ Shadow *Shadow::createShadow(Toplevel *toplevel) #endif } if (shadow) { - shadow->init(data); + if (!shadow->init(data)) { + delete shadow; + return NULL; + } } return shadow; } else { @@ -80,10 +83,13 @@ QVector< long > Shadow::readX11ShadowProperty(WId id) return ret; } -void Shadow::init(const QVector< long > &data) +bool Shadow::init(const QVector< long > &data) { for (int i=0; i &data) const QRect leftRect(- m_leftOffset, - m_topOffset, m_leftOffset, m_topLevel->height() + m_topOffset + m_bottomOffset); m_shadowRegion = QRegion(topRect).united(rightRect).united(bottomRect).united(leftRect); buildQuads(); + return true; } void Shadow::buildQuads() diff --git a/shadow.h b/shadow.h index 6b4719ed57..eb2009f610 100644 --- a/shadow.h +++ b/shadow.h @@ -124,7 +124,7 @@ protected: private: static QVector readX11ShadowProperty(WId id); - void init(const QVector &data); + bool init(const QVector &data); Toplevel *m_topLevel; // shadow pixmaps QPixmap m_shadowElements[ShadowElementsCount];