summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTor Arne Vestbø <tor.arne.vestbo@digia.com>2013-12-04 16:38:01 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-12-05 14:06:15 +0100
commit1782fc1e07619a509ca490b55f0a946537e70b97 (patch)
tree0179a4c7dff1b0b0e614d91c27b571880e72b652 /src
parentb86426c81e1c95126ff9b8b84ed5824160c2965b (diff)
Prevent recursive resize events in QAbstractScrollArea
During show() of a QAbstractScrollArea we might get resize events, which results in laying out the children of the scroll area. One of these children are the scrollbars, and raising them to the top means creating them, which in turn means creating all parents, including the abstract scroll area itself. Creating the abstract scroll area means creating a platform window, which might send synchronous resize events as a result of creating the window, and we end up recursing. Change-Id: I1a2813f03091d6c42e51834315835551cb2fd621 Reviewed-by: Jan Arve Sæther <jan-arve.saether@digia.com>
Diffstat (limited to 'src')
-rw-r--r--src/widgets/widgets/qabstractscrollarea.cpp8
-rw-r--r--src/widgets/widgets/qabstractscrollarea_p.h1
2 files changed, 7 insertions, 2 deletions
diff --git a/src/widgets/widgets/qabstractscrollarea.cpp b/src/widgets/widgets/qabstractscrollarea.cpp
index d8ee923f7a..db4ff8a2b7 100644
--- a/src/widgets/widgets/qabstractscrollarea.cpp
+++ b/src/widgets/widgets/qabstractscrollarea.cpp
@@ -167,7 +167,7 @@ QT_BEGIN_NAMESPACE
QAbstractScrollAreaPrivate::QAbstractScrollAreaPrivate()
:hbar(0), vbar(0), vbarpolicy(Qt::ScrollBarAsNeeded), hbarpolicy(Qt::ScrollBarAsNeeded),
- shownOnce(false), sizeAdjustPolicy(QAbstractScrollArea::AdjustIgnored),
+ shownOnce(false), inResize(false), sizeAdjustPolicy(QAbstractScrollArea::AdjustIgnored),
viewport(0), cornerWidget(0), left(0), top(0), right(0), bottom(0),
xoffset(0), yoffset(0), viewportFilter(0)
#ifdef Q_WS_WIN
@@ -995,8 +995,12 @@ bool QAbstractScrollArea::event(QEvent *e)
d->viewport->setMouseTracking(hasMouseTracking());
break;
case QEvent::Resize:
+ if (!d->inResize) {
+ d->inResize = true;
d->layoutChildren();
- break;
+ d->inResize = false;
+ }
+ break;
case QEvent::Show:
if (!d->shownOnce && d->sizeAdjustPolicy == QAbstractScrollArea::AdjustToContentsOnFirstShow) {
d->sizeHint = QSize();
diff --git a/src/widgets/widgets/qabstractscrollarea_p.h b/src/widgets/widgets/qabstractscrollarea_p.h
index 3093c2f812..2a4b20fe81 100644
--- a/src/widgets/widgets/qabstractscrollarea_p.h
+++ b/src/widgets/widgets/qabstractscrollarea_p.h
@@ -76,6 +76,7 @@ public:
Qt::ScrollBarPolicy vbarpolicy, hbarpolicy;
bool shownOnce;
+ bool inResize;
mutable QSize sizeHint;
QAbstractScrollArea::SizeAdjustPolicy sizeAdjustPolicy;