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:
parent
80f675df0d
commit
b7768c774c
@ -266,8 +266,15 @@ Qt::ScrollBarPolicy ScrollWidget::verticalScrollBarPolicy() const
|
|||||||
|
|
||||||
void ScrollWidget::ensureRectVisible(const QRectF &rect)
|
void ScrollWidget::ensureRectVisible(const QRectF &rect)
|
||||||
{
|
{
|
||||||
|
if (!d->widget) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
QRectF viewRect = d->scrollingWidget->boundingRect();
|
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)) {
|
if (viewRect.contains(mappedRect)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user