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.
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));
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,

View File

@ -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);