From 659844e273d523101c23690b528029fcbcfed0e1 Mon Sep 17 00:00:00 2001 From: "Aaron J. Seigo" Date: Mon, 16 Jun 2008 19:10:38 +0000 Subject: [PATCH] use the caching (!), don't crash if we get a 0 widget parameter svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=821186 --- applet.cpp | 4 ++-- containment.cpp | 6 ++++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/applet.cpp b/applet.cpp index 9af7afa39..2c0bb87b3 100644 --- a/applet.cpp +++ b/applet.cpp @@ -842,7 +842,7 @@ void Applet::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QW //FIXME: we should probably set the pixmap to screenSize(), but that breaks stuff atm. QPixmap pixmap(boundingRect().size().toSize()); - QGraphicsView* qgv = qobject_cast(widget->parent()); + QGraphicsView* qgv = qobject_cast(widget ? widget->parent() : 0); bool ghost = (qgv && (qgv == d->ghostView)); if (ghost) { @@ -1120,7 +1120,6 @@ void Applet::mouseMoveEvent(QGraphicsSceneMouseEvent *event) parent->setPos(parent->pos() + delta); } - } } @@ -1524,6 +1523,7 @@ void Applet::Private::init() { // WARNING: do not access config() OR globalConfig() in this method! // that requires a scene, which is not available at this point + q->setCacheMode(DeviceCoordinateCache); q->setAcceptsHoverEvents(true); q->setFlag(QGraphicsItem::ItemIsFocusable, true); // FIXME: adding here because nothing seems to be doing it in QGraphicsView, diff --git a/containment.cpp b/containment.cpp index 5c5531a09..b956dbbdf 100644 --- a/containment.cpp +++ b/containment.cpp @@ -104,8 +104,10 @@ Containment::~Containment() void Containment::init() { - setCacheMode(NoCache); - setFlag(QGraphicsItem::ItemIsMovable, false); + if (isContainment()) { + setCacheMode(NoCache); + setFlag(QGraphicsItem::ItemIsMovable, false); + } setFlag(QGraphicsItem::ItemClipsChildrenToShape, false); setAcceptDrops(true); setAcceptsHoverEvents(true);