summaryrefslogtreecommitdiffstats
path: root/src/gui/graphicsview
diff options
context:
space:
mode:
authorYoann Lopes <yoann.lopes@nokia.com>2009-12-07 14:04:42 (GMT)
committerYoann Lopes <yoann.lopes@nokia.com>2009-12-07 14:04:42 (GMT)
commitfb78a402b512b017c850e7410745c4d20da04a7c (patch)
tree0b3a4ec5f08bebf566a3e46e55c228ab9fbcbd9b /src/gui/graphicsview
parent7ad244cad155f32f22e82e1458eb1c42f759a620 (diff)
downloadQt-fb78a402b512b017c850e7410745c4d20da04a7c.zip
Qt-fb78a402b512b017c850e7410745c4d20da04a7c.tar.gz
Qt-fb78a402b512b017c850e7410745c4d20da04a7c.tar.bz2
Fixed memory leaks when removing a QGraphicsEffect from a QGraphicsItem or QWidget
with setGraphicsEffect(0). The effect was not deleted in that case, problem solved for both QGraphicsItem and QWidget. Autotest included. Task-number: QTBUG-5917 Reviewed-by: bnilsen
Diffstat (limited to 'src/gui/graphicsview')
-rw-r--r--src/gui/graphicsview/qgraphicsitem.cpp19
-rw-r--r--src/gui/graphicsview/qgraphicsitem_p.h5
2 files changed, 7 insertions, 17 deletions
diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp
index f93ffdf..9e8d587 100644
--- a/src/gui/graphicsview/qgraphicsitem.cpp
+++ b/src/gui/graphicsview/qgraphicsitem.cpp
@@ -2563,32 +2563,19 @@ void QGraphicsItem::setGraphicsEffect(QGraphicsEffect *effect)
if (d_ptr->graphicsEffect == effect)
return;
- if (d_ptr->graphicsEffect && effect) {
+ if (d_ptr->graphicsEffect) {
delete d_ptr->graphicsEffect;
d_ptr->graphicsEffect = 0;
}
- if (!effect) {
- // Unset current effect.
- QGraphicsEffectPrivate *oldEffectPrivate = d_ptr->graphicsEffect->d_func();
- d_ptr->graphicsEffect = 0;
- if (oldEffectPrivate) {
- oldEffectPrivate->setGraphicsEffectSource(0); // deletes the current source.
- if (d_ptr->scene) { // Update the views directly.
- d_ptr->scene->d_func()->markDirty(this, QRectF(), /*invalidateChildren=*/false,
- /*force=*/false, /*ignoreOpacity=*/false,
- /*removeItemFromScene=*/true);
- }
- }
- } else {
+ if (effect) {
// Set new effect.
QGraphicsEffectSourcePrivate *sourced = new QGraphicsItemEffectSourcePrivate(this);
QGraphicsEffectSource *source = new QGraphicsEffectSource(*sourced);
d_ptr->graphicsEffect = effect;
effect->d_func()->setGraphicsEffectSource(source);
+ prepareGeometryChange();
}
-
- prepareGeometryChange();
}
#endif //QT_NO_GRAPHICSEFFECT
diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h
index d6ffb1a..8f9fe54 100644
--- a/src/gui/graphicsview/qgraphicsitem_p.h
+++ b/src/gui/graphicsview/qgraphicsitem_p.h
@@ -562,7 +562,10 @@ public:
{}
inline void detach()
- { item->setGraphicsEffect(0); }
+ {
+ item->d_ptr->graphicsEffect = 0;
+ item->prepareGeometryChange();
+ }
inline const QGraphicsItem *graphicsItem() const
{ return item; }