From 3eb65f48c97dc5e1a8980afa35bea8e4b16f08ba Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Fri, 4 Sep 2009 15:05:46 +0200 Subject: Remove implicit margin on bulleted lists when exporting to HTML When we export a bulleted list to HTML, we add a meta-block around the list items to set the bullet style of the list ("); + QString(""); } { @@ -1151,7 +1151,7 @@ void tst_QTextDocument::toHtml_data() QTest::newRow("charfmt-for-list-item") << QTextDocumentFragment(&doc) << QString("EMPTYBLOCK") + - QString(""); + QString(""); } { @@ -1181,7 +1181,7 @@ void tst_QTextDocument::toHtml_data() QTest::newRow("list-indent") << QTextDocumentFragment(&doc) << QString("EMPTYBLOCK") + - QString(""); + QString(""); } { @@ -1445,6 +1445,21 @@ void tst_QTextDocument::toHtml_data() "\n

Bar

" "\n\n\n
"); } + + { + CREATE_DOC_AND_CURSOR(); + + QTextListFormat listFmt; + listFmt.setStyle(QTextListFormat::ListDisc); + + cursor.insertList(listFmt); + cursor.insertText("Blah"); + + QTest::newRow("list-ul-margin") << QTextDocumentFragment(&doc) + << QString("EMPTYBLOCK") + + QString(""); + + } } void tst_QTextDocument::toHtml() -- cgit v0.12 From 55bda33db049d137f4a1e3349e40e8d3365748c6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Fri, 4 Sep 2009 11:42:52 +0200 Subject: Minor fixes to the graphicsview/flowlayout example --- examples/graphicsview/flowlayout/flowlayout.cpp | 28 ++++++++++++++----------- examples/graphicsview/flowlayout/window.cpp | 2 +- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/examples/graphicsview/flowlayout/flowlayout.cpp b/examples/graphicsview/flowlayout/flowlayout.cpp index d4fc49d..32a2830 100644 --- a/examples/graphicsview/flowlayout/flowlayout.cpp +++ b/examples/graphicsview/flowlayout/flowlayout.cpp @@ -98,12 +98,10 @@ void FlowLayout::setGeometry(const QRectF &geom) qreal FlowLayout::doLayout(const QRectF &geom, bool applyNewGeometry) const { - QPointF tl = geom.topLeft(); - qreal maxw = geom.width(); - qreal left, top, right, bottom; getContentsMargins(&left, &top, &right, &bottom); - maxw = maxw - left - right; + const qreal maxw = geom.width() - left - right; + qreal x = 0; qreal y = 0; qreal maxRowHeight = 0; @@ -139,9 +137,11 @@ QSizeF FlowLayout::minSize(const QSizeF &constraint) const QSizeF size(0, 0); qreal left, top, right, bottom; getContentsMargins(&left, &top, &right, &bottom); - if (constraint.width() > 0) { // height for width - qreal height = doLayout(QRectF(QPointF(0,0), constraint), false); + if (constraint.width() >= 0) { // height for width + const qreal height = doLayout(QRectF(QPointF(0,0), constraint), false); size = QSizeF(constraint.width(), height); + } else if (constraint.height() >= 0) { // width for height? + // not supported } else { QGraphicsLayoutItem *item; foreach (item, m_items) @@ -153,8 +153,8 @@ QSizeF FlowLayout::minSize(const QSizeF &constraint) const QSizeF FlowLayout::prefSize() const { - qreal left, top, right, bottom; - getContentsMargins(&left, &top, &right, &bottom); + qreal left, right; + getContentsMargins(&left, 0, &right, 0); QGraphicsLayoutItem *item; qreal maxh = 0; @@ -196,15 +196,19 @@ QSizeF FlowLayout::maxSize() const QSizeF FlowLayout::sizeHint(Qt::SizeHint which, const QSizeF &constraint) const { + QSizeF sh = constraint; switch (which) { case Qt::PreferredSize: - return prefSize(); + sh = prefSize(); + break; case Qt::MinimumSize: - return minSize(constraint); + sh = minSize(constraint); + break; case Qt::MaximumSize: - return maxSize(); + sh = maxSize(); + break; default: break; } - return constraint; + return sh; } diff --git a/examples/graphicsview/flowlayout/window.cpp b/examples/graphicsview/flowlayout/window.cpp index 2d98026..017659a 100644 --- a/examples/graphicsview/flowlayout/window.cpp +++ b/examples/graphicsview/flowlayout/window.cpp @@ -49,7 +49,7 @@ Window::Window() { FlowLayout *lay = new FlowLayout; QLatin1String wiseWords("I am not bothered by the fact that I am unknown." - "I am bothered when I do not know others. (Confucius)"); + " I am bothered when I do not know others. (Confucius)"); QString sentence(wiseWords); QStringList words = sentence.split(QLatin1Char(' '), QString::SkipEmptyParts); for (int i = 0; i < words.count(); ++i) { -- cgit v0.12 From a0b5f9529f3bb7858f4261af98aa13d20ac6c16c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Fri, 4 Sep 2009 12:30:02 +0200 Subject: QGraphicsWidget::sizeHint didn't pass the correct constraint to layout. Adjust the constraint with the widget margin before passing it on to d->layout->effectiveSizeHint(). --- src/gui/graphicsview/qgraphicswidget.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gui/graphicsview/qgraphicswidget.cpp b/src/gui/graphicsview/qgraphicswidget.cpp index afabf49..d0f3b99 100644 --- a/src/gui/graphicsview/qgraphicswidget.cpp +++ b/src/gui/graphicsview/qgraphicswidget.cpp @@ -687,11 +687,13 @@ QSizeF QGraphicsWidget::sizeHint(Qt::SizeHint which, const QSizeF &constraint) c Q_D(const QGraphicsWidget); QSizeF sh; if (d->layout) { - sh = d->layout->effectiveSizeHint(which, constraint); + QSizeF marginSize(0,0); if (d->margins) { - sh += QSizeF(d->margins[d->Left] + d->margins[d->Right], + marginSize = QSizeF(d->margins[d->Left] + d->margins[d->Right], d->margins[d->Top] + d->margins[d->Bottom]); } + sh = d->layout->effectiveSizeHint(which, constraint - marginSize); + sh += marginSize; } else { switch (which) { case Qt::MinimumSize: -- cgit v0.12 From a56acff4789521a7b6a6439dcb88e6d9ba4b7ada Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Fri, 4 Sep 2009 12:37:20 +0200 Subject: Make sure that top-level windows respect hfw/wfh constraint. Note that the constraint is only enforced when resizing the window interactively. Calling setGeometry() will not try to enforce the constraint. See the graphicsview/flowlayout example for a "manual test". Task-number: 257455 --- src/gui/graphicsview/qgraphicswidget_p.cpp | 164 +++++++++++++++++---- src/gui/kernel/qsizepolicy.h | 12 ++ tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp | 79 ++++++++++ 3 files changed, 230 insertions(+), 25 deletions(-) diff --git a/src/gui/graphicsview/qgraphicswidget_p.cpp b/src/gui/graphicsview/qgraphicswidget_p.cpp index 787bbb1..bf826a9 100644 --- a/src/gui/graphicsview/qgraphicswidget_p.cpp +++ b/src/gui/graphicsview/qgraphicswidget_p.cpp @@ -393,49 +393,162 @@ void QGraphicsWidgetPrivate::windowFrameMousePressEvent(QGraphicsSceneMouseEvent event->setAccepted(windowData->grabbedSection != Qt::NoSection); } +/*! + Used to calculate the + Precondition: + \a widget should support either hfw or wfh + + If \a heightForWidth is set to false, this function will query the width for height + instead. \a width will then be interpreted as height, \a minh and \a maxh will be interpreted + as minimum width and maximum width. + */ +static qreal minimumHeightForWidth(qreal width, qreal minh, qreal maxh, + const QGraphicsWidget *widget, + bool heightForWidth = true) +{ + qreal minimumHeightForWidth = -1; + const QSizePolicy sp = widget->layout() ? widget->layout()->sizePolicy() : widget->sizePolicy(); + const bool hasHFW = sp.hasHeightForWidth(); + if (hasHFW == heightForWidth) { + minimumHeightForWidth = hasHFW + ? widget->effectiveSizeHint(Qt::MinimumSize, QSizeF(width, -1)).height() + : widget->effectiveSizeHint(Qt::MinimumSize, QSizeF(-1, width)).width(); //"width" is here height! + } else { + // widthForHeight + const qreal constraint = width; + while (maxh - minh > 0.1) { + qreal middle = minh + (maxh - minh)/2; + // ### really bad, if we are a widget with a layout it will call + // layout->effectiveSizeHint(Qt::MiniumumSize), which again will call + // sizeHint three times because of how the cache works + qreal hfw = hasHFW + ? widget->effectiveSizeHint(Qt::MinimumSize, QSizeF(middle, -1)).height() + : widget->effectiveSizeHint(Qt::MinimumSize, QSizeF(-1, middle)).width(); + if (hfw > constraint) { + minh = middle; + } else if (hfw <= constraint) { + maxh = middle; + } + } + minimumHeightForWidth = maxh; + } + return minimumHeightForWidth; +} + +static qreal minimumWidthForHeight(qreal height, qreal minw, qreal maxw, + const QGraphicsWidget *widget) +{ + return minimumHeightForWidth(height, minw, maxw, widget, false); +} + +static QSizeF closestAcceptableSize(const QSizeF &proposed, + const QGraphicsWidget *widget) +{ + const QSizeF current = widget->size(); + + qreal minw = proposed.width(); + qreal maxw = current.width(); + qreal minh = proposed.height(); + qreal maxh = current.height(); + + qreal middlew = maxw; + qreal middleh = maxh; + qreal min_hfw; + min_hfw = minimumHeightForWidth(maxw, minh, maxh, widget); + + do { + if (maxw - minw < 0.1) { + // we still havent found anything, cut off binary search + minw = maxw; + minh = maxh; + } + middlew = minw + (maxw - minw)/2.0; + middleh = minh + (maxh - minh)/2.0; + + min_hfw = minimumHeightForWidth(middlew, minh, maxh, widget); + + if (min_hfw > middleh) { + minw = middlew; + minh = middleh; + } else if (min_hfw <= middleh) { + maxw = middlew; + maxh = middleh; + } + } while (maxw != minw); + + min_hfw = minimumHeightForWidth(middlew, minh, maxh, widget); + + QSizeF result; + if (min_hfw < maxh) { + result = QSizeF(middlew, min_hfw); + } else { + // Needed because of the cut-off we do above. + result = QSizeF(minimumWidthForHeight(maxh, proposed.width(), current.width(), widget), maxh); + } + return result; +} + static void _q_boundGeometryToSizeConstraints(const QRectF &startGeometry, QRectF *rect, Qt::WindowFrameSection section, - const QSizeF &min, const QSizeF &max) + const QSizeF &min, const QSizeF &max, + const QGraphicsWidget *widget) { - int height; - int width; + const QRectF proposedRect = *rect; + qreal width = qBound(min.width(), proposedRect.width(), max.width()); + qreal height = qBound(min.height(), proposedRect.height(), max.height()); + + QSizePolicy sp = widget->sizePolicy(); + if (const QGraphicsLayout *l = widget->layout()) { + sp = l->sizePolicy(); + } + const bool hasHFW = sp.hasHeightForWidth(); // || sp.hasWidthForHeight(); + + const bool widthChanged = proposedRect.width() < widget->size().width(); + const bool heightChanged = proposedRect.height() < widget->size().height(); + + if (hasHFW) { + if (widthChanged || heightChanged) { + const qreal minh = min.height(); + const qreal maxh = max.height(); + const qreal proposedHFW = minimumHeightForWidth(width, minh, maxh, widget); + if (proposedHFW > proposedRect.height()) { + QSizeF effectiveSize = closestAcceptableSize(QSizeF(width, height), widget); + width = effectiveSize.width(); + height = effectiveSize.height(); + } + } + } + switch (section) { case Qt::LeftSection: - width = qRound(qBound(min.width(), rect->width(), max.width())); - rect->setRect(startGeometry.right() - width, startGeometry.top(), - width, startGeometry.height()); + rect->setRect(startGeometry.right() - qRound(width), startGeometry.top(), + qRound(width), startGeometry.height()); break; case Qt::TopLeftSection: - width = qRound(qBound(min.width(), rect->width(), max.width())); - height = qRound(qBound(min.height(), rect->height(), max.height())); - rect->setRect(startGeometry.right() - width, startGeometry.bottom() - height, - width, height); + rect->setRect(startGeometry.right() - qRound(width), startGeometry.bottom() - qRound(height), + qRound(width), qRound(height)); break; case Qt::TopSection: - height = qRound(qBound(min.height(), rect->height(), max.height())); - rect->setRect(startGeometry.left(), startGeometry.bottom() - height, - startGeometry.width(), height); + rect->setRect(startGeometry.left(), startGeometry.bottom() - qRound(height), + startGeometry.width(), qRound(height)); break; case Qt::TopRightSection: - height = qRound(qBound(min.height(), rect->height(), max.height())); - rect->setTop(rect->bottom() - height); - rect->setWidth(qBound(min.width(), rect->width(), max.width())); + rect->setTop(rect->bottom() - qRound(height)); + rect->setWidth(qRound(width)); break; case Qt::RightSection: - rect->setWidth(qBound(min.width(), rect->width(), max.width())); + rect->setWidth(qRound(width)); break; case Qt::BottomRightSection: - rect->setWidth(qBound(min.width(), rect->width(), max.width())); - rect->setHeight(qBound(min.height(), rect->height(), max.height())); + rect->setWidth(qRound(width)); + rect->setHeight(qRound(height)); break; case Qt::BottomSection: - rect->setHeight(qBound(min.height(), rect->height(), max.height())); + rect->setHeight(qRound(height)); break; case Qt::BottomLeftSection: - height = qRound(qBound(min.height(), rect->height(), max.height())); - width = qRound(qBound(min.width(), rect->width(), max.width())); - rect->setRect(startGeometry.right() - width, startGeometry.top(), - width, height); + rect->setRect(startGeometry.right() - qRound(width), startGeometry.top(), + qRound(width), qRound(height)); break; default: break; @@ -506,7 +619,8 @@ void QGraphicsWidgetPrivate::windowFrameMouseMoveEvent(QGraphicsSceneMouseEvent _q_boundGeometryToSizeConstraints(windowData->startGeometry, &newGeometry, windowData->grabbedSection, q->effectiveSizeHint(Qt::MinimumSize), - q->effectiveSizeHint(Qt::MaximumSize)); + q->effectiveSizeHint(Qt::MaximumSize), + q); q->setGeometry(newGeometry); } } diff --git a/src/gui/kernel/qsizepolicy.h b/src/gui/kernel/qsizepolicy.h index 4261dda..eb13788 100644 --- a/src/gui/kernel/qsizepolicy.h +++ b/src/gui/kernel/qsizepolicy.h @@ -64,6 +64,7 @@ private: VMask = HMask << HSize, CTShift = 9, CTSize = 5, + WFHShift = CTShift + CTSize, CTMask = ((0x1 << CTSize) - 1) << CTShift, UnusedShift = CTShift + CTSize, UnusedSize = 2 @@ -199,6 +200,17 @@ private: QSizePolicy(int i) : data(i) { } quint32 data; +/* use bit flags instead, keep it here for improved readability for now + quint32 horzPolicy : 4; + quint32 vertPolicy : 4; + quint32 hfw : 1; + quint32 ctype : 5; + quint32 wfh : 1; + quint32 padding : 1; // we cannot use the highest bit + quint32 horStretch : 8; + quint32 verStretch : 8; +*/ + }; Q_DECLARE_OPERATORS_FOR_FLAGS(QSizePolicy::ControlTypes) diff --git a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp index 03054f9..d1193bd 100644 --- a/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp +++ b/tests/auto/qgraphicswidget/tst_qgraphicswidget.cpp @@ -157,6 +157,7 @@ private slots: void shortcutsDeletion(); void painterStateProtectionOnWindowFrame(); void ensureClipping(); + void respectHFW(); // Task fixes void task236127_bspTreeIndexFails(); @@ -2543,6 +2544,84 @@ void tst_QGraphicsWidget::ensureClipping() QVERIFY(scene.drawnItems.contains(childitem)); } +class HFWWidget : public QGraphicsWidget +{ +public: + HFWWidget() : QGraphicsWidget(0, Qt::Window) + { + QSizePolicy sp; + sp.setHeightForWidth(true); + setSizePolicy(sp); + } + + void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) + { + Q_UNUSED(option); + Q_UNUSED(widget); + qreal w = rect().width(); + QRectF box(0, 0, w, 2400/w); + painter->drawRoundRect(box); + painter->drawLine(box.topLeft(), box.bottomRight()); + painter->drawLine(box.bottomLeft(), box.topRight()); + } + +protected: + QSizeF sizeHint(Qt::SizeHint which, const QSizeF &constraint = QSizeF()) const + { + qreal w = constraint.width(); + switch (which) { + case Qt::MinimumSize: + if (w >= 0 && constraint.height() < 0) { + // keep the same area of 60x40 = 2400 + return QSizeF(w, 2400.0/w); + } else { + return QSizeF(10, 10); + } + break; + case Qt::PreferredSize: + return QSizeF(48.989794, 48.989794); + default: + break; + } + return QGraphicsWidget::sizeHint(which, constraint); + } +}; + +void tst_QGraphicsWidget::respectHFW() +{ + QGraphicsScene scene; + HFWWidget *window = new HFWWidget; + scene.addItem(window); + QGraphicsView *view = new QGraphicsView(&scene); + view->resize(400, 400); + view->setSceneRect(-100, -100, 300,300); + + view->show(); + window->setGeometry(0, 0, 70, 70); + + { // here we go - simulate a interactive resize of the window + QTest::qWait(200); + QTest::mouseMove(view, view->mapFromScene(71, 71)); // bottom right corner + QTest::qWait(200); + + QTest::mousePress(view->viewport(), Qt::LeftButton, 0, view->mapFromScene(71, 71), 200); + view->grabMouse(); + // move both mouse cursor and set correct event in order to emulate resize + QTest::mouseMove(view->viewport(), view->mapFromScene(60, 30), 200); + QMouseEvent e = QMouseEvent(QEvent::MouseMove, + view->mapFromScene(60, 20), + Qt::NoButton, + Qt::LeftButton, + Qt::NoModifier); + QApplication::sendEvent(view->viewport(), &e); + view->releaseMouse(); + } + QTest::qWait(200); + const QSizeF winSize = window->size(); + qreal minHFW = window->effectiveSizeHint(Qt::MinimumSize, QSizeF(winSize.width(), -1)).height(); + QVERIFY(qAbs(minHFW - winSize.height()) < 1); +} + QTEST_MAIN(tst_QGraphicsWidget) #include "tst_qgraphicswidget.moc" -- cgit v0.12 From 7aacb8b3ff5c4c998298207b355b9c301d736d34 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Fri, 4 Sep 2009 15:19:02 +0200 Subject: Make the view in the flowlayout example big enough. --- examples/graphicsview/flowlayout/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/graphicsview/flowlayout/main.cpp b/examples/graphicsview/flowlayout/main.cpp index 206f604..e672ae6 100644 --- a/examples/graphicsview/flowlayout/main.cpp +++ b/examples/graphicsview/flowlayout/main.cpp @@ -50,6 +50,7 @@ int main(int argc, char **argv) QGraphicsView *view = new QGraphicsView(&scene); Window *w = new Window; scene.addItem(w); + view->resize(400, 300); view->show(); return app.exec(); } -- cgit v0.12 From 7d41759f87db72ff9b9ff1d8ce017f466440f2ef Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 4 Sep 2009 13:35:25 +1000 Subject: Don't call pure virtuals on deleting QGraphicsItem This also needs to be reviewed by andreas. Reviewed-by: Michael Brasser --- src/gui/graphicsview/qgraphicsitem.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index cdcb0c4..16a9a0a 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -4780,10 +4780,12 @@ void QGraphicsItemPrivate::updateCachedClipPathFromSetPosHelper(const QPointF &n if (transformData) thisToParentTransform = transformData->computedFullTransform(&thisToParentTransform); QGraphicsItem *clipParent = parent; - while (clipParent && !(clipParent->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape)) { + while (clipParent && !clipParent->d_ptr->inDestructor && !(clipParent->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape)) { thisToParentTransform *= clipParent->d_ptr->transformToParent(); clipParent = clipParent->d_ptr->parent; } + if (clipParent && clipParent->d_ptr->inDestructor) + return; // thisToParentTransform is now the same as q->itemTransform(clipParent), except // that the new position (which is not yet set on the item) is taken into account. -- cgit v0.12 From f7be6402e089aefd445a5ab98912ff5aea511cea Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Fri, 4 Sep 2009 11:56:43 +0200 Subject: Fix crashes when moving descendents during destruction. This fix prevents crashes in QGraphicsItem caused by calls to pure virtual functions as an item tries to access its dying parent. This happens when an item is moved by an ancestor during this ancestor's destructor. Autotests included. Reviewed-by: bnilsen --- src/gui/graphicsview/qgraphicsitem.cpp | 18 +++++--- tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 60 ++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 7 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 16a9a0a..eae3e63 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -4770,7 +4770,7 @@ void QGraphicsItemPrivate::updateCachedClipPathFromSetPosHelper(const QPointF &n { Q_ASSERT(inSetPosHelper); - if (!(ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren)) + if (inDestructor || !(ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren)) return; // Not clipped by any ancestor. // Find closest clip ancestor and transform. @@ -4784,13 +4784,15 @@ void QGraphicsItemPrivate::updateCachedClipPathFromSetPosHelper(const QPointF &n thisToParentTransform *= clipParent->d_ptr->transformToParent(); clipParent = clipParent->d_ptr->parent; } - if (clipParent && clipParent->d_ptr->inDestructor) - return; - // thisToParentTransform is now the same as q->itemTransform(clipParent), except - // that the new position (which is not yet set on the item) is taken into account. - Q_ASSERT(clipParent); - Q_ASSERT(clipParent->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape); + // Ensure no parents are currently being deleted. This can only + // happen if the item is moved by a dying ancestor. + QGraphicsItem *p = clipParent; + while (p) { + if (p->d_ptr->inDestructor) + return; + p = p->d_ptr->parent; + } // From here everything is calculated in clip parent's coordinates. const QRectF parentBoundingRect(clipParent->boundingRect()); @@ -6852,6 +6854,8 @@ void QGraphicsItem::removeFromIndex() */ void QGraphicsItem::prepareGeometryChange() { + if (d_ptr->inDestructor) + return; if (d_ptr->scene) { d_ptr->scene->d_func()->dirtyGrowingItemsBoundingRect = true; d_ptr->geometryChanged = 1; diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 408decc..77c2d45 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -292,6 +292,7 @@ private slots: void activate(); void setActivePanelOnInactiveScene(); void activationOnShowHide(); + void moveWhileDeleting(); // task specific tests below me void task141694_textItemEnsureVisible(); @@ -8103,5 +8104,64 @@ void tst_QGraphicsItem::activationOnShowHide() QVERIFY(otherItem->isActive()); } +class MoveWhileDying : public QGraphicsRectItem +{ +public: + MoveWhileDying(QGraphicsItem *parent = 0) + : QGraphicsRectItem(parent) + { } + ~MoveWhileDying() + { + foreach (QGraphicsItem *c, childItems()) { + foreach (QGraphicsItem *cc, c->childItems()) { + cc->moveBy(10, 10); + } + c->moveBy(10, 10); + } + if (QGraphicsItem *p = parentItem()) { p->moveBy(10, 10); } + } +}; + +void tst_QGraphicsItem::moveWhileDeleting() +{ + QGraphicsScene scene; + QGraphicsRectItem *rect = new QGraphicsRectItem; + MoveWhileDying *silly = new MoveWhileDying(rect); + QGraphicsRectItem *child = new QGraphicsRectItem(silly); + scene.addItem(rect); + delete rect; // don't crash! + + rect = new QGraphicsRectItem; + silly = new MoveWhileDying(rect); + child = new QGraphicsRectItem(silly); + + QGraphicsView view(&scene); + view.show(); +#ifdef Q_WS_X11 + qt_x11_wait_for_window_manager(&view); +#endif + QTest::qWait(125); + + delete rect; + + rect = new QGraphicsRectItem; + rect->setFlag(QGraphicsItem::ItemClipsChildrenToShape); + silly = new MoveWhileDying(rect); + child = new QGraphicsRectItem(silly); + + QTest::qWait(125); + + delete rect; + + rect = new MoveWhileDying; + rect->setFlag(QGraphicsItem::ItemClipsChildrenToShape); + child = new QGraphicsRectItem(rect); + silly = new MoveWhileDying(child); + + QTest::qWait(125); + + delete rect; +} + QTEST_MAIN(tst_QGraphicsItem) #include "tst_qgraphicsitem.moc" -- cgit v0.12 From 1a60fb9506519210edcbfb3fbc400a67a6d26a41 Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Fri, 4 Sep 2009 14:00:01 +0200 Subject: Optimize qt_format_text test operations: try not to detach Second try. This is a fixed version of the one reverted in commit 25014061b8de The difference is that it does text[offset] = QChar::LineSeparator; instead of chr = QChar::LineSeparator; Reviewed-by: Eskil --- src/gui/painting/qpainter.cpp | 68 ++++++++++++++++++------------------------- 1 file changed, 28 insertions(+), 40 deletions(-) diff --git a/src/gui/painting/qpainter.cpp b/src/gui/painting/qpainter.cpp index a6bea76..263e53e 100644 --- a/src/gui/painting/qpainter.cpp +++ b/src/gui/painting/qpainter.cpp @@ -7545,10 +7545,9 @@ void qt_format_text(const QFont &fnt, const QRectF &_r, if (!painter) tf |= Qt::TextDontPrint; - int maxUnderlines = 0; + uint maxUnderlines = 0; int numUnderlines = 0; - int underlinePositionStack[32]; - int *underlinePositions = underlinePositionStack; + QVarLengthArray underlinePositions(1); QFontMetricsF fm(fnt); QString text = str; @@ -7557,54 +7556,46 @@ start_lengthVariant: bool hasMoreLengthVariants = false; // compatible behaviour to the old implementation. Replace // tabs by spaces - QChar *chr = text.data() + offset; - QChar *end = text.data() + text.length(); bool has_tab = false; - while (chr != end) { - if (*chr == QLatin1Char('\r') || (singleline && *chr == QLatin1Char('\n'))) { - *chr = QLatin1Char(' '); - } else if (*chr == QLatin1Char('\n')) { - *chr = QChar::LineSeparator; - } else if (*chr == QLatin1Char('&')) { + int old_offset = offset; + for (; offset < text.length(); offset++) { + QChar chr = text.at(offset); + if (chr == QLatin1Char('\r') || (singleline && chr == QLatin1Char('\n'))) { + text[offset] = QLatin1Char(' '); + } else if (chr == QLatin1Char('\n')) { + text[offset] = QChar::LineSeparator; + } else if (chr == QLatin1Char('&')) { ++maxUnderlines; - } else if (*chr == QLatin1Char('\t')) { + } else if (chr == QLatin1Char('\t')) { + if (!expandtabs) { + text[offset] = QLatin1Char(' '); + } else if (!tabarraylen && !tabstops) { + tabstops = qRound(fm.width(QLatin1Char('x'))*8); + } has_tab = true; - } else if (*chr == QChar(ushort(0x9c))) { + } else if (chr == QChar(ushort(0x9c))) { // string with multiple length variants - end = chr; hasMoreLengthVariants = true; break; } - ++chr; - } - if (has_tab) { - if (!expandtabs) { - chr = text.data() + offset; - while (chr != end) { - if (*chr == QLatin1Char('\t')) - *chr = QLatin1Char(' '); - ++chr; - } - } else if (!tabarraylen && !tabstops) { - tabstops = qRound(fm.width(QLatin1Char('x'))*8); - } } - QChar *cout = end; - if (hidemnmemonic || showmnemonic) { - if (maxUnderlines > 32) - underlinePositions = new int[maxUnderlines]; - cout = text.data() + offset; + int length = offset - old_offset; + if ((hidemnmemonic || showmnemonic) && maxUnderlines > 0) { + underlinePositions.resize(maxUnderlines + 1); + + QChar *cout = text.data() + old_offset; QChar *cin = cout; - int l = end - cout; + int l = length; while (l) { if (*cin == QLatin1Char('&')) { ++cin; + --length; --l; if (!l) break; if (*cin != QLatin1Char('&') && !hidemnmemonic) - underlinePositions[numUnderlines++] = cout - text.unicode(); + underlinePositions[numUnderlines++] = cout - text.data() - old_offset; } *cout = *cin; ++cout; @@ -7621,7 +7612,7 @@ start_lengthVariant: qreal height = 0; qreal width = 0; - QString finalText = text.mid(offset, cout - (text.data() + offset)); + QString finalText = text.mid(old_offset, length); QStackTextEngine engine(finalText, fnt); if (option) { engine.option = *option; @@ -7640,7 +7631,7 @@ start_lengthVariant: engine.forceJustification = true; QTextLayout textLayout(&engine); textLayout.setCacheEnabled(true); - textLayout.engine()->underlinePositions = underlinePositions; + textLayout.engine()->underlinePositions = underlinePositions.data(); if (finalText.isEmpty()) { height = fm.height(); @@ -7709,7 +7700,7 @@ start_lengthVariant: QRectF bounds = QRectF(r.x() + xoff, r.y() + yoff, width, height); if (hasMoreLengthVariants && !(tf & Qt::TextLongestVariant) && !r.contains(bounds)) { - offset = end - text.data() + 1; + offset++; goto start_lengthVariant; } if (brect) @@ -7738,9 +7729,6 @@ start_lengthVariant: painter->restore(); } } - - if (underlinePositions != underlinePositionStack) - delete [] underlinePositions; } /*! -- cgit v0.12 From 5323b15f50df99722d304c04d1758bb9410ef041 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Thu, 3 Sep 2009 08:17:05 +0200 Subject: Fix tst_QTimer::moveToThread() on Windows We shouldn't fully unregister timers when the event dispatcher is stopped when a thread exits, since this releases the timerId back to the pool. Instead, only free the OS resources. Auto-test included. Reviewed-by: ogoffart --- src/corelib/kernel/qeventdispatcher_win.cpp | 10 ++++---- tests/auto/qtimer/tst_qtimer.cpp | 40 +++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index b7934db..9c308a3 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -331,7 +331,7 @@ public: WinTimerVec timerVec; WinTimerDict timerDict; void registerTimer(WinTimerInfo *t); - void unregisterTimer(WinTimerInfo *t); + void unregisterTimer(WinTimerInfo *t, bool closingDown = false); void sendTimerEvent(int timerId); // socket notifiers @@ -557,10 +557,10 @@ void QEventDispatcherWin32Private::registerTimer(WinTimerInfo *t) qErrnoWarning("QEventDispatcherWin32::registerTimer: Failed to create a timer"); } -void QEventDispatcherWin32Private::unregisterTimer(WinTimerInfo *t) +void QEventDispatcherWin32Private::unregisterTimer(WinTimerInfo *t, bool closingDown) { // mark timer as unused - if (!QObjectPrivate::get(t->obj)->inThreadChangeEvent) + if (!QObjectPrivate::get(t->obj)->inThreadChangeEvent && !closingDown) QAbstractEventDispatcherPrivate::releaseTimerId(t->timerId); if (t->interval == 0) { @@ -1019,8 +1019,8 @@ void QEventDispatcherWin32::closingDown() unregisterSocketNotifier((*(d->sn_except.begin()))->obj); // clean up any timers - while (!d->timerDict.isEmpty()) - unregisterTimer((*(d->timerDict.begin()))->timerId); + for (int i = 0; i < d->timerVec.count(); ++i) + d->unregisterTimer(d->timerVec.at(i), true); } bool QEventDispatcherWin32::event(QEvent *e) diff --git a/tests/auto/qtimer/tst_qtimer.cpp b/tests/auto/qtimer/tst_qtimer.cpp index 57502c7..36fce76 100644 --- a/tests/auto/qtimer/tst_qtimer.cpp +++ b/tests/auto/qtimer/tst_qtimer.cpp @@ -87,6 +87,7 @@ private slots: void restartedTimerFiresTooSoon(); void timerFiresOnlyOncePerProcessEvents_data(); void timerFiresOnlyOncePerProcessEvents(); + void timerIdPersistsAfterThreadExit(); }; class TimerHelper : public QObject @@ -562,5 +563,44 @@ void tst_QTimer::timerFiresOnlyOncePerProcessEvents() QCOMPARE(longSlot.count, 1); } +class TimerIdPersistsAfterThreadExitThread : public QThread +{ +public: + QTimer *timer; + int timerId, returnValue; + + TimerIdPersistsAfterThreadExitThread() + : QThread(), timer(0), timerId(-1), returnValue(-1) + { } + ~TimerIdPersistsAfterThreadExitThread() + { + delete timer; + } + + void run() + { + QEventLoop eventLoop; + timer = new QTimer; + connect(timer, SIGNAL(timeout()), &eventLoop, SLOT(quit())); + timer->start(100); + timerId = timer->timerId(); + returnValue = eventLoop.exec(); + } +}; + +void tst_QTimer::timerIdPersistsAfterThreadExit() +{ + TimerIdPersistsAfterThreadExitThread thread; + thread.start(); + QVERIFY(thread.wait(30000)); + QCOMPARE(thread.returnValue, 0); + + // even though the thread has exited, and the event dispatcher destroyed, the timer is still + // "active", meaning the timer id should NOT be reused (i.e. the event dispatcher should not + // have unregistered it) + int timerId = thread.startTimer(100); + QVERIFY((timerId & 0xffffff) != (thread.timerId & 0xffffff)); +} + QTEST_MAIN(tst_QTimer) #include "tst_qtimer.moc" -- cgit v0.12 From 57447242994a16e30d3cb199eefaf625f0088f9f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 4 Sep 2009 13:20:04 +0200 Subject: Avoided streaming multiple copies of images/pixmaps in QPaintBuffer. This reduces the size of the trace files significantly in certain cases. Reviewed-by: Trond --- src/gui/painting/qpaintbuffer.cpp | 75 ++++++++++++++++++++++++++++++++++++++- 1 file changed, 74 insertions(+), 1 deletion(-) diff --git a/src/gui/painting/qpaintbuffer.cpp b/src/gui/painting/qpaintbuffer.cpp index 04ddd7d..7de9063 100644 --- a/src/gui/painting/qpaintbuffer.cpp +++ b/src/gui/painting/qpaintbuffer.cpp @@ -1721,11 +1721,66 @@ QDataStream &operator>>(QDataStream &stream, QPaintBufferCommand &command) return stream; } +struct QPaintBufferCacheEntry +{ + QVariant::Type type; + quint64 cacheKey; +}; + +QDataStream &operator<<(QDataStream &stream, const QPaintBufferCacheEntry &entry) +{ + return stream << entry.type << entry.cacheKey; +} + +QDataStream &operator>>(QDataStream &stream, QPaintBufferCacheEntry &entry) +{ + return stream >> entry.type >> entry.cacheKey; +} + +static int qRegisterPaintBufferMetaTypes() +{ + qRegisterMetaType(); + qRegisterMetaTypeStreamOperators("QPaintBufferCacheEntry"); + + return 0; // something +} + +Q_DECLARE_METATYPE(QPaintBufferCacheEntry); +Q_CONSTRUCTOR_FUNCTION(qRegisterPaintBufferMetaTypes) + QDataStream &operator<<(QDataStream &stream, const QPaintBuffer &buffer) { + QHash pixmaps; + QHash images; + + QVector variants = buffer.d_ptr->variants; + for (int i = 0; i < variants.size(); ++i) { + const QVariant &v = variants.at(i); + if (v.type() == QVariant::Image) { + const QImage image(v.value()); + images[image.cacheKey()] = image; + + QPaintBufferCacheEntry entry; + entry.type = QVariant::Image; + entry.cacheKey = image.cacheKey(); + variants[i] = QVariant::fromValue(entry); + } else if (v.type() == QVariant::Pixmap) { + const QPixmap pixmap(v.value()); + pixmaps[pixmap.cacheKey()] = pixmap; + + QPaintBufferCacheEntry entry; + entry.type = QVariant::Pixmap; + entry.cacheKey = pixmap.cacheKey(); + variants[i] = QVariant::fromValue(entry); + } + } + + stream << pixmaps; + stream << images; + stream << buffer.d_ptr->ints; stream << buffer.d_ptr->floats; - stream << buffer.d_ptr->variants; + stream << variants; stream << buffer.d_ptr->commands; stream << buffer.d_ptr->boundingRect; @@ -1734,12 +1789,30 @@ QDataStream &operator<<(QDataStream &stream, const QPaintBuffer &buffer) QDataStream &operator>>(QDataStream &stream, QPaintBuffer &buffer) { + QHash pixmaps; + QHash images; + + stream >> pixmaps; + stream >> images; + stream >> buffer.d_ptr->ints; stream >> buffer.d_ptr->floats; stream >> buffer.d_ptr->variants; stream >> buffer.d_ptr->commands; stream >> buffer.d_ptr->boundingRect; + QVector &variants = buffer.d_ptr->variants; + for (int i = 0; i < variants.size(); ++i) { + const QVariant &v = variants.at(i); + if (v.canConvert()) { + QPaintBufferCacheEntry entry = v.value(); + if (entry.type == QVariant::Image) + variants[i] = QVariant(images.value(entry.cacheKey)); + else + variants[i] = QVariant(pixmaps.value(entry.cacheKey)); + } + } + return stream; } -- cgit v0.12 From f0b0ab1291dec59ae2fe1e88a3b20d173772e175 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Fri, 4 Sep 2009 15:08:44 +0200 Subject: Added multiple frames to QPaintBuffer. This lets us stream a single QPaintBuffer instead of one QPaintBuffer per frame in the trace graphicssystem, which leads to not streaming pixmaps / images once per frame. Performance when doing a trace is also a lot better for painting heavy applications. Reviewed-by: Trond --- src/gui/painting/qpaintbuffer.cpp | 26 ++++++++-- src/gui/painting/qpaintbuffer_p.h | 8 ++- .../trace/qgraphicssystem_trace.cpp | 60 +++++++++++++--------- tools/qttracereplay/main.cpp | 52 +++++-------------- 4 files changed, 74 insertions(+), 72 deletions(-) diff --git a/src/gui/painting/qpaintbuffer.cpp b/src/gui/painting/qpaintbuffer.cpp index 7de9063..f9cb108 100644 --- a/src/gui/painting/qpaintbuffer.cpp +++ b/src/gui/painting/qpaintbuffer.cpp @@ -239,7 +239,7 @@ bool QPaintBuffer::isEmpty() const -void QPaintBuffer::draw(QPainter *painter) const +void QPaintBuffer::draw(QPainter *painter, int frame) const { #ifdef QPAINTBUFFER_DEBUG_DRAW qDebug() << "QPaintBuffer::draw() --------------------------------"; @@ -270,10 +270,10 @@ void QPaintBuffer::draw(QPainter *painter) const ? (QPaintEngineEx *) painter->paintEngine() : 0; if (xengine) { QPaintEngineExReplayer player; - player.draw(*this, painter); + player.draw(*this, painter, frame); } else { QPainterReplayer player; - player.draw(*this, painter); + player.draw(*this, painter, frame); } #ifdef QPAINTBUFFER_DEBUG_DRAW @@ -1035,17 +1035,31 @@ void QPainterReplayer::setupTransform(QPainter *_painter) painter->setTransform(m_world_matrix); } -void QPainterReplayer::draw(const QPaintBuffer &buffer, QPainter *_painter) +void QPainterReplayer::draw(const QPaintBuffer &buffer, QPainter *_painter, int frame) { d = buffer.d_ptr; setupTransform(_painter); - for (int cmdIndex=0; cmdIndexcommands.size(); ++cmdIndex) { + int frameStart = (frame == 0) ? 0 : d->frames.at(frame-1); + int frameEnd = (frame == d->frames.size()) ? d->commands.size() : d->frames.at(frame); + + for (int cmdIndex=frameStart; cmdIndexcommands.at(cmdIndex); process(cmd); } } +void QPaintBuffer::beginNewFrame() +{ + if (!d_ptr->commands.isEmpty()) + d_ptr->frames << d_ptr->commands.size(); +} + +int QPaintBuffer::numFrames() const +{ + return d_ptr->frames.size() + 1; +} + void QPainterReplayer::process(const QPaintBufferCommand &cmd) { switch (cmd.id) { @@ -1783,6 +1797,7 @@ QDataStream &operator<<(QDataStream &stream, const QPaintBuffer &buffer) stream << variants; stream << buffer.d_ptr->commands; stream << buffer.d_ptr->boundingRect; + stream << buffer.d_ptr->frames; return stream; } @@ -1800,6 +1815,7 @@ QDataStream &operator>>(QDataStream &stream, QPaintBuffer &buffer) stream >> buffer.d_ptr->variants; stream >> buffer.d_ptr->commands; stream >> buffer.d_ptr->boundingRect; + stream >> buffer.d_ptr->frames; QVector &variants = buffer.d_ptr->variants; for (int i = 0; i < variants.size(); ++i) { diff --git a/src/gui/painting/qpaintbuffer_p.h b/src/gui/painting/qpaintbuffer_p.h index b360279..2cb1d7c 100644 --- a/src/gui/painting/qpaintbuffer_p.h +++ b/src/gui/painting/qpaintbuffer_p.h @@ -71,7 +71,10 @@ public: bool isEmpty() const; - void draw(QPainter *painter) const; + void beginNewFrame(); + int numFrames() const; + + void draw(QPainter *painter, int frame = 0) const; void setBoundingRect(const QRectF &rect); QRectF boundingRect() const; @@ -270,6 +273,7 @@ public: QVector variants; QVector commands; + QList frames; QPaintBufferEngine *engine; QRectF boundingRect; @@ -306,7 +310,7 @@ public: void setupTransform(QPainter *painter); void process(const QPaintBufferCommand &cmd); - void draw(const QPaintBuffer &buffer, QPainter *painter); + void draw(const QPaintBuffer &buffer, QPainter *painter, int frame); protected: QPaintBufferPrivate *d; diff --git a/src/plugins/graphicssystems/trace/qgraphicssystem_trace.cpp b/src/plugins/graphicssystems/trace/qgraphicssystem_trace.cpp index 36a8df1..bbb6536 100644 --- a/src/plugins/graphicssystems/trace/qgraphicssystem_trace.cpp +++ b/src/plugins/graphicssystems/trace/qgraphicssystem_trace.cpp @@ -57,30 +57,35 @@ public: ~QTraceWindowSurface(); QPaintDevice *paintDevice(); + void beginPaint(const QRegion &rgn); void endPaint(const QRegion &rgn); + bool scroll(const QRegion &area, int dx, int dy); + private: QPaintBuffer *buffer; + QList updates; - QFile *outputFile; - QDataStream *out; - - int frameId; + qulonglong winId; }; QTraceWindowSurface::QTraceWindowSurface(QWidget *widget) : QRasterWindowSurface(widget) , buffer(0) - , outputFile(0) - , out(0) - , frameId(0) + , winId(0) { } QTraceWindowSurface::~QTraceWindowSurface() { - delete out; - delete outputFile; + if (buffer) { + QFile outputFile(QString(QLatin1String("qtgraphics-%0.trace")).arg(winId)); + if (outputFile.open(QIODevice::WriteOnly)) { + QDataStream out(&outputFile); + out << *buffer << updates; + } + delete buffer; + } } QPaintDevice *QTraceWindowSurface::paintDevice() @@ -92,28 +97,33 @@ QPaintDevice *QTraceWindowSurface::paintDevice() return buffer; } -void QTraceWindowSurface::endPaint(const QRegion &rgn) +void QTraceWindowSurface::beginPaint(const QRegion &rgn) { - if (!out) { - outputFile = new QFile(QString(QLatin1String("qtgraphics-%0.trace")).arg((qulonglong)window()->winId())); - if (outputFile->open(QIODevice::WriteOnly)) - out = new QDataStream(outputFile); - } + // ensure paint buffer is created + paintDevice(); + buffer->beginNewFrame(); + + QRasterWindowSurface::beginPaint(rgn); +} +void QTraceWindowSurface::endPaint(const QRegion &rgn) +{ QPainter p(QRasterWindowSurface::paintDevice()); - buffer->draw(&p); + buffer->draw(&p, buffer->numFrames()-1); p.end(); - if (out) { - *out << frameId++; - *out << (qulonglong)window()->winId(); - *out << geometry(); - *out << rgn; - *out << *buffer; - } + winId = (qulonglong)window()->winId(); + + updates << rgn; - delete buffer; - buffer = 0; + QRasterWindowSurface::endPaint(rgn); +} + +bool QTraceWindowSurface::scroll(const QRegion &, int, int) +{ + // TODO: scrolling should also be streamed and replayed + // to test scrolling performance + return false; } QTraceGraphicsSystem::QTraceGraphicsSystem() diff --git a/tools/qttracereplay/main.cpp b/tools/qttracereplay/main.cpp index 970531b..34508e2 100644 --- a/tools/qttracereplay/main.cpp +++ b/tools/qttracereplay/main.cpp @@ -45,12 +45,6 @@ #include #include -struct Frame -{ - QRegion updateRegion; - QPaintBuffer *buffer; -}; - class ReplayWidget : public QWidget { Q_OBJECT @@ -63,7 +57,9 @@ public slots: void updateRect(); private: - QList frames; + QList updates; + QPaintBuffer buffer; + int currentFrame; int currentIteration; QTime timer; @@ -74,7 +70,7 @@ private: void ReplayWidget::updateRect() { - update(frames.at(currentFrame).updateRegion); + update(updates.at(currentFrame)); } void ReplayWidget::paintEvent(QPaintEvent *) @@ -83,10 +79,10 @@ void ReplayWidget::paintEvent(QPaintEvent *) // p.setClipRegion(frames.at(currentFrame).updateRegion); - frames.at(currentFrame).buffer->draw(&p); + buffer.draw(&p, currentFrame); ++currentFrame; - if (currentFrame >= frames.size()) { + if (currentFrame >= buffer.numFrames()) { currentFrame = 0; ++currentIteration; @@ -116,15 +112,13 @@ void ReplayWidget::paintEvent(QPaintEvent *) stddev = qSqrt(stddev / iterationTimes.size()); qSort(iterationTimes.begin(), iterationTimes.end()); - qreal median = iterationTimes.at(iterationTimes.size() / 2); - if ((iterationTimes.size() % 1) == 1) - median = (median + iterationTimes.at(iterationTimes.size() / 2 - 1)) * 0.5; + uint median = iterationTimes.at(iterationTimes.size() / 2); stddev = 100 * stddev / mean; if (iterationTimes.size() >= 10 || stddev < 4) { - printf("%s, iterations: %d, frames: %d, min(ms): %d, median(ms): %f, stddev: %f %%, max(fps): %f\n", qPrintable(filename), - iterationTimes.size(), frames.size(), min, median, stddev, 1000. * frames.size() / min); + printf("%s, iterations: %d, frames: %d, min(ms): %d, median(ms): %d, stddev: %f %%, max(fps): %f\n", qPrintable(filename), + iterationTimes.size(), updates.size(), min, median, stddev, 1000. * updates.size() / min); deleteLater(); return; } @@ -146,34 +140,12 @@ ReplayWidget::ReplayWidget(const QString &filename_) QRect bounds; if (file.open(QIODevice::ReadOnly)) { QDataStream in(&file); - - while (true) { - int frameId; - in >> frameId; - - if (in.status() != QDataStream::Ok) - break; - - qulonglong windowId; - QRegion rgn; - - in >> windowId; - - Frame frame; - frame.buffer = new QPaintBuffer; - - in >> bounds; - - in >> frame.updateRegion; - in >> *frame.buffer; - - frames << frame; - } + in >> buffer >> updates; } - qDebug() << "Read" << frames.size() << "frames"; + qDebug() << "Read paint buffer with" << buffer.numFrames() << "frames"; - resize(bounds.size()); + resize(buffer.boundingRect().size().toSize()); setAutoFillBackground(false); setAttribute(Qt::WA_NoSystemBackground); -- cgit v0.12 From 26d0990c66068bfc92a2ec77512b26d4a0c11b02 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Fri, 4 Sep 2009 15:38:35 +0200 Subject: Implement symbol hiding for JSC's JIT functions. These functions are implemented directly in assembly, so they need the proper directives to enable/disable visibility. On ELF systems, it's .hidden, whereas on Mach-O systems (Mac) it's .private_extern. On Windows, it's not necessary since you have to explicitly export. I also implemented the AIX idiom, though it's unlikely anyone will implement AIX/POWER JIT. That leaves only HP-UX on PA-RISC unimplemented, from the platforms that Qt supports. It's also unlikely that we'll imlpement JIT for it. Reviewed-by: Kent Hansen --- .../webkit/JavaScriptCore/jit/JITStubs.cpp | 23 ++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp b/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp index f0d3b84..0eb0799 100644 --- a/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp +++ b/src/3rdparty/webkit/JavaScriptCore/jit/JITStubs.cpp @@ -73,6 +73,19 @@ namespace JSC { #define SYMBOL_STRING(name) #name #endif +#if PLATFORM(DARWIN) + // Mach-O platform +#define HIDE_SYMBOL(name) ".private_extern _" #name +#elif PLATFORM(AIX) + // IBM's own file format +#define HIDE_SYMBOL(name) ".lglobl " #name +#elif PLATFORM(LINUX) || PLATFORM(FREEBSD) || PLATFORM(OPENBSD) || PLATFORM(SOLARIS) || (PLATFORM(HPUX) && PLATFORM(IA64)) || PLATFORM(SYMBIAN) || PLATFORM(NETBSD) + // ELF platform +#define HIDE_SYMBOL(name) ".hidden " #name +#else +#define HIDE_SYMBOL(name) +#endif + #if COMPILER(GCC) && PLATFORM(X86) // These ASSERTs remind you that, if you change the layout of JITStackFrame, you @@ -83,6 +96,7 @@ COMPILE_ASSERT(offsetof(struct JITStackFrame, savedEBX) == 0x1c, JITStackFrame_s asm volatile ( ".globl " SYMBOL_STRING(ctiTrampoline) "\n" +HIDE_SYMBOL(ctiTrampoline) "\n" SYMBOL_STRING(ctiTrampoline) ":" "\n" "pushl %ebp" "\n" "movl %esp, %ebp" "\n" @@ -103,6 +117,7 @@ SYMBOL_STRING(ctiTrampoline) ":" "\n" asm volatile ( ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n" +HIDE_SYMBOL(ctiVMThrowTrampoline) "\n" SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n" #if !USE(JIT_STUB_ARGUMENT_VA_LIST) "movl %esp, %ecx" "\n" @@ -118,6 +133,7 @@ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n" asm volatile ( ".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n" +HIDE_SYMBOL(ctiOpThrowNotCaught) "\n" SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n" "addl $0x1c, %esp" "\n" "popl %ebx" "\n" @@ -141,6 +157,7 @@ COMPILE_ASSERT(offsetof(struct JITStackFrame, savedRBX) == 0x48, JITStackFrame_s asm volatile ( ".globl " SYMBOL_STRING(ctiTrampoline) "\n" +HIDE_SYMBOL(ctiTrampoline) "\n" SYMBOL_STRING(ctiTrampoline) ":" "\n" "pushq %rbp" "\n" "movq %rsp, %rbp" "\n" @@ -167,6 +184,7 @@ SYMBOL_STRING(ctiTrampoline) ":" "\n" asm volatile ( ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n" +HIDE_SYMBOL(ctiVMThrowTrampoline) "\n" SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n" "movq %rsp, %rdi" "\n" "call " SYMBOL_STRING(cti_vm_throw) "\n" @@ -182,6 +200,7 @@ SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n" asm volatile ( ".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n" +HIDE_SYMBOL(ctiOpThrowNotCaught) "\n" SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n" "addq $0x48, %rsp" "\n" "popq %rbx" "\n" @@ -203,6 +222,7 @@ asm volatile ( ".text" "\n" ".align 2" "\n" ".globl " SYMBOL_STRING(ctiTrampoline) "\n" +HIDE_SYMBOL(ctiTrampoline) "\n" ".thumb" "\n" ".thumb_func " SYMBOL_STRING(ctiTrampoline) "\n" SYMBOL_STRING(ctiTrampoline) ":" "\n" @@ -229,6 +249,7 @@ asm volatile ( ".text" "\n" ".align 2" "\n" ".globl " SYMBOL_STRING(ctiVMThrowTrampoline) "\n" +HIDE_SYMBOL(ctiVMThrowTrampoline) "\n" ".thumb" "\n" ".thumb_func " SYMBOL_STRING(ctiVMThrowTrampoline) "\n" SYMBOL_STRING(ctiVMThrowTrampoline) ":" "\n" @@ -246,6 +267,7 @@ asm volatile ( ".text" "\n" ".align 2" "\n" ".globl " SYMBOL_STRING(ctiOpThrowNotCaught) "\n" +HIDE_SYMBOL(ctiOpThrowNotCaught) "\n" ".thumb" "\n" ".thumb_func " SYMBOL_STRING(ctiOpThrowNotCaught) "\n" SYMBOL_STRING(ctiOpThrowNotCaught) ":" "\n" @@ -591,6 +613,7 @@ namespace JITStubs { ".text" "\n" \ ".align 2" "\n" \ ".globl " SYMBOL_STRING(cti_##op) "\n" \ + HIDE_SYMBOL(cti_##op) "\n" \ ".thumb" "\n" \ ".thumb_func " SYMBOL_STRING(cti_##op) "\n" \ SYMBOL_STRING(cti_##op) ":" "\n" \ -- cgit v0.12 From bc75db154015a2da8d32e3e023bc76999dd5bfc0 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Fri, 4 Sep 2009 16:01:41 +0200 Subject: Fixed tst_QFiledialog::filesSelectedSignal where the selected directory to run the test may not have any file on it. Reviewed-by: Olivier --- tests/auto/qfiledialog/qfiledialog.pro | 9 +++++++++ tests/auto/qfiledialog/tst_qfiledialog.cpp | 3 ++- 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/tests/auto/qfiledialog/qfiledialog.pro b/tests/auto/qfiledialog/qfiledialog.pro index bea7716..058acc5 100644 --- a/tests/auto/qfiledialog/qfiledialog.pro +++ b/tests/auto/qfiledialog/qfiledialog.pro @@ -16,3 +16,12 @@ wince*|symbian: { symbian:TARGET.EPOCHEAPSIZE="0x100 0x1000000" symbian:HEADERS += ../../../include/qtgui/private/qfileinfogatherer_p.h + +wince*: { + DEFINES += SRCDIR=\\\"./\\\" +} symbian: { + TARGET.UID3 = 0xE0340003 + DEFINES += SYMBIAN_SRCDIR_UID=$$lower($$replace(TARGET.UID3,"0x","")) +} else { + DEFINES += SRCDIR=\\\"$$PWD/\\\" +} diff --git a/tests/auto/qfiledialog/tst_qfiledialog.cpp b/tests/auto/qfiledialog/tst_qfiledialog.cpp index 161efe0..67be797 100644 --- a/tests/auto/qfiledialog/tst_qfiledialog.cpp +++ b/tests/auto/qfiledialog/tst_qfiledialog.cpp @@ -297,7 +297,8 @@ void tst_QFiledialog::filesSelectedSignal() QNonNativeFileDialog fd; fd.setViewMode(QFileDialog::List); fd.setOptions(QFileDialog::DontUseNativeDialog); - fd.setDirectory(QDir::homePath()); + QDir testDir(SRCDIR"/../../.."); + fd.setDirectory(testDir); QFETCH(QFileDialog::FileMode, fileMode); fd.setFileMode(fileMode); QSignalSpy spyFilesSelected(&fd, SIGNAL(filesSelected(const QStringList &))); -- cgit v0.12 From fcd105dba705f148f774e085f6deb8be96fce628 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Thu, 3 Sep 2009 14:40:10 +0200 Subject: More fixes for qatomic_windows.h If platform headers have been included the Interlocked names may be macros and we end up with double underscores in our function names. By prefixing "Interlocked" and then the actual function names we work around that. Let's hope nobody redefines Interlocked or Increment and friends... :-) Reviewed-by: Prasanth Ullattil --- src/corelib/arch/qatomic_windows.h | 49 +++++++++++++++++++++----------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/src/corelib/arch/qatomic_windows.h b/src/corelib/arch/qatomic_windows.h index 6082d0b..07b0b25 100644 --- a/src/corelib/arch/qatomic_windows.h +++ b/src/corelib/arch/qatomic_windows.h @@ -102,9 +102,14 @@ #define QT_INTERLOCKED_CONCAT(prefix, suffix) \ QT_INTERLOCKED_CONCAT_I(prefix, suffix) -// MSVC intrinsics prefix function names with an underscore +// MSVC intrinsics prefix function names with an underscore. Also, if platform +// SDK headers have been included, the Interlocked names may be defined as +// macros. +// To avoid double underscores, we paste the prefix with Interlocked first and +// then the remainder of the function name. #define QT_INTERLOCKED_FUNCTION(name) \ - QT_INTERLOCKED_CONCAT(QT_INTERLOCKED_PREFIX, name) + QT_INTERLOCKED_CONCAT( \ + QT_INTERLOCKED_CONCAT(QT_INTERLOCKED_PREFIX, Interlocked), name) #ifdef QT_INTERLOCKED_NO_VOLATILE # define QT_INTERLOCKED_VOLATILE @@ -127,16 +132,16 @@ extern "C" { - long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( InterlockedIncrement )(long QT_INTERLOCKED_VOLATILE *); - long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( InterlockedDecrement )(long QT_INTERLOCKED_VOLATILE *); - long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( InterlockedCompareExchange )(long QT_INTERLOCKED_VOLATILE *, long, long); - long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( InterlockedExchange )(long QT_INTERLOCKED_VOLATILE *, long); - long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( InterlockedExchangeAdd )(long QT_INTERLOCKED_VOLATILE *, long); + long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( Increment )(long QT_INTERLOCKED_VOLATILE *); + long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( Decrement )(long QT_INTERLOCKED_VOLATILE *); + long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( CompareExchange )(long QT_INTERLOCKED_VOLATILE *, long, long); + long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( Exchange )(long QT_INTERLOCKED_VOLATILE *, long); + long QT_INTERLOCKED_PROTOTYPE QT_INTERLOCKED_FUNCTION( ExchangeAdd )(long QT_INTERLOCKED_VOLATILE *, long); # if !defined(Q_OS_WINCE) && !defined(__i386__) && !defined(_M_IX86) - void * QT_INTERLOCKED_FUNCTION( InterlockedCompareExchangePointer )(void * QT_INTERLOCKED_VOLATILE *, void *, void *); - void * QT_INTERLOCKED_FUNCTION( InterlockedExchangePointer )(void * QT_INTERLOCKED_VOLATILE *, void *); - __int64 QT_INTERLOCKED_FUNCTION( InterlockedExchangeAdd64 )(__int64 QT_INTERLOCKED_VOLATILE *, __int64); + void * QT_INTERLOCKED_FUNCTION( CompareExchangePointer )(void * QT_INTERLOCKED_VOLATILE *, void *, void *); + void * QT_INTERLOCKED_FUNCTION( ExchangePointer )(void * QT_INTERLOCKED_VOLATILE *, void *); + __int64 QT_INTERLOCKED_FUNCTION( ExchangeAdd64 )(__int64 QT_INTERLOCKED_VOLATILE *, __int64); # endif } @@ -156,7 +161,7 @@ extern "C" { # pragma intrinsic (_InterlockedCompareExchange) # pragma intrinsic (_InterlockedExchangeAdd) -# ifndef _M_IX86 +# if !defined(Q_OS_WINCE) && !defined(_M_IX86) # pragma intrinsic (_InterlockedCompareExchangePointer) # pragma intrinsic (_InterlockedExchangePointer) # pragma intrinsic (_InterlockedExchangeAdd64) @@ -168,26 +173,26 @@ extern "C" { // Interlocked* replacement macros #define QT_INTERLOCKED_INCREMENT(value) \ - QT_INTERLOCKED_FUNCTION(InterlockedIncrement)( \ + QT_INTERLOCKED_FUNCTION( Increment )( \ QT_INTERLOCKED_REMOVE_VOLATILE( value ) ) #define QT_INTERLOCKED_DECREMENT(value) \ - QT_INTERLOCKED_FUNCTION(InterlockedDecrement)( \ + QT_INTERLOCKED_FUNCTION( Decrement )( \ QT_INTERLOCKED_REMOVE_VOLATILE( value ) ) #define QT_INTERLOCKED_COMPARE_EXCHANGE(value, newValue, expectedValue) \ - QT_INTERLOCKED_FUNCTION(InterlockedCompareExchange)( \ + QT_INTERLOCKED_FUNCTION( CompareExchange )( \ QT_INTERLOCKED_REMOVE_VOLATILE( value ), \ newValue, \ expectedValue ) #define QT_INTERLOCKED_EXCHANGE(value, newValue) \ - QT_INTERLOCKED_FUNCTION(InterlockedExchange)( \ + QT_INTERLOCKED_FUNCTION( Exchange )( \ QT_INTERLOCKED_REMOVE_VOLATILE( value ), \ newValue ) #define QT_INTERLOCKED_EXCHANGE_ADD(value, valueToAdd) \ - QT_INTERLOCKED_FUNCTION(InterlockedExchangeAdd)( \ + QT_INTERLOCKED_FUNCTION( ExchangeAdd )( \ QT_INTERLOCKED_REMOVE_VOLATILE( value ), \ valueToAdd ) @@ -195,36 +200,36 @@ extern "C" { # define QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER(value, newValue, expectedValue) \ reinterpret_cast( \ - QT_INTERLOCKED_FUNCTION(InterlockedCompareExchange)( \ + QT_INTERLOCKED_FUNCTION( CompareExchange )( \ QT_INTERLOCKED_REMOVE_VOLATILE( value ## _integral ), \ (long)( newValue ), \ (long)( expectedValue ) )) # define QT_INTERLOCKED_EXCHANGE_POINTER(value, newValue) \ - QT_INTERLOCKED_FUNCTION(InterlockedExchange)( \ + QT_INTERLOCKED_FUNCTION( Exchange )( \ QT_INTERLOCKED_REMOVE_VOLATILE( value ## _integral ), \ (quintptr)( newValue ) ) # define QT_INTERLOCKED_EXCHANGE_ADD_POINTER(value, valueToAdd) \ - QT_INTERLOCKED_FUNCTION(InterlockedExchangeAdd)( \ + QT_INTERLOCKED_FUNCTION( ExchangeAdd )( \ QT_INTERLOCKED_REMOVE_VOLATILE( value ## _integral ), \ valueToAdd ) #else // !defined(Q_OS_WINCE) && !defined(__i386__) && !defined(_M_IX86) # define QT_INTERLOCKED_COMPARE_EXCHANGE_POINTER(value, newValue, expectedValue) \ - QT_INTERLOCKED_FUNCTION(InterlockedCompareExchangePointer)( \ + QT_INTERLOCKED_FUNCTION( CompareExchangePointer )( \ reinterpret_cast( QT_INTERLOCKED_REMOVE_VOLATILE( value ) ), \ newValue, \ expectedValue ) # define QT_INTERLOCKED_EXCHANGE_POINTER(value, newValue) \ - QT_INTERLOCKED_FUNCTION(InterlockedExchangePointer)( \ + QT_INTERLOCKED_FUNCTION( ExchangePointer )( \ reinterpret_cast( QT_INTERLOCKED_REMOVE_VOLATILE( value ) ), \ newValue ) # define QT_INTERLOCKED_EXCHANGE_ADD_POINTER(value, valueToAdd) \ - QT_INTERLOCKED_FUNCTION(InterlockedExchangeAdd64)( \ + QT_INTERLOCKED_FUNCTION( ExchangeAdd64 )( \ QT_INTERLOCKED_REMOVE_VOLATILE( value ## _integral ), \ valueToAdd ) -- cgit v0.12 From 504b819e01d5b3768fc525c648ce43a1574b81d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jo=C3=A3o=20Abecasis?= Date: Fri, 4 Sep 2009 13:03:26 +0200 Subject: Updating line-numbers for linguist auto tests --- .../lupdate/testdata/good/lacksqobject/expectedoutput.txt | 8 ++++---- .../linguist/lupdate/testdata/good/merge_ordering/foo.cpp | 1 + .../testdata/good/mergecpp_noobsolete/project.ts.result | 8 ++++---- .../testdata/good/mergecpp_obsolete/project.ts.result | 8 ++++---- .../linguist/lupdate/testdata/good/mergeui/project.ts.result | 6 +++--- tests/auto/linguist/lupdate/testdata/good/mergeui/project.ui | 6 ++++-- .../testdata/good/multiple_locations/project.ts.result | 6 +++--- .../lupdate/testdata/good/namespaces/project.ts.result | 2 +- .../lupdate/testdata/good/parsecpp/project.ts.result | 10 +++++----- .../lupdate/testdata/good/parsecpp2/expectedoutput.txt | 8 ++++---- .../linguist/lupdate/testdata/good/parseui/project.ts.result | 4 ++-- .../linguist/lupdate/testdata/good/prefix/project.ts.result | 6 +++--- .../linguist/lupdate/testdata/recursivescan/bar.ts.result | 8 ++++---- .../linguist/lupdate/testdata/recursivescan/foo.ts.result | 12 ++++++------ .../auto/linguist/lupdate/testdata/recursivescan/project.ui | 6 ++++-- 15 files changed, 52 insertions(+), 47 deletions(-) diff --git a/tests/auto/linguist/lupdate/testdata/good/lacksqobject/expectedoutput.txt b/tests/auto/linguist/lupdate/testdata/good/lacksqobject/expectedoutput.txt index 1a6cfeb..72ec3c5 100644 --- a/tests/auto/linguist/lupdate/testdata/good/lacksqobject/expectedoutput.txt +++ b/tests/auto/linguist/lupdate/testdata/good/lacksqobject/expectedoutput.txt @@ -1,8 +1,8 @@ -.*/lupdate/testdata/good/lacksqobject/main.cpp:17: Class 'B' lacks Q_OBJECT macro +.*/lupdate/testdata/good/lacksqobject/main.cpp:58: Class 'B' lacks Q_OBJECT macro -.*/lupdate/testdata/good/lacksqobject/main.cpp:24: Class 'C' lacks Q_OBJECT macro +.*/lupdate/testdata/good/lacksqobject/main.cpp:65: Class 'C' lacks Q_OBJECT macro -.*/lupdate/testdata/good/lacksqobject/main.cpp:37: Class 'nsB::B' lacks Q_OBJECT macro +.*/lupdate/testdata/good/lacksqobject/main.cpp:78: Class 'nsB::B' lacks Q_OBJECT macro -.*/lupdate/testdata/good/lacksqobject/main.cpp:43: Class 'nsB::C' lacks Q_OBJECT macro +.*/lupdate/testdata/good/lacksqobject/main.cpp:84: Class 'nsB::C' lacks Q_OBJECT macro diff --git a/tests/auto/linguist/lupdate/testdata/good/merge_ordering/foo.cpp b/tests/auto/linguist/lupdate/testdata/good/merge_ordering/foo.cpp index e1fca6e..0f7f9fb 100644 --- a/tests/auto/linguist/lupdate/testdata/good/merge_ordering/foo.cpp +++ b/tests/auto/linguist/lupdate/testdata/good/merge_ordering/foo.cpp @@ -1,3 +1,4 @@ + /**************************************************************************** ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.ts.result index de2c45a..b328e90 100644 --- a/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp_noobsolete/project.ts.result @@ -4,22 +4,22 @@ FindDialog - + Enter the text you want to find. - + Search reached end of the document - + Search reached start of the document - + Text not found diff --git a/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.ts.result index 4012182..cfd11b1 100644 --- a/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/mergecpp_obsolete/project.ts.result @@ -8,22 +8,22 @@ Skriv inn teksten du soker etter - + Enter the text you want to find. - + Search reached end of the document - + Search reached start of the document - + Text not found diff --git a/tests/auto/linguist/lupdate/testdata/good/mergeui/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/mergeui/project.ts.result index 4c5f74d..1a2244b 100644 --- a/tests/auto/linguist/lupdate/testdata/good/mergeui/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/mergeui/project.ts.result @@ -4,18 +4,18 @@ FindDialog - + Qt Assistant - Find Text Qt Assistant - Find text Qt Assistant - Finn tekst - + 300px 300px - + 401 pixels diff --git a/tests/auto/linguist/lupdate/testdata/good/mergeui/project.ui b/tests/auto/linguist/lupdate/testdata/good/mergeui/project.ui index d022101..1d8a716 100644 --- a/tests/auto/linguist/lupdate/testdata/good/mergeui/project.ui +++ b/tests/auto/linguist/lupdate/testdata/good/mergeui/project.ui @@ -1,6 +1,7 @@ - ********************************************************************* + +********************************************************************* ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) @@ -39,7 +40,8 @@ ** ** $QT_END_LICENSE$ ** -********************************************************************* +********************************************************************* + FindDialog diff --git a/tests/auto/linguist/lupdate/testdata/good/multiple_locations/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/multiple_locations/project.ts.result index ec1f02f..a7ae155 100644 --- a/tests/auto/linguist/lupdate/testdata/good/multiple_locations/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/multiple_locations/project.ts.result @@ -4,9 +4,9 @@ context - - - + + + just a message This is one comment ---------- diff --git a/tests/auto/linguist/lupdate/testdata/good/namespaces/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/namespaces/project.ts.result index bb5b739..c1a34bd 100644 --- a/tests/auto/linguist/lupdate/testdata/good/namespaces/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/namespaces/project.ts.result @@ -30,7 +30,7 @@ Outer::Middle1::Different - different namespaced class def diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result index 9e4e319..d63c7c3 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp/project.ts.result @@ -4,14 +4,14 @@ - + This is supposed to be quoted " newline backslashed \ stuff. again an extra comment, this time for id-based NOOP - + This needs to be here. Really. @@ -259,7 +259,7 @@ backslashed \ stuff. TestingTake17 - + something cool random comment @@ -267,12 +267,12 @@ backslashed \ stuff. fooish_bar - + less cool - + even more cool diff --git a/tests/auto/linguist/lupdate/testdata/good/parsecpp2/expectedoutput.txt b/tests/auto/linguist/lupdate/testdata/good/parsecpp2/expectedoutput.txt index e3f7926..8d057d8 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parsecpp2/expectedoutput.txt +++ b/tests/auto/linguist/lupdate/testdata/good/parsecpp2/expectedoutput.txt @@ -1,7 +1,7 @@ -.*/lupdate/testdata/good/parsecpp2/main.cpp:10: Excess closing brace .* +.*/lupdate/testdata/good/parsecpp2/main.cpp:51: Excess closing brace .* -.*/lupdate/testdata/good/parsecpp2/main.cpp:14: Excess closing brace .* +.*/lupdate/testdata/good/parsecpp2/main.cpp:55: Excess closing brace .* -.*/lupdate/testdata/good/parsecpp2/main.cpp:20: Excess closing brace .* +.*/lupdate/testdata/good/parsecpp2/main.cpp:61: Excess closing brace .* -.*/lupdate/testdata/good/parsecpp2/main.cpp:24: Excess closing brace .* +.*/lupdate/testdata/good/parsecpp2/main.cpp:65: Excess closing brace .* diff --git a/tests/auto/linguist/lupdate/testdata/good/parseui/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/parseui/project.ts.result index 7f665f4..93adae4 100644 --- a/tests/auto/linguist/lupdate/testdata/good/parseui/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/parseui/project.ts.result @@ -4,12 +4,12 @@ FindDialog - + Qt Assistant - Finn text - + Finn tekst - Der Bjørn möchte auch mal. diff --git a/tests/auto/linguist/lupdate/testdata/good/prefix/project.ts.result b/tests/auto/linguist/lupdate/testdata/good/prefix/project.ts.result index c15b986..e356921 100644 --- a/tests/auto/linguist/lupdate/testdata/good/prefix/project.ts.result +++ b/tests/auto/linguist/lupdate/testdata/good/prefix/project.ts.result @@ -4,18 +4,18 @@ Foo - + XXX YYY - + CTOR - + BAR diff --git a/tests/auto/linguist/lupdate/testdata/recursivescan/bar.ts.result b/tests/auto/linguist/lupdate/testdata/recursivescan/bar.ts.result index b86edae..5c3c21c 100644 --- a/tests/auto/linguist/lupdate/testdata/recursivescan/bar.ts.result +++ b/tests/auto/linguist/lupdate/testdata/recursivescan/bar.ts.result @@ -4,22 +4,22 @@ FindDialog - + Enter the text you want to find. - + Search reached end of the document - + Search reached start of the document - + Text not found diff --git a/tests/auto/linguist/lupdate/testdata/recursivescan/foo.ts.result b/tests/auto/linguist/lupdate/testdata/recursivescan/foo.ts.result index 835b3e0..95a34fa 100644 --- a/tests/auto/linguist/lupdate/testdata/recursivescan/foo.ts.result +++ b/tests/auto/linguist/lupdate/testdata/recursivescan/foo.ts.result @@ -4,32 +4,32 @@ FindDialog - + Qt Assistant - Finn text - + Finn tekst - + Enter the text you want to find. - + Search reached end of the document - + Search reached start of the document - + Text not found diff --git a/tests/auto/linguist/lupdate/testdata/recursivescan/project.ui b/tests/auto/linguist/lupdate/testdata/recursivescan/project.ui index 709b3e8..d25001f 100644 --- a/tests/auto/linguist/lupdate/testdata/recursivescan/project.ui +++ b/tests/auto/linguist/lupdate/testdata/recursivescan/project.ui @@ -1,6 +1,7 @@ -********************************************************************* + +********************************************************************* ** ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). ** Contact: Nokia Corporation (qt-info@nokia.com) @@ -39,7 +40,8 @@ ** ** $QT_END_LICENSE$ ** -********************************************************************* +********************************************************************* + FindDialog -- cgit v0.12 From 1dd1400a84831da7377dadd2521460f129e9640a Mon Sep 17 00:00:00 2001 From: Thomas Zander Date: Wed, 2 Sep 2009 22:04:22 +0200 Subject: Make the example also work on a desktop with a dark theme. --- tests/manual/qtabletevent/device_information/tabletwidget.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/manual/qtabletevent/device_information/tabletwidget.cpp b/tests/manual/qtabletevent/device_information/tabletwidget.cpp index 15a3d80..684f2a5 100644 --- a/tests/manual/qtabletevent/device_information/tabletwidget.cpp +++ b/tests/manual/qtabletevent/device_information/tabletwidget.cpp @@ -47,6 +47,7 @@ TabletWidget::TabletWidget() { QPalette newPalette = palette(); newPalette.setColor(QPalette::Window, Qt::white); + newPalette.setColor(QPalette::WindowText, Qt::black); setPalette(newPalette); qApp->installEventFilter(this); resetAttributes(); -- cgit v0.12 From 3959edcf4c4a531e87c9296ba401bd0f08caaed4 Mon Sep 17 00:00:00 2001 From: Kim Motoyoshi Kalland Date: Fri, 4 Sep 2009 17:00:06 +0200 Subject: Fixed object rotations in the boxes demo. When Math3D was introduced, the boxes demo was changed to use the classes in the new module, but the change caused some bugs with the object rotations. This commit should fix them. Reviewed-by: Samuel --- demos/boxes/scene.cpp | 5 +---- demos/boxes/trackball.cpp | 14 +++++++------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/demos/boxes/scene.cpp b/demos/boxes/scene.cpp index 7c0d4d8..0975fc5 100644 --- a/demos/boxes/scene.cpp +++ b/demos/boxes/scene.cpp @@ -718,8 +718,6 @@ void Scene::renderBoxes(const QMatrix4x4 &view, int excludeBox) glPushMatrix(); QMatrix4x4 m; m.rotate(m_trackBalls[1].rotation()); - m = m.transposed(); - multMatrix(m); glRotatef(360.0f * i / m_programs.size(), 0.0f, 0.0f, 1.0f); @@ -753,7 +751,6 @@ void Scene::renderBoxes(const QMatrix4x4 &view, int excludeBox) if (-1 != excludeBox) { QMatrix4x4 m; m.rotate(m_trackBalls[0].rotation()); - m = m.transposed(); multMatrix(m); if (glActiveTexture) { @@ -880,7 +877,7 @@ void Scene::renderCubemaps() GLRenderTargetCube::getViewMatrix(mat, face); QVector4D v = QVector4D(-center.x(), -center.y(), -center.z(), 1.0); - mat.setColumn(3, v * mat); + mat.setColumn(3, mat * v); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); renderBoxes(mat, i); diff --git a/demos/boxes/trackball.cpp b/demos/boxes/trackball.cpp index 9898441..60de6af 100644 --- a/demos/boxes/trackball.cpp +++ b/demos/boxes/trackball.cpp @@ -92,9 +92,9 @@ void TrackBall::move(const QPointF& p, const QQuaternion &transformation) { QLineF delta(m_lastPos, p); m_angularVelocity = 180*delta.length() / (PI*msecs); - m_axis = QVector3D(delta.dy(), -delta.dx(), 0.0f).normalized(); + m_axis = QVector3D(-delta.dy(), delta.dx(), 0.0f).normalized(); m_axis = transformation.rotateVector(m_axis); - m_rotation *= QQuaternion::fromAxisAndAngle(m_axis, delta.length()); + m_rotation = QQuaternion::fromAxisAndAngle(m_axis, 180 / PI * delta.length()) * m_rotation; } break; case Sphere: @@ -113,13 +113,13 @@ void TrackBall::move(const QPointF& p, const QQuaternion &transformation) else currentPos3D.normalize(); - m_axis = QVector3D::crossProduct(currentPos3D, lastPos3D); - float angle = asin(sqrt(QVector3D::dotProduct(m_axis, m_axis))); + m_axis = QVector3D::crossProduct(lastPos3D, currentPos3D); + float angle = 180 / PI * asin(sqrt(QVector3D::dotProduct(m_axis, m_axis))); - m_angularVelocity = 180*angle / (PI*msecs); + m_angularVelocity = angle / msecs; m_axis.normalize(); m_axis = transformation.rotateVector(m_axis); - m_rotation *= QQuaternion::fromAxisAndAngle(m_axis, angle); + m_rotation = QQuaternion::fromAxisAndAngle(m_axis, angle) * m_rotation; } break; } @@ -155,6 +155,6 @@ QQuaternion TrackBall::rotation() const QTime currentTime = QTime::currentTime(); float angle = m_angularVelocity * m_lastTime.msecsTo(currentTime); - return m_rotation * QQuaternion::fromAxisAndAngle(m_axis, angle); + return QQuaternion::fromAxisAndAngle(m_axis, angle) * m_rotation; } -- cgit v0.12