d->widget can be 0

svn path=/trunk/KDE/kdelibs/; revision=1048893
This commit is contained in:
Aaron J. Seigo 2009-11-14 04:31:06 +00:00
parent 642ac28d10
commit 4162839c2b

View File

@ -288,11 +288,14 @@ void ScrollWidget::setWidget(QGraphicsWidget *widget)
d->widget = widget; d->widget = widget;
Plasma::Animator::self()->registerScrollingManager(this); Plasma::Animator::self()->registerScrollingManager(this);
//it's not good it's setting a size policy here, but it's done to be retrocompatible with older applications //it's not good it's setting a size policy here, but it's done to be retrocompatible with older applications
widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
widget->setParentItem(d->scrollingWidget); if (widget) {
widget->setPos(QPoint(0,0)); widget->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
widget->installEventFilter(this); widget->setParentItem(d->scrollingWidget);
d->adjustScrollbars(); widget->setPos(QPoint(0,0));
widget->installEventFilter(this);
d->adjustScrollbars();
}
} }
QGraphicsWidget *ScrollWidget::widget() const QGraphicsWidget *ScrollWidget::widget() const
@ -395,17 +398,19 @@ QRectF ScrollWidget::viewportGeometry() const
QSizeF ScrollWidget::contentsSize() const QSizeF ScrollWidget::contentsSize() const
{ {
return d->widget->size(); return d->widget ? d->widget->size() : QSizeF();
} }
void ScrollWidget::setScrollPosition(const QPointF &position) void ScrollWidget::setScrollPosition(const QPointF &position)
{ {
d->widget->setPos(-position); if (d->widget) {
d->widget->setPos(-position);
}
} }
QPointF ScrollWidget::scrollPosition() const QPointF ScrollWidget::scrollPosition() const
{ {
return -d->widget->pos(); return d->widget ? -d->widget->pos() : QPointF();
} }
void ScrollWidget::setStyleSheet(const QString &styleSheet) void ScrollWidget::setStyleSheet(const QString &styleSheet)