From dc1045b8cbb86ee7fa67a3bac3318ebe63ce6d2c Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Mon, 31 Aug 2009 12:29:44 +0000 Subject: [PATCH] * proper sizes * don't crash on null target svn path=/trunk/KDE/kdelibs/; revision=1017771 --- widgets/itembackground.cpp | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/widgets/itembackground.cpp b/widgets/itembackground.cpp index c3fb997d2..6638371a1 100644 --- a/widgets/itembackground.cpp +++ b/widgets/itembackground.cpp @@ -69,14 +69,16 @@ ItemBackground::ItemBackground(QGraphicsWidget *parent) d->fading = false; d->fadeIn = false; d->immediate = false; - qreal l, t, r, b; - d->frameSvg->getMargins(l, t, r, b); - setContentsMargins(l, t, r, b); d->frameSvg->setImagePath("widgets/viewitem"); d->frameSvg->setEnabledBorders(Plasma::FrameSvg::AllBorders); d->frameSvg->setCacheAllRenderedFrames(true); d->frameSvg->setElementPrefix("hover"); + + qreal l, t, r, b; + d->frameSvg->getMargins(l, t, r, b); + setContentsMargins(l, t, r, b); + connect(d->frameSvg, SIGNAL(repaintNeeded()), this, SLOT(frameSvgChanged())); setAcceptedMouseButtons(0); @@ -90,11 +92,8 @@ ItemBackground::~ItemBackground() void ItemBackground::setTarget(const QRectF &newGeometry) { - qreal left, top, right, bottom; - d->frameSvg->getMargins(left, top, right, bottom); - d->oldGeometry = geometry(); - d->newGeometry = newGeometry.adjusted(-left, -top, right, bottom); + d->newGeometry = newGeometry; if (!isVisible()) { setGeometry(d->newGeometry); @@ -122,7 +121,7 @@ void ItemBackground::setTargetItem(QGraphicsItem *target) d->target->removeSceneEventFilter(this); QObject *obj = 0; - if (target->isWidget()) { + if (target && target->isWidget()) { obj = static_cast(target); } else { obj = dynamic_cast(target);