check for null widget

bound the passed rect to the widget bounding rect

svn path=/trunk/KDE/kdelibs/; revision=1027836
This commit is contained in:
Marco Martin 2009-09-24 21:27:40 +00:00
parent 80f675df0d
commit b7768c774c

View File

@ -266,8 +266,15 @@ Qt::ScrollBarPolicy ScrollWidget::verticalScrollBarPolicy() const
void ScrollWidget::ensureRectVisible(const QRectF &rect)
{
if (!d->widget) {
return;
}
QRectF viewRect = d->scrollingWidget->boundingRect();
QRectF mappedRect = d->widget->mapToItem(d->scrollingWidget, rect).boundingRect();
//ensure the rect is not outside the widget bounding rect
QRectF mappedRect = QRectF(QPointF(qBound((qreal)0.0, rect.x(), d->widget->size().width()-rect.width()),
qBound((qreal)0.0, rect.y(), d->widget->size().height()-rect.height())), rect.size());
mappedRect = d->widget->mapToItem(d->scrollingWidget, mappedRect).boundingRect();
if (viewRect.contains(mappedRect)) {
return;
}