use qweakpointer to prevent crashs

svn path=/trunk/KDE/kdelibs/; revision=1048662
This commit is contained in:
Igor Trindade Oliveira 2009-11-13 17:38:04 +00:00
parent 0d38c4cfa8
commit 11ca7e2b29

View File

@ -24,6 +24,8 @@
#include <QGraphicsRotation> #include <QGraphicsRotation>
#include <QSequentialAnimationGroup> #include <QSequentialAnimationGroup>
#include <QWeakPointer>
#include <kdebug.h> #include <kdebug.h>
namespace Plasma namespace Plasma
@ -36,7 +38,7 @@ class RotationStackedAnimationPrivate {
qint8 reference; qint8 reference;
QGraphicsWidget *backWidget; QWeakPointer<QGraphicsWidget> backWidget;
QSequentialAnimationGroup *groupAnim; QSequentialAnimationGroup *groupAnim;
StackedLayout *sLayout; StackedLayout *sLayout;
}; };
@ -71,7 +73,7 @@ qint8 RotationStackedAnimation::reference() const
QGraphicsWidget *RotationStackedAnimation::backWidget() QGraphicsWidget *RotationStackedAnimation::backWidget()
{ {
return d->backWidget; return d->backWidget.data();
} }
void RotationStackedAnimation::setBackWidget(QGraphicsWidget *backWidget) void RotationStackedAnimation::setBackWidget(QGraphicsWidget *backWidget)
@ -80,7 +82,7 @@ void RotationStackedAnimation::setBackWidget(QGraphicsWidget *backWidget)
if(widgetToAnimate()) { if(widgetToAnimate()) {
d->sLayout->addWidget(widgetToAnimate()); d->sLayout->addWidget(widgetToAnimate());
d->sLayout->addWidget(backWidget); d->sLayout->addWidget(d->backWidget.data());
} }
} }
@ -93,7 +95,7 @@ QAbstractAnimation *RotationStackedAnimation::render(QObject *parent)
{ {
Q_UNUSED(parent); Q_UNUSED(parent);
bool dirty = false; bool dirty = false;
QPair<QGraphicsWidget *,QGraphicsWidget *> widgets = qMakePair(widgetToAnimate(), d->backWidget); QPair<QGraphicsWidget *,QGraphicsWidget *> widgets = qMakePair(widgetToAnimate(), backWidget());
QPropertyAnimation *frontAnim, *backAnim; QPropertyAnimation *frontAnim, *backAnim;
d->groupAnim = dynamic_cast<QSequentialAnimationGroup* >(animation()); d->groupAnim = dynamic_cast<QSequentialAnimationGroup* >(animation());
if (!d->groupAnim) { if (!d->groupAnim) {