summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQt Continuous Integration System <qt-info@nokia.com>2011-06-16 07:08:34 (GMT)
committerQt Continuous Integration System <qt-info@nokia.com>2011-06-16 07:08:34 (GMT)
commit61aae4e9a033bfb59664105e5377fd086bacb517 (patch)
tree92f6f6d70713be3e0033c6cf841e0b4e87e33512 /src
parent3efaed62e11e9e461f7244a99a233140b9f28510 (diff)
parent6fa05b234e2bb6fdabcaf5eb4550b0b32a434fd1 (diff)
downloadQt-61aae4e9a033bfb59664105e5377fd086bacb517.zip
Qt-61aae4e9a033bfb59664105e5377fd086bacb517.tar.gz
Qt-61aae4e9a033bfb59664105e5377fd086bacb517.tar.bz2
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-water-staging into 4.7-integration
* '4.7' of scm.dev.nokia.troll.no:qt/qt-water-staging: Fixes to how resize event and layout request are posted. Fixed move a QGraphicsWidget and invalidate its layout at the same time Fix infinite recursion when changing geometry on Mac
Diffstat (limited to 'src')
-rw-r--r--src/gui/graphicsview/qgraphicslayout.cpp14
-rw-r--r--src/gui/graphicsview/qgraphicswidget.cpp19
-rw-r--r--src/gui/graphicsview/qgraphicswidget.h2
-rw-r--r--src/gui/graphicsview/qgraphicswidget_p.cpp14
-rw-r--r--src/gui/graphicsview/qgraphicswidget_p.h5
-rw-r--r--src/gui/kernel/qwidget_mac.mm12
6 files changed, 35 insertions, 31 deletions
diff --git a/src/gui/graphicsview/qgraphicslayout.cpp b/src/gui/graphicsview/qgraphicslayout.cpp
index b37dfd4..f983955 100644
--- a/src/gui/graphicsview/qgraphicslayout.cpp
+++ b/src/gui/graphicsview/qgraphicslayout.cpp
@@ -269,18 +269,8 @@ void QGraphicsLayout::activate()
return;
Q_ASSERT(!parentItem->isLayout());
- if (QGraphicsLayout::instantInvalidatePropagation()) {
- QGraphicsWidget *parentWidget = static_cast<QGraphicsWidget*>(parentItem);
- if (!parentWidget->parentLayoutItem()) {
- // we've reached the topmost widget, resize it
- bool wasResized = parentWidget->testAttribute(Qt::WA_Resized);
- parentWidget->resize(parentWidget->size());
- parentWidget->setAttribute(Qt::WA_Resized, wasResized);
- }
-
- setGeometry(parentItem->contentsRect()); // relayout children
- } else {
- setGeometry(parentItem->contentsRect()); // relayout children
+ setGeometry(parentItem->contentsRect()); // relayout children
+ if (!QGraphicsLayout::instantInvalidatePropagation()) {
parentLayoutItem()->updateGeometry();
}
}
diff --git a/src/gui/graphicsview/qgraphicswidget.cpp b/src/gui/graphicsview/qgraphicswidget.cpp
index 804394a..965b1b34 100644
--- a/src/gui/graphicsview/qgraphicswidget.cpp
+++ b/src/gui/graphicsview/qgraphicswidget.cpp
@@ -347,11 +347,10 @@ void QGraphicsWidget::setGeometry(const QRectF &rect)
{
QGraphicsWidgetPrivate *wd = QGraphicsWidget::d_func();
QGraphicsLayoutItemPrivate *d = QGraphicsLayoutItem::d_ptr.data();
- QRectF newGeom;
+ QRectF newGeom = rect;
QPointF oldPos = d->geom.topLeft();
if (!wd->inSetPos) {
setAttribute(Qt::WA_Resized);
- newGeom = rect;
newGeom.setSize(rect.size().expandedTo(effectiveSizeHint(Qt::MinimumSize))
.boundedTo(effectiveSizeHint(Qt::MaximumSize)));
@@ -405,14 +404,7 @@ void QGraphicsWidget::setGeometry(const QRectF &rect)
emit widthChanged();
if (oldSize.height() != newGeom.size().height())
emit heightChanged();
- QGraphicsLayout *lay = wd->layout;
- if (QGraphicsLayout::instantInvalidatePropagation()) {
- if (!lay || lay->isActivated()) {
- QApplication::sendEvent(this, &re);
- }
- } else {
- QApplication::sendEvent(this, &re);
- }
+ QApplication::sendEvent(this, &re);
}
}
@@ -1091,8 +1083,11 @@ void QGraphicsWidget::updateGeometry()
* When the event is received, it will start flowing all the way down to the leaf
* widgets in one go. This will make a relayout flicker-free.
*/
- if (QGraphicsLayout::instantInvalidatePropagation())
- QApplication::postEvent(static_cast<QGraphicsWidget *>(this), new QEvent(QEvent::LayoutRequest));
+ if (QGraphicsLayout::instantInvalidatePropagation()) {
+ Q_D(QGraphicsWidget);
+ ++d->refCountInvokeRelayout;
+ QMetaObject::invokeMethod(this, "_q_relayout", Qt::QueuedConnection);
+ }
}
if (!QGraphicsLayout::instantInvalidatePropagation()) {
bool wasResized = testAttribute(Qt::WA_Resized);
diff --git a/src/gui/graphicsview/qgraphicswidget.h b/src/gui/graphicsview/qgraphicswidget.h
index 063be2d..5085817 100644
--- a/src/gui/graphicsview/qgraphicswidget.h
+++ b/src/gui/graphicsview/qgraphicswidget.h
@@ -234,6 +234,8 @@ protected:
private:
Q_DISABLE_COPY(QGraphicsWidget)
Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QGraphicsWidget)
+ Q_PRIVATE_SLOT(d_func(), void _q_relayout())
+
friend class QGraphicsScene;
friend class QGraphicsScenePrivate;
friend class QGraphicsView;
diff --git a/src/gui/graphicsview/qgraphicswidget_p.cpp b/src/gui/graphicsview/qgraphicswidget_p.cpp
index 059051e..dc0f7c0 100644
--- a/src/gui/graphicsview/qgraphicswidget_p.cpp
+++ b/src/gui/graphicsview/qgraphicswidget_p.cpp
@@ -232,6 +232,18 @@ void QGraphicsWidgetPrivate::resolveLayoutDirection()
}
}
+/* private slot */
+void QGraphicsWidgetPrivate::_q_relayout()
+{
+ --refCountInvokeRelayout;
+ if (refCountInvokeRelayout == 0) {
+ Q_Q(QGraphicsWidget);
+ bool wasResized = q->testAttribute(Qt::WA_Resized);
+ q->resize(q->size()); // this will restrict the size
+ q->setAttribute(Qt::WA_Resized, wasResized);
+ }
+}
+
QPalette QGraphicsWidgetPrivate::naturalWidgetPalette() const
{
Q_Q(const QGraphicsWidget);
@@ -897,4 +909,6 @@ void QGraphicsWidgetPrivate::setGeometryFromSetPos()
QT_END_NAMESPACE
+#include "moc_qgraphicswidget.cpp"
+
#endif //QT_NO_GRAPHICSVIEW
diff --git a/src/gui/graphicsview/qgraphicswidget_p.h b/src/gui/graphicsview/qgraphicswidget_p.h
index 398abc3..6ea2586 100644
--- a/src/gui/graphicsview/qgraphicswidget_p.h
+++ b/src/gui/graphicsview/qgraphicswidget_p.h
@@ -81,6 +81,7 @@ public:
polished(0),
inSetPos(0),
autoFillBackground(0),
+ refCountInvokeRelayout(0),
focusPolicy(Qt::NoFocus),
focusNext(0),
focusPrev(0),
@@ -106,6 +107,7 @@ public:
QGraphicsLayout *layout;
void setLayoutDirection_helper(Qt::LayoutDirection direction);
void resolveLayoutDirection();
+ void _q_relayout();
// Style
QPalette palette;
@@ -179,11 +181,14 @@ public:
return false;
return (attributes & (1 << bit)) != 0;
}
+ // 32 bits
+ quint32 refCountInvokeRelayout : 16;
quint32 attributes : 10;
quint32 inSetGeometry : 1;
quint32 polished: 1;
quint32 inSetPos : 1;
quint32 autoFillBackground : 1;
+ quint32 padding : 2; // feel free to use
// Focus
Qt::FocusPolicy focusPolicy;
diff --git a/src/gui/kernel/qwidget_mac.mm b/src/gui/kernel/qwidget_mac.mm
index 2f33f55..9481a85 100644
--- a/src/gui/kernel/qwidget_mac.mm
+++ b/src/gui/kernel/qwidget_mac.mm
@@ -4434,6 +4434,11 @@ void QWidgetPrivate::setGeometry_sys_helper(int x, int y, int w, int h, bool isM
QPoint oldp = q->pos();
QSize olds = q->size();
+ // Apply size restrictions, applicable for Windows & Widgets.
+ if (QWExtra *extra = extraData()) {
+ w = qBound(extra->minw, w, extra->maxw);
+ h = qBound(extra->minh, h, extra->maxh);
+ }
const bool isResize = (olds != QSize(w, h));
if (!realWindow && !isResize && QPoint(x, y) == oldp)
@@ -4443,13 +4448,6 @@ void QWidgetPrivate::setGeometry_sys_helper(int x, int y, int w, int h, bool isM
data.window_state = data.window_state & ~Qt::WindowMaximized;
const bool visible = q->isVisible();
- // Apply size restrictions, applicable for Windows & Widgets.
- if (QWExtra *extra = extraData()) {
- w = qMin(w, extra->maxw);
- h = qMin(h, extra->maxh);
- w = qMax(w, extra->minw);
- h = qMax(h, extra->minh);
- }
data.crect = QRect(x, y, w, h);
if (realWindow) {