use the caching (!), don't crash if we get a 0 widget parameter

svn path=/trunk/KDE/kdebase/workspace/libs/plasma/; revision=821186
This commit is contained in:
Aaron J. Seigo 2008-06-16 19:10:38 +00:00
parent 996da901e2
commit 659844e273
2 changed files with 6 additions and 4 deletions

View File

@ -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. //FIXME: we should probably set the pixmap to screenSize(), but that breaks stuff atm.
QPixmap pixmap(boundingRect().size().toSize()); QPixmap pixmap(boundingRect().size().toSize());
QGraphicsView* qgv = qobject_cast<QGraphicsView*>(widget->parent()); QGraphicsView* qgv = qobject_cast<QGraphicsView*>(widget ? widget->parent() : 0);
bool ghost = (qgv && (qgv == d->ghostView)); bool ghost = (qgv && (qgv == d->ghostView));
if (ghost) { if (ghost) {
@ -1120,7 +1120,6 @@ void Applet::mouseMoveEvent(QGraphicsSceneMouseEvent *event)
parent->setPos(parent->pos() + delta); parent->setPos(parent->pos() + delta);
} }
} }
} }
@ -1524,6 +1523,7 @@ void Applet::Private::init()
{ {
// WARNING: do not access config() OR globalConfig() in this method! // WARNING: do not access config() OR globalConfig() in this method!
// that requires a scene, which is not available at this point // that requires a scene, which is not available at this point
q->setCacheMode(DeviceCoordinateCache);
q->setAcceptsHoverEvents(true); q->setAcceptsHoverEvents(true);
q->setFlag(QGraphicsItem::ItemIsFocusable, true); q->setFlag(QGraphicsItem::ItemIsFocusable, true);
// FIXME: adding here because nothing seems to be doing it in QGraphicsView, // FIXME: adding here because nothing seems to be doing it in QGraphicsView,

View File

@ -104,8 +104,10 @@ Containment::~Containment()
void Containment::init() void Containment::init()
{ {
setCacheMode(NoCache); if (isContainment()) {
setFlag(QGraphicsItem::ItemIsMovable, false); setCacheMode(NoCache);
setFlag(QGraphicsItem::ItemIsMovable, false);
}
setFlag(QGraphicsItem::ItemClipsChildrenToShape, false); setFlag(QGraphicsItem::ItemClipsChildrenToShape, false);
setAcceptDrops(true); setAcceptDrops(true);
setAcceptsHoverEvents(true); setAcceptsHoverEvents(true);