From 88eb3b1670ac3989e6549bd8870f482ce357c979 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Wed, 31 Mar 2010 11:41:07 +1000 Subject: Allow attributes to be bound after a QGLShaderProgram is linked. Task-number: QTBUG-9450 Reviewed-by: Sarah Smith --- src/opengl/qglshaderprogram.cpp | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/opengl/qglshaderprogram.cpp b/src/opengl/qglshaderprogram.cpp index 79484fa..bbfc2d5 100644 --- a/src/opengl/qglshaderprogram.cpp +++ b/src/opengl/qglshaderprogram.cpp @@ -969,17 +969,18 @@ GLuint QGLShaderProgram::programId() const Any attributes that have not been explicitly bound when the program is linked will be assigned locations automatically. + When this function is called after the program has been linked, + the program will need to be relinked for the change to take effect. + \sa attributeLocation() */ void QGLShaderProgram::bindAttributeLocation(const char *name, int location) { Q_D(QGLShaderProgram); - if (!d->linked) { - glBindAttribLocation(d->programGuard.id(), location, name); - } else { - qWarning() << "QGLShaderProgram::bindAttributeLocation(" << name - << "): cannot bind after shader program is linked"; - } + if (!init()) + return; + glBindAttribLocation(d->programGuard.id(), location, name); + d->linked = false; // Program needs to be relinked. } /*! @@ -990,6 +991,9 @@ void QGLShaderProgram::bindAttributeLocation(const char *name, int location) Any attributes that have not been explicitly bound when the program is linked will be assigned locations automatically. + When this function is called after the program has been linked, + the program will need to be relinked for the change to take effect. + \sa attributeLocation() */ void QGLShaderProgram::bindAttributeLocation(const QByteArray& name, int location) @@ -1005,6 +1009,9 @@ void QGLShaderProgram::bindAttributeLocation(const QByteArray& name, int locatio Any attributes that have not been explicitly bound when the program is linked will be assigned locations automatically. + When this function is called after the program has been linked, + the program will need to be relinked for the change to take effect. + \sa attributeLocation() */ void QGLShaderProgram::bindAttributeLocation(const QString& name, int location) -- cgit v0.12 From 04b2c18ea04abcf38df4f924479a0aed75fe40c9 Mon Sep 17 00:00:00 2001 From: David Faure Date: Wed, 31 Mar 2010 10:44:20 +0200 Subject: Fix translation mistake spotted by Laurent Montel Merge-request: 542 Reviewed-by: Oswald Buddenhagen --- translations/designer_fr.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/translations/designer_fr.ts b/translations/designer_fr.ts index b3bf4de..bfdbb73 100644 --- a/translations/designer_fr.ts +++ b/translations/designer_fr.ts @@ -1166,7 +1166,7 @@ &Pixmap Function - Function de &pixmap + Fonction de &pixmap -- cgit v0.12 From 27a110eb7238b8b8d72db968d813855a9c2afb08 Mon Sep 17 00:00:00 2001 From: David Faure Date: Wed, 31 Mar 2010 11:13:38 +0200 Subject: Fix crash when using qDebug() on a QBrush with Qt::TexturePattern style. Merge-request: 541 Reviewed-by: Benjamin Poulain --- src/gui/painting/qbrush.cpp | 3 ++- tests/auto/qbrush/tst_qbrush.cpp | 13 ++++++++++++- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/gui/painting/qbrush.cpp b/src/gui/painting/qbrush.cpp index 1a83b1d..fcfc44d 100644 --- a/src/gui/painting/qbrush.cpp +++ b/src/gui/painting/qbrush.cpp @@ -989,7 +989,8 @@ QDebug operator<<(QDebug dbg, const QBrush &b) "LinearGradientPattern", "RadialGradientPattern", "ConicalGradientPattern", - "TexturePattern" + 0, 0, 0, 0, 0, 0, + "TexturePattern" // 24 }; dbg.nospace() << "QBrush(" << b.color() << ',' << BRUSH_STYLES[b.style()] << ')'; diff --git a/tests/auto/qbrush/tst_qbrush.cpp b/tests/auto/qbrush/tst_qbrush.cpp index bc2bc60..cff45c2 100644 --- a/tests/auto/qbrush/tst_qbrush.cpp +++ b/tests/auto/qbrush/tst_qbrush.cpp @@ -75,9 +75,10 @@ private slots: void gradientStops(); void textures(); - + void nullBrush(); void isOpaque(); + void debug(); }; Q_DECLARE_METATYPE(QBrush) @@ -390,5 +391,15 @@ void tst_QBrush::isOpaque() QVERIFY(!brush.isOpaque()); } +void tst_QBrush::debug() +{ + QPixmap pixmap_source(10, 10); + fill(&pixmap_source); + QBrush pixmap_brush; + pixmap_brush.setTexture(pixmap_source); + QCOMPARE(pixmap_brush.style(), Qt::TexturePattern); + qDebug() << pixmap_brush; // don't crash +} + QTEST_MAIN(tst_QBrush) #include "tst_qbrush.moc" -- cgit v0.12 From 670ef284a02e822fa244462e9e8126bc646dff5e Mon Sep 17 00:00:00 2001 From: Tasuku Suzuki Date: Thu, 18 Mar 2010 22:58:51 +0900 Subject: Fix compile error with QT_NO_NETWORKDISKCACHE in QtNetwork Merge-request: 2332 Reviewed-by: Peter Hartmann --- src/network/access/qnetworkdiskcache.cpp | 3 ++- src/network/access/qnetworkdiskcache_p.h | 4 ++++ 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/network/access/qnetworkdiskcache.cpp b/src/network/access/qnetworkdiskcache.cpp index ec6817a..cce6bd9 100644 --- a/src/network/access/qnetworkdiskcache.cpp +++ b/src/network/access/qnetworkdiskcache.cpp @@ -41,7 +41,6 @@ //#define QNETWORKDISKCACHE_DEBUG -#ifndef QT_NO_NETWORKDISKCACHE #include "qnetworkdiskcache.h" #include "qnetworkdiskcache_p.h" @@ -60,6 +59,8 @@ #define CACHE_POSTFIX QLatin1String(".cache") #define MAX_COMPRESSION_SIZE (1024 * 1024 * 3) +#ifndef QT_NO_NETWORKDISKCACHE + QT_BEGIN_NAMESPACE /*! diff --git a/src/network/access/qnetworkdiskcache_p.h b/src/network/access/qnetworkdiskcache_p.h index ad46602..b6df179 100644 --- a/src/network/access/qnetworkdiskcache_p.h +++ b/src/network/access/qnetworkdiskcache_p.h @@ -59,6 +59,8 @@ #include #include +#ifndef QT_NO_NETWORKDISKCACHE + QT_BEGIN_NAMESPACE class QFile; @@ -119,4 +121,6 @@ public: QT_END_NAMESPACE +#endif // QT_NO_NETWORKDISKCACHE + #endif // QNETWORKDISKCACHE_P_H -- cgit v0.12 From 91ba0239bcaca91e5d07b685e53ecd3ce13d58ba Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 31 Mar 2010 13:46:10 +0100 Subject: Remove compiler warning RVCT complains that a non-POD type (VideoParameters) is passed through the TRACE_ENTRY ellipsis, when building in debug mode. Reviewed-by: trustme --- src/3rdparty/phonon/mmf/videoplayer_dsa.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/3rdparty/phonon/mmf/videoplayer_dsa.cpp b/src/3rdparty/phonon/mmf/videoplayer_dsa.cpp index 226d079..d607f1d 100644 --- a/src/3rdparty/phonon/mmf/videoplayer_dsa.cpp +++ b/src/3rdparty/phonon/mmf/videoplayer_dsa.cpp @@ -217,7 +217,7 @@ void getDsaRegion(RWsSession &session, const RWindowBase &window) void MMF::DsaVideoPlayer::handleParametersChanged(VideoParameters parameters) { TRACE_CONTEXT(DsaVideoPlayer::handleParametersChanged, EVideoInternal); - TRACE_ENTRY("parameters 0x%x", parameters); + TRACE_ENTRY("parameters 0x%x", parameters.operator int()); if (!m_window) return; -- cgit v0.12 From 6ac2419622eadb54c86e24c6a57824c7f78b07ac Mon Sep 17 00:00:00 2001 From: Gareth Stockwell Date: Wed, 31 Mar 2010 13:49:35 +0100 Subject: Ensure Phonon MMF backend emits aboutToFinish It seems that, after a call to CMdaAudioPlayerUtility::SetPosition, the reported position values are slightly lower than they should be. This, combined with the fact that the backend emitted aboutToFinish from its timer tick slot, means that the aboutToFinish signal is sometimes not emitted at the end of an audio clip, if the position has been advanced by seeking during playback. This patch adds a check in the implementation of the MMdaAudioPlayerCallback::MapcPlayComplete callback - if, at this point, aboutToFinish has not been emitted, it is emitted now. Task-number: QTBUG-9368 Reviewed-by: trustme --- src/3rdparty/phonon/mmf/abstractmediaplayer.cpp | 13 +++++++++---- src/3rdparty/phonon/mmf/abstractmediaplayer.h | 2 +- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp index 544762a..6356c21 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.cpp @@ -369,6 +369,13 @@ void MMF::AbstractMediaPlayer::playbackComplete(int error) { stopTimers(); + if (KErrNone == error && !m_aboutToFinishSent) { + const qint64 total = totalTime(); + emit MMF::AbstractPlayer::tick(total); + m_aboutToFinishSent = true; + emit aboutToFinish(); + } + if (KErrNone == error) { changeState(StoppedState); @@ -393,15 +400,13 @@ qint64 MMF::AbstractMediaPlayer::toMilliSeconds(const TTimeIntervalMicroSeconds void MMF::AbstractMediaPlayer::positionTick() { - emitMarksIfReached(); - const qint64 current = currentTime(); + emitMarksIfReached(current); emit MMF::AbstractPlayer::tick(current); } -void MMF::AbstractMediaPlayer::emitMarksIfReached() +void MMF::AbstractMediaPlayer::emitMarksIfReached(qint64 current) { - const qint64 current = currentTime(); const qint64 total = totalTime(); const qint64 remaining = total - current; diff --git a/src/3rdparty/phonon/mmf/abstractmediaplayer.h b/src/3rdparty/phonon/mmf/abstractmediaplayer.h index abd6bff..308b5af 100644 --- a/src/3rdparty/phonon/mmf/abstractmediaplayer.h +++ b/src/3rdparty/phonon/mmf/abstractmediaplayer.h @@ -91,7 +91,7 @@ private: void stopBufferStatusTimer(); void stopTimers(); void doVolumeChanged(); - void emitMarksIfReached(); + void emitMarksIfReached(qint64 position); void resetMarksIfRewound(); private Q_SLOTS: -- cgit v0.12 From 741b75b8e595a26944ba8fca8835463787b02676 Mon Sep 17 00:00:00 2001 From: Toby Tomkins Date: Thu, 1 Apr 2010 10:33:12 +1000 Subject: Remove qWait functions as it is used in QTRY_* macros. Reviewed-by: rohan mcgovern --- tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 509 +++++++++---------------- 1 file changed, 182 insertions(+), 327 deletions(-) diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 4d9f23f..9f7db95 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -960,12 +960,11 @@ void tst_QGraphicsItem::toolTip() QGraphicsView view(&scene); view.setFixedSize(200, 200); view.show(); - QTest::qWait(250); { QHelpEvent helpEvent(QEvent::ToolTip, view.viewport()->rect().topLeft(), view.viewport()->mapToGlobal(view.viewport()->rect().topLeft())); QApplication::sendEvent(view.viewport(), &helpEvent); - QTest::qWait(250); + QTRY_COMPARE(QApplication::topLevelWidgets().size(), 1); bool foundView = false; bool foundTipLabel = false; @@ -975,15 +974,15 @@ void tst_QGraphicsItem::toolTip() if (widget->inherits("QTipLabel")) foundTipLabel = true; } - QVERIFY(foundView); - QVERIFY(!foundTipLabel); + QTRY_VERIFY(foundView); + QTRY_VERIFY(!foundTipLabel); } { QHelpEvent helpEvent(QEvent::ToolTip, view.viewport()->rect().center(), view.viewport()->mapToGlobal(view.viewport()->rect().center())); QApplication::sendEvent(view.viewport(), &helpEvent); - QTest::qWait(250); + QTRY_COMPARE(QApplication::topLevelWidgets().size(), 2); bool foundView = false; bool foundTipLabel = false; @@ -993,15 +992,15 @@ void tst_QGraphicsItem::toolTip() if (widget->inherits("QTipLabel")) foundTipLabel = true; } - QVERIFY(foundView); - QVERIFY(foundTipLabel); + QTRY_VERIFY(foundView); + QTRY_VERIFY(foundTipLabel); } { QHelpEvent helpEvent(QEvent::ToolTip, view.viewport()->rect().topLeft(), view.viewport()->mapToGlobal(view.viewport()->rect().topLeft())); QApplication::sendEvent(view.viewport(), &helpEvent); - QTest::qWait(1000); + QTRY_COMPARE(QApplication::topLevelWidgets().size(), 1); bool foundView = false; bool foundTipLabel = false; @@ -1011,8 +1010,8 @@ void tst_QGraphicsItem::toolTip() if (widget->inherits("QTipLabel") && widget->isVisible()) foundTipLabel = true; } - QVERIFY(foundView); - QVERIFY(!foundTipLabel); + QTRY_VERIFY(foundView); + QTRY_VERIFY(!foundTipLabel); } } @@ -1506,7 +1505,6 @@ void tst_QGraphicsItem::selected_textItem() QGraphicsView view(&scene); view.show(); QTest::qWaitForWindowShown(&view); - QTest::qWait(20); QTRY_VERIFY(!text->isSelected()); QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, @@ -1546,136 +1544,115 @@ void tst_QGraphicsItem::selected_multi() QVERIFY(!item2->isSelected()); // Start clicking - QTest::qWait(200); // Click on item1 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item1->scenePos())); - QTest::qWait(20); - QVERIFY(item1->isSelected()); - QVERIFY(!item2->isSelected()); + QTRY_VERIFY(item1->isSelected()); + QTRY_VERIFY(!item2->isSelected()); // Click on item2 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item2->scenePos())); - QTest::qWait(20); - QVERIFY(item2->isSelected()); - QVERIFY(!item1->isSelected()); + QTRY_VERIFY(item2->isSelected()); + QTRY_VERIFY(!item1->isSelected()); // Ctrl-click on item1 QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(item1->scenePos())); - QTest::qWait(20); - QVERIFY(item2->isSelected()); - QVERIFY(item1->isSelected()); + QTRY_VERIFY(item2->isSelected()); + QTRY_VERIFY(item1->isSelected()); // Ctrl-click on item1 again QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(item1->scenePos())); - QTest::qWait(20); - QVERIFY(item2->isSelected()); - QVERIFY(!item1->isSelected()); + QTRY_VERIFY(item2->isSelected()); + QTRY_VERIFY(!item1->isSelected()); // Ctrl-click on item2 QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(item2->scenePos())); - QTest::qWait(20); - QVERIFY(!item2->isSelected()); - QVERIFY(!item1->isSelected()); + QTRY_VERIFY(!item2->isSelected()); + QTRY_VERIFY(!item1->isSelected()); // Click on item1 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item1->scenePos())); - QTest::qWait(20); - QVERIFY(item1->isSelected()); - QVERIFY(!item2->isSelected()); + QTRY_VERIFY(item1->isSelected()); + QTRY_VERIFY(!item2->isSelected()); // Click on scene QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(0, 0)); - QTest::qWait(20); - QVERIFY(!item1->isSelected()); - QVERIFY(!item2->isSelected()); + QTRY_VERIFY(!item1->isSelected()); + QTRY_VERIFY(!item2->isSelected()); // Click on item1 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item1->scenePos())); - QTest::qWait(20); - QVERIFY(item1->isSelected()); - QVERIFY(!item2->isSelected()); + QTRY_VERIFY(item1->isSelected()); + QTRY_VERIFY(!item2->isSelected()); // Ctrl-click on scene QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(0, 0)); - QTest::qWait(20); - QVERIFY(!item1->isSelected()); - QVERIFY(!item2->isSelected()); + QTRY_VERIFY(!item1->isSelected()); + QTRY_VERIFY(!item2->isSelected()); // Click on item1 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item1->scenePos())); - QTest::qWait(20); - QVERIFY(item1->isSelected()); - QVERIFY(!item2->isSelected()); + QTRY_VERIFY(item1->isSelected()); + QTRY_VERIFY(!item2->isSelected()); // Press on item2 QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item2->scenePos())); - QTest::qWait(20); - QVERIFY(!item1->isSelected()); - QVERIFY(item2->isSelected()); + QTRY_VERIFY(!item1->isSelected()); + QTRY_VERIFY(item2->isSelected()); // Release on item2 QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item2->scenePos())); - QTest::qWait(20); - QVERIFY(!item1->isSelected()); - QVERIFY(item2->isSelected()); + QTRY_VERIFY(!item1->isSelected()); + QTRY_VERIFY(item2->isSelected()); // Click on item1 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item1->scenePos())); - QTest::qWait(20); - QVERIFY(item1->isSelected()); - QVERIFY(!item2->isSelected()); + QTRY_VERIFY(item1->isSelected()); + QTRY_VERIFY(!item2->isSelected()); // Ctrl-click on item1 QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(item1->scenePos())); - QTest::qWait(20); - QVERIFY(!item1->isSelected()); - QVERIFY(!item2->isSelected()); + QTRY_VERIFY(!item1->isSelected()); + QTRY_VERIFY(!item2->isSelected()); // Ctrl-press on item1 QTest::mousePress(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(item1->scenePos())); - QTest::qWait(20); - QVERIFY(!item1->isSelected()); - QVERIFY(!item2->isSelected()); + QTRY_VERIFY(!item1->isSelected()); + QTRY_VERIFY(!item2->isSelected()); { // Ctrl-move on item1 QMouseEvent event(QEvent::MouseMove, view.mapFromScene(item1->scenePos()) + QPoint(1, 0), Qt::LeftButton, Qt::LeftButton, Qt::ControlModifier); QApplication::sendEvent(view.viewport(), &event); - QTest::qWait(20); - QVERIFY(!item1->isSelected()); - QVERIFY(!item2->isSelected()); + QTRY_VERIFY(!item1->isSelected()); + QTRY_VERIFY(!item2->isSelected()); } // Release on item1 QTest::mouseRelease(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(item1->scenePos())); - QTest::qWait(20); - QVERIFY(item1->isSelected()); - QVERIFY(!item2->isSelected()); + QTRY_VERIFY(item1->isSelected()); + QTRY_VERIFY(!item2->isSelected()); item1->setFlag(QGraphicsItem::ItemIsMovable); item1->setSelected(false); // Ctrl-press on item1 QTest::mousePress(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(item1->scenePos())); - QTest::qWait(20); - QVERIFY(!item1->isSelected()); - QVERIFY(!item2->isSelected()); + QTRY_VERIFY(!item1->isSelected()); + QTRY_VERIFY(!item2->isSelected()); { // Ctrl-move on item1 QMouseEvent event(QEvent::MouseMove, view.mapFromScene(item1->scenePos()) + QPoint(1, 0), Qt::LeftButton, Qt::LeftButton, Qt::ControlModifier); QApplication::sendEvent(view.viewport(), &event); - QTest::qWait(20); - QVERIFY(item1->isSelected()); - QVERIFY(!item2->isSelected()); + QTRY_VERIFY(item1->isSelected()); + QTRY_VERIFY(!item2->isSelected()); } // Release on item1 QTest::mouseRelease(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(item1->scenePos())); - QTest::qWait(20); - QVERIFY(item1->isSelected()); - QVERIFY(!item2->isSelected()); + QTRY_VERIFY(item1->isSelected()); + QTRY_VERIFY(!item2->isSelected()); } void tst_QGraphicsItem::acceptedMouseButtons() @@ -3059,7 +3036,6 @@ void tst_QGraphicsItem::hoverEventsGenerateRepaints() QGraphicsView view(&scene); view.show(); QTest::qWaitForWindowShown(&view); - QTest::qWait(150); EventTester *tester = new EventTester; scene.addItem(tester); @@ -3075,11 +3051,9 @@ void tst_QGraphicsItem::hoverEventsGenerateRepaints() // Check that we get a repaint int npaints = tester->repaints; - qApp->processEvents(); - qApp->processEvents(); - QCOMPARE(tester->events.size(), 2); // enter + move - QCOMPARE(tester->repaints, npaints + 1); - QCOMPARE(tester->events.last(), QEvent::GraphicsSceneHoverMove); + QTRY_COMPARE(tester->events.size(), 2); // enter + move + QTRY_COMPARE(tester->repaints, npaints + 1); + QTRY_COMPARE(tester->events.last(), QEvent::GraphicsSceneHoverMove); // Send a hover move event QGraphicsSceneHoverEvent hoverMoveEvent(QEvent::GraphicsSceneHoverMove); @@ -3088,12 +3062,9 @@ void tst_QGraphicsItem::hoverEventsGenerateRepaints() QApplication::sendEvent(&scene, &hoverMoveEvent); // Check that we don't get a repaint - qApp->processEvents(); - qApp->processEvents(); - - QCOMPARE(tester->events.size(), 3); - QCOMPARE(tester->repaints, npaints + 1); - QCOMPARE(tester->events.last(), QEvent::GraphicsSceneHoverMove); + QTRY_COMPARE(tester->events.size(), 3); + QTRY_COMPARE(tester->repaints, npaints + 1); + QTRY_COMPARE(tester->events.last(), QEvent::GraphicsSceneHoverMove); // Send a hover leave event QGraphicsSceneHoverEvent hoverLeaveEvent(QEvent::GraphicsSceneHoverLeave); @@ -3102,12 +3073,9 @@ void tst_QGraphicsItem::hoverEventsGenerateRepaints() QApplication::sendEvent(&scene, &hoverLeaveEvent); // Check that we get a repaint - qApp->processEvents(); - qApp->processEvents(); - - QCOMPARE(tester->events.size(), 4); - QCOMPARE(tester->repaints, npaints + 2); - QCOMPARE(tester->events.last(), QEvent::GraphicsSceneHoverLeave); + QTRY_COMPARE(tester->events.size(), 4); + QTRY_COMPARE(tester->repaints, npaints + 2); + QTRY_COMPARE(tester->events.last(), QEvent::GraphicsSceneHoverLeave); } void tst_QGraphicsItem::boundingRects_data() @@ -3191,9 +3159,8 @@ void tst_QGraphicsItem::childrenBoundingRect() view.show(); QTest::qWaitForWindowShown(&view); - QTest::qWait(30); - QCOMPARE(parent->childrenBoundingRect(), QRectF(-500, -100, 600, 800)); + QTRY_COMPARE(parent->childrenBoundingRect(), QRectF(-500, -100, 600, 800)); } void tst_QGraphicsItem::childrenBoundingRectTransformed() @@ -3339,8 +3306,6 @@ void tst_QGraphicsItem::group() QCOMPARE(scene.items().size(), 4); QCOMPARE(scene.items(group->sceneBoundingRect()).size(), 3); - QTest::qWait(25); - QRectF parent2SceneBoundingRect = parent2->sceneBoundingRect(); group->addToGroup(parent2); QCOMPARE(parent2->group(), group); @@ -3351,8 +3316,6 @@ void tst_QGraphicsItem::group() QCOMPARE(scene.items().size(), 4); QCOMPARE(scene.items(group->sceneBoundingRect()).size(), 4); - QTest::qWait(25); - QList newItems; for (int i = 0; i < 100; ++i) { QGraphicsItem *item = scene.addRect(QRectF(-25, -25, 50, 50), QPen(Qt::black, 0), @@ -3369,9 +3332,7 @@ void tst_QGraphicsItem::group() int n = 0; foreach (QGraphicsItem *item, newItems) { group->addToGroup(item); - QCOMPARE(item->group(), group); - if ((n++ % 100) == 0) - QTest::qWait(10); + QTRY_COMPARE(item->group(), group); } } @@ -3561,7 +3522,6 @@ void tst_QGraphicsItem::handlesChildEvents() QGraphicsView view(&scene); view.show(); QTest::qWaitForWindowShown(&view); - QTest::qWait(20); // Pull out the items, closest item first QList items = scene.items(scene.itemsBoundingRect()); @@ -3774,7 +3734,6 @@ void tst_QGraphicsItem::filtersChildEvents() QGraphicsView view(&scene); view.show(); QTest::qWaitForWindowShown(&view); - QTest::qWait(20); QGraphicsSceneMouseEvent pressEvent(QEvent::GraphicsSceneMousePress); QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMouseRelease); @@ -3900,7 +3859,6 @@ void tst_QGraphicsItem::ensureVisible() } item->ensureVisible(-100, -100, 25, 25); - QTest::qWait(25); for (int x = -100; x < 100; x += 25) { for (int y = -100; y < 100; y += 25) { @@ -3934,7 +3892,6 @@ void tst_QGraphicsItem::ensureVisible() } item->ensureVisible(100, 100, 25, 25); - QTest::qWait(25); } void tst_QGraphicsItem::cursor() @@ -3975,8 +3932,6 @@ void tst_QGraphicsItem::cursor() view.show(); QTest::mouseMove(&view, view.rect().center()); - QTest::qWait(25); - QCursor cursor = view.viewport()->cursor(); { @@ -3984,9 +3939,7 @@ void tst_QGraphicsItem::cursor() QApplication::sendEvent(view.viewport(), &event); } - QTest::qWait(25); - - QCOMPARE(view.viewport()->cursor().shape(), cursor.shape()); + QTRY_COMPARE(view.viewport()->cursor().shape(), cursor.shape()); { QTest::mouseMove(view.viewport(), view.mapFromScene(item1->sceneBoundingRect().center())); @@ -4001,7 +3954,7 @@ void tst_QGraphicsItem::cursor() return; #endif - QCOMPARE(view.viewport()->cursor().shape(), item1->cursor().shape()); + QTRY_COMPARE(view.viewport()->cursor().shape(), item1->cursor().shape()); { QTest::mouseMove(view.viewport(), view.mapFromScene(item2->sceneBoundingRect().center())); @@ -4009,9 +3962,7 @@ void tst_QGraphicsItem::cursor() QApplication::sendEvent(view.viewport(), &event); } - QTest::qWait(25); - - QCOMPARE(view.viewport()->cursor().shape(), item2->cursor().shape()); + QTRY_COMPARE(view.viewport()->cursor().shape(), item2->cursor().shape()); { QTest::mouseMove(view.viewport(), view.rect().center()); @@ -4019,9 +3970,7 @@ void tst_QGraphicsItem::cursor() QApplication::sendEvent(view.viewport(), &event); } - QTest::qWait(25); - - QCOMPARE(view.viewport()->cursor().shape(), cursor.shape()); + QTRY_COMPARE(view.viewport()->cursor().shape(), cursor.shape()); #endif } /* @@ -4685,7 +4634,6 @@ void tst_QGraphicsItem::sceneEventFilter() view.show(); QApplication::setActiveWindow(&view); QTest::qWaitForWindowShown(&view); - QTest::qWait(25); QGraphicsTextItem *text1 = scene.addText(QLatin1String("Text1")); QGraphicsTextItem *text2 = scene.addText(QLatin1String("Text2")); @@ -4749,7 +4697,6 @@ void tst_QGraphicsItem::sceneEventFilter() gv.setScene(anotherScene); gv.show(); QTest::qWaitForWindowShown(&gv); - QTest::qWait(25); ti->installSceneEventFilter(ti2); ti3->installSceneEventFilter(ti); delete ti2; @@ -4820,30 +4767,25 @@ void tst_QGraphicsItem::paint() QGraphicsView view2(&scene2); view2.show(); QTest::qWaitForWindowShown(&view2); - QTest::qWait(25); PaintTester tester2; scene2.addItem(&tester2); - qApp->processEvents(); //First show one paint QTRY_COMPARE(tester2.painted, 1); //nominal case, update call paint tester2.update(); - qApp->processEvents(); QTRY_VERIFY(tester2.painted == 2); //we remove the item from the scene, number of updates is still the same tester2.update(); scene2.removeItem(&tester2); - qApp->processEvents(); QTRY_VERIFY(tester2.painted == 2); //We re-add the item, the number of paint should increase scene2.addItem(&tester2); tester2.update(); - qApp->processEvents(); QTRY_VERIFY(tester2.painted == 3); } @@ -5237,7 +5179,6 @@ void tst_QGraphicsItem::itemClipsChildrenToShape2() #else QGraphicsView view(&scene); view.show(); - QTest::qWait(5000); #endif } @@ -5647,29 +5588,29 @@ void tst_QGraphicsItem::untransformable() for (int i = 0; i < 10; ++i) { QPoint center = view.viewport()->rect().center(); - QCOMPARE(view.itemAt(center), item1); - QCOMPARE(view.itemAt(center - QPoint(40, 0)), item1); - QCOMPARE(view.itemAt(center - QPoint(-40, 0)), item1); - QCOMPARE(view.itemAt(center - QPoint(0, 40)), item1); - QCOMPARE(view.itemAt(center - QPoint(0, -40)), item1); + QTRY_COMPARE(view.itemAt(center), item1); + QTRY_COMPARE(view.itemAt(center - QPoint(40, 0)), item1); + QTRY_COMPARE(view.itemAt(center - QPoint(-40, 0)), item1); + QTRY_COMPARE(view.itemAt(center - QPoint(0, 40)), item1); + QTRY_COMPARE(view.itemAt(center - QPoint(0, -40)), item1); center += QPoint(70, 70); - QCOMPARE(view.itemAt(center - QPoint(40, 0)), item2); - QCOMPARE(view.itemAt(center - QPoint(-40, 0)), item2); - QCOMPARE(view.itemAt(center - QPoint(0, 40)), item2); - QCOMPARE(view.itemAt(center - QPoint(0, -40)), item2); + QTRY_COMPARE(view.itemAt(center - QPoint(40, 0)), item2); + QTRY_COMPARE(view.itemAt(center - QPoint(-40, 0)), item2); + QTRY_COMPARE(view.itemAt(center - QPoint(0, 40)), item2); + QTRY_COMPARE(view.itemAt(center - QPoint(0, -40)), item2); center += QPoint(0, 100); - QCOMPARE(view.itemAt(center - QPoint(40, 0)), item3); - QCOMPARE(view.itemAt(center - QPoint(-40, 0)), item3); - QCOMPARE(view.itemAt(center - QPoint(0, 40)), item3); - QCOMPARE(view.itemAt(center - QPoint(0, -40)), item3); + QTRY_COMPARE(view.itemAt(center - QPoint(40, 0)), item3); + QTRY_COMPARE(view.itemAt(center - QPoint(-40, 0)), item3); + QTRY_COMPARE(view.itemAt(center - QPoint(0, 40)), item3); + QTRY_COMPARE(view.itemAt(center - QPoint(0, -40)), item3); view.scale(0.5, 0.5); view.rotate(13); view.shear(qreal(0.01), qreal(0.01)); view.translate(10, 10); - QTest::qWait(25); + qApp->processEvents(); } } @@ -5707,7 +5648,6 @@ void tst_QGraphicsItem::contextMenuEventPropagation() view.show(); view.resize(200, 200); QTest::qWaitForWindowShown(&view); - QTest::qWait(20); QContextMenuEvent event(QContextMenuEvent::Mouse, QPoint(10, 10), view.viewport()->mapToGlobal(QPoint(10, 10))); @@ -5814,8 +5754,6 @@ void tst_QGraphicsItem::task141694_textItemEnsureVisible() int hscroll = view.horizontalScrollBar()->value(); int vscroll = view.verticalScrollBar()->value(); - QTest::qWait(10); - // This should not cause the view to scroll QTRY_COMPARE(view.horizontalScrollBar()->value(), hscroll); QCOMPARE(view.verticalScrollBar()->value(), vscroll); @@ -5983,7 +5921,6 @@ void tst_QGraphicsItem::ensureUpdateOnTextItem() QGraphicsView view(&scene); view.show(); QTest::qWaitForWindowShown(&view); - QTest::qWait(25); TextItem *text1 = new TextItem(QLatin1String("123")); scene.addItem(text1); qApp->processEvents(); @@ -6285,7 +6222,6 @@ void tst_QGraphicsItem::opacity2() RESET_REPAINT_COUNTERS child->setOpacity(0.0); - QTest::qWait(10); QTRY_COMPARE(view.repaints, 1); QCOMPARE(parent->repaints, 1); QCOMPARE(child->repaints, 0); @@ -6294,7 +6230,6 @@ void tst_QGraphicsItem::opacity2() RESET_REPAINT_COUNTERS child->setOpacity(1.0); - QTest::qWait(10); QTRY_COMPARE(view.repaints, 1); QCOMPARE(parent->repaints, 1); QCOMPARE(child->repaints, 1); @@ -6303,7 +6238,6 @@ void tst_QGraphicsItem::opacity2() RESET_REPAINT_COUNTERS parent->setOpacity(0.0); - QTest::qWait(10); QTRY_COMPARE(view.repaints, 1); QCOMPARE(parent->repaints, 0); QCOMPARE(child->repaints, 0); @@ -6312,7 +6246,6 @@ void tst_QGraphicsItem::opacity2() RESET_REPAINT_COUNTERS parent->setOpacity(1.0); - QTest::qWait(10); QTRY_COMPARE(view.repaints, 1); QCOMPARE(parent->repaints, 1); QCOMPARE(child->repaints, 1); @@ -6322,7 +6255,6 @@ void tst_QGraphicsItem::opacity2() RESET_REPAINT_COUNTERS child->setOpacity(0.0); - QTest::qWait(10); QTRY_COMPARE(view.repaints, 1); QCOMPARE(parent->repaints, 1); QCOMPARE(child->repaints, 0); @@ -6331,7 +6263,6 @@ void tst_QGraphicsItem::opacity2() RESET_REPAINT_COUNTERS child->setOpacity(0.0); // Already 0.0; no change. - QTest::qWait(10); QTRY_COMPARE(view.repaints, 0); QCOMPARE(parent->repaints, 0); QCOMPARE(child->repaints, 0); @@ -6356,8 +6287,6 @@ void tst_QGraphicsItem::opacityZeroUpdates() view.reset(); parent->setOpacity(0.0); - QTest::qWait(20); - // transforming items bounding rect to view coordinates const QRect childDeviceBoundingRect = child->deviceTransform(view.viewportTransform()) .mapRect(child->boundingRect()).toRect(); @@ -6425,7 +6354,6 @@ void tst_QGraphicsItem::itemStacksBehindParent() view.show(); QTest::qWaitForWindowShown(&view); QTRY_VERIFY(!paintedItems.isEmpty()); - QTest::qWait(100); paintedItems.clear(); view.viewport()->update(); QApplication::processEvents(); @@ -6522,7 +6450,6 @@ void tst_QGraphicsItem::nestedClipping() view.setOptimizationFlag(QGraphicsView::IndirectPainting); view.show(); QTest::qWaitForWindowShown(&view); - QTest::qWait(25); QList expected; expected << root << l1 << l2 << l3; @@ -6710,16 +6637,13 @@ void tst_QGraphicsItem::tabChangesFocus() QTRY_VERIFY(scene.isActive()); dial1->setFocus(); - QTest::qWait(15); QTRY_VERIFY(dial1->hasFocus()); QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); - QTest::qWait(15); QTRY_VERIFY(view->hasFocus()); QTRY_VERIFY(item->hasFocus()); QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); - QTest::qWait(15); if (tabChangesFocus) { QTRY_VERIFY(!view->hasFocus()); @@ -6753,24 +6677,21 @@ void tst_QGraphicsItem::cacheMode() testerChild2->setFlag(QGraphicsItem::ItemIgnoresTransformations); scene.addItem(tester); - QTest::qWait(10); for (int i = 0; i < 2; ++i) { // No visual change. QTRY_COMPARE(tester->repaints, 1); - QCOMPARE(testerChild->repaints, 1); - QCOMPARE(testerChild2->repaints, 1); + QTRY_COMPARE(testerChild->repaints, 1); + QTRY_COMPARE(testerChild2->repaints, 1); tester->setCacheMode(QGraphicsItem::NoCache); testerChild->setCacheMode(QGraphicsItem::NoCache); testerChild2->setCacheMode(QGraphicsItem::NoCache); - QTest::qWait(25); QTRY_COMPARE(tester->repaints, 1); - QCOMPARE(testerChild->repaints, 1); - QCOMPARE(testerChild2->repaints, 1); + QTRY_COMPARE(testerChild->repaints, 1); + QTRY_COMPARE(testerChild2->repaints, 1); tester->setCacheMode(QGraphicsItem::DeviceCoordinateCache); testerChild->setCacheMode(QGraphicsItem::DeviceCoordinateCache); testerChild2->setCacheMode(QGraphicsItem::DeviceCoordinateCache); - QTest::qWait(25); } // The first move causes a repaint as the item is painted into its pixmap. @@ -6778,151 +6699,131 @@ void tst_QGraphicsItem::cacheMode() tester->setPos(10, 10); testerChild->setPos(10, 10); testerChild2->setPos(10, 10); - QTest::qWait(25); QTRY_COMPARE(tester->repaints, 2); - QCOMPARE(testerChild->repaints, 2); - QCOMPARE(testerChild2->repaints, 2); + QTRY_COMPARE(testerChild->repaints, 2); + QTRY_COMPARE(testerChild2->repaints, 2); // Consecutive moves should not repaint. tester->setPos(20, 20); testerChild->setPos(20, 20); testerChild2->setPos(20, 20); - QTest::qWait(250); - QCOMPARE(tester->repaints, 2); - QCOMPARE(testerChild->repaints, 2); - QCOMPARE(testerChild2->repaints, 2); + QTRY_COMPARE(tester->repaints, 2); + QTRY_COMPARE(testerChild->repaints, 2); + QTRY_COMPARE(testerChild2->repaints, 2); // Translating does not result in a repaint. tester->translate(10, 10); - QTest::qWait(25); QTRY_COMPARE(tester->repaints, 2); - QCOMPARE(testerChild->repaints, 2); - QCOMPARE(testerChild2->repaints, 2); + QTRY_COMPARE(testerChild->repaints, 2); + QTRY_COMPARE(testerChild2->repaints, 2); // Rotating results in a repaint. tester->rotate(45); - QTest::qWait(25); QTRY_COMPARE(tester->repaints, 3); - QCOMPARE(testerChild->repaints, 3); - QCOMPARE(testerChild2->repaints, 2); + QTRY_COMPARE(testerChild->repaints, 3); + QTRY_COMPARE(testerChild2->repaints, 2); // Change to ItemCoordinateCache (triggers repaint). tester->setCacheMode(QGraphicsItem::ItemCoordinateCache); // autosize testerChild->setCacheMode(QGraphicsItem::ItemCoordinateCache); // autosize testerChild2->setCacheMode(QGraphicsItem::ItemCoordinateCache); // autosize - QTest::qWait(25); QTRY_COMPARE(tester->repaints, 4); - QCOMPARE(testerChild->repaints, 4); - QCOMPARE(testerChild2->repaints, 3); + QTRY_COMPARE(testerChild->repaints, 4); + QTRY_COMPARE(testerChild2->repaints, 3); // Rotating items with ItemCoordinateCache doesn't cause a repaint. tester->rotate(22); testerChild->rotate(22); testerChild2->rotate(22); - QTest::qWait(25); QTRY_COMPARE(tester->repaints, 4); - QCOMPARE(testerChild->repaints, 4); - QCOMPARE(testerChild2->repaints, 3); + QTRY_COMPARE(testerChild->repaints, 4); + QTRY_COMPARE(testerChild2->repaints, 3); // Explicit update causes a repaint. tester->update(0, 0, 5, 5); - QTest::qWait(25); QTRY_COMPARE(tester->repaints, 5); - QCOMPARE(testerChild->repaints, 4); - QCOMPARE(testerChild2->repaints, 3); + QTRY_COMPARE(testerChild->repaints, 4); + QTRY_COMPARE(testerChild2->repaints, 3); // Updating outside the item's bounds does not cause a repaint. tester->update(10, 10, 5, 5); - QTest::qWait(25); QTRY_COMPARE(tester->repaints, 5); - QCOMPARE(testerChild->repaints, 4); - QCOMPARE(testerChild2->repaints, 3); + QTRY_COMPARE(testerChild->repaints, 4); + QTRY_COMPARE(testerChild2->repaints, 3); // Resizing an item should cause a repaint of that item. (because of // autosize). tester->setGeometry(QRectF(-15, -15, 30, 30)); - QTest::qWait(25); QTRY_COMPARE(tester->repaints, 6); - QCOMPARE(testerChild->repaints, 4); - QCOMPARE(testerChild2->repaints, 3); + QTRY_COMPARE(testerChild->repaints, 4); + QTRY_COMPARE(testerChild2->repaints, 3); // Set fixed size. tester->setCacheMode(QGraphicsItem::ItemCoordinateCache, QSize(30, 30)); testerChild->setCacheMode(QGraphicsItem::ItemCoordinateCache, QSize(30, 30)); testerChild2->setCacheMode(QGraphicsItem::ItemCoordinateCache, QSize(30, 30)); - QTest::qWait(20); QTRY_COMPARE(tester->repaints, 7); - QCOMPARE(testerChild->repaints, 5); - QCOMPARE(testerChild2->repaints, 4); + QTRY_COMPARE(testerChild->repaints, 5); + QTRY_COMPARE(testerChild2->repaints, 4); // Resizing the item should cause a repaint. testerChild->setGeometry(QRectF(-15, -15, 30, 30)); - QTest::qWait(25); QTRY_COMPARE(tester->repaints, 7); - QCOMPARE(testerChild->repaints, 6); - QCOMPARE(testerChild2->repaints, 4); + QTRY_COMPARE(testerChild->repaints, 6); + QTRY_COMPARE(testerChild2->repaints, 4); // Scaling the view does not cause a repaint. view.scale(0.7, 0.7); - QTest::qWait(25); QTRY_COMPARE(tester->repaints, 7); - QCOMPARE(testerChild->repaints, 6); - QCOMPARE(testerChild2->repaints, 4); + QTRY_COMPARE(testerChild->repaints, 6); + QTRY_COMPARE(testerChild2->repaints, 4); // Switch to device coordinate cache. tester->setCacheMode(QGraphicsItem::DeviceCoordinateCache); testerChild->setCacheMode(QGraphicsItem::DeviceCoordinateCache); testerChild2->setCacheMode(QGraphicsItem::DeviceCoordinateCache); - QTest::qWait(25); QTRY_COMPARE(tester->repaints, 8); - QCOMPARE(testerChild->repaints, 7); - QCOMPARE(testerChild2->repaints, 5); + QTRY_COMPARE(testerChild->repaints, 7); + QTRY_COMPARE(testerChild2->repaints, 5); // Scaling the view back should cause repaints for two of the items. view.setTransform(QTransform()); - QTest::qWait(25); QTRY_COMPARE(tester->repaints, 9); - QCOMPARE(testerChild->repaints, 8); - QCOMPARE(testerChild2->repaints, 5); + QTRY_COMPARE(testerChild->repaints, 8); + QTRY_COMPARE(testerChild2->repaints, 5); // Rotating the base item (perspective) should repaint two items. tester->setTransform(QTransform().rotate(10, Qt::XAxis)); - QTest::qWait(25); QTRY_COMPARE(tester->repaints, 10); - QCOMPARE(testerChild->repaints, 9); - QCOMPARE(testerChild2->repaints, 5); + QTRY_COMPARE(testerChild->repaints, 9); + QTRY_COMPARE(testerChild2->repaints, 5); // Moving the middle item should case a repaint even if it's a move, // because the parent is rotated with a perspective. testerChild->setPos(1, 1); - QTest::qWait(25); QTRY_COMPARE(tester->repaints, 10); - QCOMPARE(testerChild->repaints, 10); - QCOMPARE(testerChild2->repaints, 5); + QTRY_COMPARE(testerChild->repaints, 10); + QTRY_COMPARE(testerChild2->repaints, 5); // Make a huge item tester->setGeometry(QRectF(-4000, -4000, 8000, 8000)); - QTest::qWait(25); QTRY_COMPARE(tester->repaints, 11); - QCOMPARE(testerChild->repaints, 10); - QCOMPARE(testerChild2->repaints, 5); + QTRY_COMPARE(testerChild->repaints, 10); + QTRY_COMPARE(testerChild2->repaints, 5); // Move the large item - will cause a repaint as the // cache is clipped. tester->setPos(5, 0); - QTest::qWait(25); QTRY_COMPARE(tester->repaints, 12); - QCOMPARE(testerChild->repaints, 10); - QCOMPARE(testerChild2->repaints, 5); + QTRY_COMPARE(testerChild->repaints, 10); + QTRY_COMPARE(testerChild2->repaints, 5); // Hiding and showing should invalidate the cache tester->hide(); - QTest::qWait(25); tester->show(); - QTest::qWait(25); QTRY_COMPARE(tester->repaints, 13); - QCOMPARE(testerChild->repaints, 11); - QCOMPARE(testerChild2->repaints, 6); + QTRY_COMPARE(testerChild->repaints, 11); + QTRY_COMPARE(testerChild2->repaints, 6); } void tst_QGraphicsItem::updateCachedItemAfterMove() @@ -6939,31 +6840,26 @@ void tst_QGraphicsItem::updateCachedItemAfterMove() view.show(); QTest::qWaitForWindowShown(&view); - QTest::qWait(12); QTRY_VERIFY(tester->repaints > 0); tester->repaints = 0; // Move the item, should not cause repaints tester->setPos(10, 0); - QTest::qWait(12); - QCOMPARE(tester->repaints, 0); + QTRY_COMPARE(tester->repaints, 0); // Move then update, should cause one repaint tester->setPos(20, 0); tester->update(); - QTest::qWait(12); - QCOMPARE(tester->repaints, 1); + QTRY_COMPARE(tester->repaints, 1); // Hiding the item doesn't cause a repaint tester->hide(); - QTest::qWait(12); - QCOMPARE(tester->repaints, 1); + QTRY_COMPARE(tester->repaints, 1); // Moving a hidden item doesn't cause a repaint tester->setPos(30, 0); tester->update(); - QTest::qWait(12); - QCOMPARE(tester->repaints, 1); + QTRY_COMPARE(tester->repaints, 1); } class Track : public QGraphicsRectItem @@ -7084,7 +6980,6 @@ void tst_QGraphicsItem::update() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&view); #endif - QTest::qWait(100); EventTester *item = new EventTester; scene.addItem(item); @@ -7093,23 +6988,20 @@ void tst_QGraphicsItem::update() item->update(); // Item marked as dirty scene.update(); // Entire scene marked as dirty - qApp->processEvents(); - QCOMPARE(item->repaints, 1); + QTRY_COMPARE(item->repaints, 1); // Make sure the dirty state from the previous update is reset so that // the item don't think it is already dirty and discards this update. item->update(); - qApp->processEvents(); - QCOMPARE(item->repaints, 2); + QTRY_COMPARE(item->repaints, 2); // Make sure a partial update doesn't cause a full update to be discarded. view.reset(); item->repaints = 0; item->update(QRectF(0, 0, 5, 5)); item->update(); - qApp->processEvents(); - QCOMPARE(item->repaints, 1); - QCOMPARE(view.repaints, 1); + QTRY_COMPARE(item->repaints, 1); + QTRY_COMPARE(view.repaints, 1); QRect itemDeviceBoundingRect = item->deviceTransform(view.viewportTransform()) .mapRect(item->boundingRect()).toRect(); QRegion expectedRegion = itemDeviceBoundingRect.adjusted(-2, -2, 2, 2); @@ -7120,65 +7012,55 @@ void tst_QGraphicsItem::update() view.reset(); item->repaints = 0; item->update(-15, -15, 5, 5); // Item's brect: (-10, -10, 20, 20) - qApp->processEvents(); - QCOMPARE(item->repaints, 0); - QCOMPARE(view.repaints, 0); + QTRY_COMPARE(item->repaints, 0); + QTRY_COMPARE(view.repaints, 0); // Make sure the area occupied by an item is repainted when hiding it. view.reset(); item->repaints = 0; item->update(); // Full update; all sub-sequent update requests are discarded. item->hide(); // visible set to 0. ignoreVisible must be set to 1; the item won't be processed otherwise. - qApp->processEvents(); - QCOMPARE(item->repaints, 0); - QCOMPARE(view.repaints, 1); + QTRY_COMPARE(item->repaints, 0); + QTRY_COMPARE(view.repaints, 1); // The entire item's bounding rect (adjusted for antialiasing) should have been painted. - QCOMPARE(view.paintedRegion, expectedRegion); + QTRY_COMPARE(view.paintedRegion, expectedRegion); // Make sure item is repainted when shown (after being hidden). view.reset(); item->repaints = 0; item->show(); - qApp->processEvents(); - QCOMPARE(item->repaints, 1); - QCOMPARE(view.repaints, 1); + QTRY_COMPARE(item->repaints, 1); + QTRY_COMPARE(view.repaints, 1); // The entire item's bounding rect (adjusted for antialiasing) should have been painted. - QCOMPARE(view.paintedRegion, expectedRegion); + QTRY_COMPARE(view.paintedRegion, expectedRegion); item->repaints = 0; item->hide(); - qApp->processEvents(); view.reset(); const QPointF originalPos = item->pos(); item->setPos(5000, 5000); - qApp->processEvents(); - QCOMPARE(item->repaints, 0); - QCOMPARE(view.repaints, 0); - qApp->processEvents(); + QTRY_COMPARE(item->repaints, 0); + QTRY_COMPARE(view.repaints, 0); item->setPos(originalPos); - qApp->processEvents(); - QCOMPARE(item->repaints, 0); - QCOMPARE(view.repaints, 0); + QTRY_COMPARE(item->repaints, 0); + QTRY_COMPARE(view.repaints, 0); item->show(); - qApp->processEvents(); - QCOMPARE(item->repaints, 1); - QCOMPARE(view.repaints, 1); + QTRY_COMPARE(item->repaints, 1); + QTRY_COMPARE(view.repaints, 1); // The entire item's bounding rect (adjusted for antialiasing) should have been painted. QCOMPARE(view.paintedRegion, expectedRegion); QGraphicsViewPrivate *viewPrivate = static_cast(qt_widget_private(&view)); item->setPos(originalPos + QPoint(50, 50)); viewPrivate->updateAll(); - QVERIFY(viewPrivate->fullUpdatePending); - QTest::qWait(50); + QVERIFY(viewPrivate->fullUpdatePending); // test to ensure object will be updated + QTRY_VERIFY(!(viewPrivate->fullUpdatePending)); // test to ensure object has been updated item->repaints = 0; view.reset(); item->setPos(originalPos); - QTest::qWait(50); - qApp->processEvents(); - QCOMPARE(item->repaints, 1); - QCOMPARE(view.repaints, 1); + QTRY_COMPARE(item->repaints, 1); + QTRY_COMPARE(view.repaints, 1); COMPARE_REGIONS(view.paintedRegion, expectedRegion + expectedRegion.translated(50, 50)); // Make sure moving a parent item triggers an update on the children @@ -7195,18 +7077,16 @@ void tst_QGraphicsItem::update() view.reset(); item->repaints = 0; parent->translate(-400, 0); - qApp->processEvents(); - QCOMPARE(item->repaints, 0); - QCOMPARE(view.repaints, 1); - QCOMPARE(view.paintedRegion, expectedRegion); + QTRY_COMPARE(item->repaints, 0); + QTRY_COMPARE(view.repaints, 1); + QTRY_COMPARE(view.paintedRegion, expectedRegion); view.reset(); item->repaints = 0; parent->translate(400, 0); - qApp->processEvents(); - QCOMPARE(item->repaints, 1); - QCOMPARE(view.repaints, 1); - QCOMPARE(view.paintedRegion, expectedRegion); - QCOMPARE(view.paintedRegion, expectedRegion); + QTRY_COMPARE(item->repaints, 1); + QTRY_COMPARE(view.repaints, 1); + QTRY_COMPARE(view.paintedRegion, expectedRegion); + QTRY_COMPARE(view.paintedRegion, expectedRegion); } void tst_QGraphicsItem::setTransformProperties_data() @@ -7363,17 +7243,13 @@ void tst_QGraphicsItem::itemUsesExtendedStyleOption() rect->startTrack = false; view.show(); QTest::qWaitForWindowShown(&view); - QTest::qWait(60); rect->startTrack = true; rect->update(10, 10, 10, 10); - QTest::qWait(60); rect->startTrack = false; rect->setFlag(QGraphicsItem::ItemUsesExtendedStyleOption, true); - QVERIFY((rect->flags() & QGraphicsItem::ItemUsesExtendedStyleOption)); - QTest::qWait(60); + QTRY_VERIFY((rect->flags() & QGraphicsItem::ItemUsesExtendedStyleOption)); rect->startTrack = true; rect->update(10, 10, 10, 10); - QTest::qWait(60); } void tst_QGraphicsItem::itemSendsGeometryChanges() @@ -7425,7 +7301,6 @@ void tst_QGraphicsItem::moveItem() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&view); #endif - QTest::qWait(100); EventTester *parent = new EventTester; EventTester *child = new EventTester(parent); @@ -7448,9 +7323,8 @@ void tst_QGraphicsItem::moveItem() .adjusted(-2, -2, 2, 2); // Adjusted for antialiasing. parent->setPos(20, 20); - qApp->processEvents(); - QCOMPARE(parent->repaints, 1); - QCOMPARE(view.repaints, 1); + QTRY_COMPARE(parent->repaints, 1); + QTRY_COMPARE(view.repaints, 1); QRegion expectedParentRegion = parentDeviceBoundingRect; // old position parentDeviceBoundingRect.translate(20, 20); expectedParentRegion += parentDeviceBoundingRect; // new position @@ -7459,32 +7333,29 @@ void tst_QGraphicsItem::moveItem() RESET_COUNTERS child->setPos(20, 20); - qApp->processEvents(); - QCOMPARE(parent->repaints, 1); - QCOMPARE(child->repaints, 1); - QCOMPARE(view.repaints, 1); + QTRY_COMPARE(parent->repaints, 1); + QTRY_COMPARE(child->repaints, 1); + QTRY_COMPARE(view.repaints, 1); const QRegion expectedChildRegion = expectedParentRegion.translated(20, 20); COMPARE_REGIONS(view.paintedRegion, expectedChildRegion); RESET_COUNTERS grandChild->setPos(20, 20); - qApp->processEvents(); - QCOMPARE(parent->repaints, 1); - QCOMPARE(child->repaints, 1); - QCOMPARE(grandChild->repaints, 1); - QCOMPARE(view.repaints, 1); + QTRY_COMPARE(parent->repaints, 1); + QTRY_COMPARE(child->repaints, 1); + QTRY_COMPARE(grandChild->repaints, 1); + QTRY_COMPARE(view.repaints, 1); const QRegion expectedGrandChildRegion = expectedParentRegion.translated(40, 40); COMPARE_REGIONS(view.paintedRegion, expectedGrandChildRegion); RESET_COUNTERS parent->translate(20, 20); - qApp->processEvents(); - QCOMPARE(parent->repaints, 1); - QCOMPARE(child->repaints, 1); - QCOMPARE(grandChild->repaints, 1); - QCOMPARE(view.repaints, 1); + QTRY_COMPARE(parent->repaints, 1); + QTRY_COMPARE(child->repaints, 1); + QTRY_COMPARE(grandChild->repaints, 1); + QTRY_COMPARE(view.repaints, 1); expectedParentRegion.translate(20, 20); expectedParentRegion += expectedChildRegion.translated(20, 20); expectedParentRegion += expectedGrandChildRegion.translated(20, 20); @@ -7504,7 +7375,6 @@ void tst_QGraphicsItem::moveLineItem() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&view); #endif - QTest::qWait(200); view.reset(); const QRect itemDeviceBoundingRect = item->deviceTransform(view.viewportTransform()) @@ -7513,15 +7383,13 @@ void tst_QGraphicsItem::moveLineItem() // Make sure the calculated region is correct. item->update(); - QTest::qWait(10); QTRY_COMPARE(view.paintedRegion, expectedRegion); view.reset(); // Old position: (50, 50) item->setPos(50, 100); expectedRegion += expectedRegion.translated(0, 50); - QTest::qWait(10); - QCOMPARE(view.paintedRegion, expectedRegion); + QTRY_COMPARE(view.paintedRegion, expectedRegion); } void tst_QGraphicsItem::sorting_data() @@ -7564,7 +7432,6 @@ void tst_QGraphicsItem::sorting() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&view); #endif - QTest::qWait(100); _paintedItems.clear(); @@ -7623,7 +7490,6 @@ void tst_QGraphicsItem::hitTestUntransformableItem() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&view); #endif - QTest::qWait(100); // Confuse the BSP with dummy items. QGraphicsRectItem *dummy = new QGraphicsRectItem(0, 0, 20, 20); @@ -7649,18 +7515,16 @@ void tst_QGraphicsItem::hitTestUntransformableItem() item3->setPos(80, 80); scene.addItem(item1); - QTest::qWait(100); QList items = scene.items(QPointF(80, 80)); - QCOMPARE(items.size(), 1); - QCOMPARE(items.at(0), static_cast(item3)); + QTRY_COMPARE(items.size(), 1); + QTRY_COMPARE(items.at(0), static_cast(item3)); scene.setItemIndexMethod(QGraphicsScene::NoIndex); - QTest::qWait(100); items = scene.items(QPointF(80, 80)); - QCOMPARE(items.size(), 1); - QCOMPARE(items.at(0), static_cast(item3)); + QTRY_COMPARE(items.size(), 1); + QTRY_COMPARE(items.at(0), static_cast(item3)); } void tst_QGraphicsItem::hitTestGraphicsEffectItem() @@ -7673,7 +7537,6 @@ void tst_QGraphicsItem::hitTestGraphicsEffectItem() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&view); #endif - QTest::qWait(100); // Confuse the BSP with dummy items. QGraphicsRectItem *dummy = new QGraphicsRectItem(0, 0, 20, 20); @@ -7706,7 +7569,6 @@ void tst_QGraphicsItem::hitTestGraphicsEffectItem() item3->brush = Qt::blue; scene.addItem(item1); - QTest::qWait(100); item1->repaints = 0; item2->repaints = 0; @@ -7716,28 +7578,26 @@ void tst_QGraphicsItem::hitTestGraphicsEffectItem() QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect; shadow->setOffset(-20, -20); item1->setGraphicsEffect(shadow); - QTest::qWait(50); // Make sure all visible items are repainted. - QCOMPARE(item1->repaints, 0); - QCOMPARE(item2->repaints, 1); - QCOMPARE(item3->repaints, 1); + QTRY_COMPARE(item1->repaints, 0); + QTRY_COMPARE(item2->repaints, 1); + QTRY_COMPARE(item3->repaints, 1); // Make sure an item doesn't respond to a click on its shadow. QList items = scene.items(QPointF(75, 75)); - QVERIFY(items.isEmpty()); + QTRY_VERIFY(items.isEmpty()); items = scene.items(QPointF(80, 80)); - QCOMPARE(items.size(), 1); - QCOMPARE(items.at(0), static_cast(item3)); + QTRY_COMPARE(items.size(), 1); + QTRY_COMPARE(items.at(0), static_cast(item3)); scene.setItemIndexMethod(QGraphicsScene::NoIndex); - QTest::qWait(100); items = scene.items(QPointF(75, 75)); - QVERIFY(items.isEmpty()); + QTRY_VERIFY(items.isEmpty()); items = scene.items(QPointF(80, 80)); - QCOMPARE(items.size(), 1); - QCOMPARE(items.at(0), static_cast(item3)); + QTRY_COMPARE(items.size(), 1); + QTRY_COMPARE(items.at(0), static_cast(item3)); } void tst_QGraphicsItem::focusProxy() @@ -8396,7 +8256,6 @@ void tst_QGraphicsItem::moveWhileDeleting() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&view); #endif - QTest::qWait(125); delete rect; @@ -8405,8 +8264,6 @@ void tst_QGraphicsItem::moveWhileDeleting() silly = new MoveWhileDying(rect); child = new QGraphicsRectItem(silly); - QTest::qWait(125); - delete rect; rect = new MoveWhileDying; @@ -8414,8 +8271,6 @@ void tst_QGraphicsItem::moveWhileDeleting() child = new QGraphicsRectItem(rect); silly = new MoveWhileDying(child); - QTest::qWait(125); - delete rect; } -- cgit v0.12 From b38c650407e4e89c4394129540aa0a0e81398763 Mon Sep 17 00:00:00 2001 From: Toby Tomkins Date: Thu, 1 Apr 2010 17:50:53 +1000 Subject: Partially revert "Remove qWait functions as it is used in QTRY_* macros." Needs investigation of autotest failures on QWS, osx, win platforms. This reverts commit 741b75b8e595a26944ba8fca8835463787b02676. Conflicts: tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp --- tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 486 ++++++++++++++++--------- 1 file changed, 314 insertions(+), 172 deletions(-) diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index f81a520..7fdd9c9 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -962,11 +962,12 @@ void tst_QGraphicsItem::toolTip() QGraphicsView view(&scene); view.setFixedSize(200, 200); view.show(); + QTest::qWait(250); { QHelpEvent helpEvent(QEvent::ToolTip, view.viewport()->rect().topLeft(), view.viewport()->mapToGlobal(view.viewport()->rect().topLeft())); QApplication::sendEvent(view.viewport(), &helpEvent); - QTRY_COMPARE(QApplication::topLevelWidgets().size(), 1); + QTest::qWait(250); bool foundView = false; bool foundTipLabel = false; @@ -976,15 +977,15 @@ void tst_QGraphicsItem::toolTip() if (widget->inherits("QTipLabel")) foundTipLabel = true; } - QTRY_VERIFY(foundView); - QTRY_VERIFY(!foundTipLabel); + QVERIFY(foundView); + QVERIFY(!foundTipLabel); } { QHelpEvent helpEvent(QEvent::ToolTip, view.viewport()->rect().center(), view.viewport()->mapToGlobal(view.viewport()->rect().center())); QApplication::sendEvent(view.viewport(), &helpEvent); - QTRY_COMPARE(QApplication::topLevelWidgets().size(), 2); + QTest::qWait(250); bool foundView = false; bool foundTipLabel = false; @@ -994,15 +995,15 @@ void tst_QGraphicsItem::toolTip() if (widget->inherits("QTipLabel")) foundTipLabel = true; } - QTRY_VERIFY(foundView); - QTRY_VERIFY(foundTipLabel); + QVERIFY(foundView); + QVERIFY(foundTipLabel); } { QHelpEvent helpEvent(QEvent::ToolTip, view.viewport()->rect().topLeft(), view.viewport()->mapToGlobal(view.viewport()->rect().topLeft())); QApplication::sendEvent(view.viewport(), &helpEvent); - QTRY_COMPARE(QApplication::topLevelWidgets().size(), 1); + QTest::qWait(1000); bool foundView = false; bool foundTipLabel = false; @@ -1012,8 +1013,8 @@ void tst_QGraphicsItem::toolTip() if (widget->inherits("QTipLabel") && widget->isVisible()) foundTipLabel = true; } - QTRY_VERIFY(foundView); - QTRY_VERIFY(!foundTipLabel); + QVERIFY(foundView); + QVERIFY(!foundTipLabel); } } @@ -1507,6 +1508,7 @@ void tst_QGraphicsItem::selected_textItem() QGraphicsView view(&scene); view.show(); QTest::qWaitForWindowShown(&view); + QTest::qWait(20); QTRY_VERIFY(!text->isSelected()); QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, @@ -1546,115 +1548,136 @@ void tst_QGraphicsItem::selected_multi() QVERIFY(!item2->isSelected()); // Start clicking + QTest::qWait(200); // Click on item1 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item1->scenePos())); - QTRY_VERIFY(item1->isSelected()); - QTRY_VERIFY(!item2->isSelected()); + QTest::qWait(20); + QVERIFY(item1->isSelected()); + QVERIFY(!item2->isSelected()); // Click on item2 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item2->scenePos())); - QTRY_VERIFY(item2->isSelected()); - QTRY_VERIFY(!item1->isSelected()); + QTest::qWait(20); + QVERIFY(item2->isSelected()); + QVERIFY(!item1->isSelected()); // Ctrl-click on item1 QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(item1->scenePos())); - QTRY_VERIFY(item2->isSelected()); - QTRY_VERIFY(item1->isSelected()); + QTest::qWait(20); + QVERIFY(item2->isSelected()); + QVERIFY(item1->isSelected()); // Ctrl-click on item1 again QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(item1->scenePos())); - QTRY_VERIFY(item2->isSelected()); - QTRY_VERIFY(!item1->isSelected()); + QTest::qWait(20); + QVERIFY(item2->isSelected()); + QVERIFY(!item1->isSelected()); // Ctrl-click on item2 QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(item2->scenePos())); - QTRY_VERIFY(!item2->isSelected()); - QTRY_VERIFY(!item1->isSelected()); + QTest::qWait(20); + QVERIFY(!item2->isSelected()); + QVERIFY(!item1->isSelected()); // Click on item1 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item1->scenePos())); - QTRY_VERIFY(item1->isSelected()); - QTRY_VERIFY(!item2->isSelected()); + QTest::qWait(20); + QVERIFY(item1->isSelected()); + QVERIFY(!item2->isSelected()); // Click on scene QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(0, 0)); - QTRY_VERIFY(!item1->isSelected()); - QTRY_VERIFY(!item2->isSelected()); + QTest::qWait(20); + QVERIFY(!item1->isSelected()); + QVERIFY(!item2->isSelected()); // Click on item1 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item1->scenePos())); - QTRY_VERIFY(item1->isSelected()); - QTRY_VERIFY(!item2->isSelected()); + QTest::qWait(20); + QVERIFY(item1->isSelected()); + QVERIFY(!item2->isSelected()); // Ctrl-click on scene QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(0, 0)); - QTRY_VERIFY(!item1->isSelected()); - QTRY_VERIFY(!item2->isSelected()); + QTest::qWait(20); + QVERIFY(!item1->isSelected()); + QVERIFY(!item2->isSelected()); // Click on item1 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item1->scenePos())); - QTRY_VERIFY(item1->isSelected()); - QTRY_VERIFY(!item2->isSelected()); + QTest::qWait(20); + QVERIFY(item1->isSelected()); + QVERIFY(!item2->isSelected()); // Press on item2 QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item2->scenePos())); - QTRY_VERIFY(!item1->isSelected()); - QTRY_VERIFY(item2->isSelected()); + QTest::qWait(20); + QVERIFY(!item1->isSelected()); + QVERIFY(item2->isSelected()); // Release on item2 QTest::mouseRelease(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item2->scenePos())); - QTRY_VERIFY(!item1->isSelected()); - QTRY_VERIFY(item2->isSelected()); + QTest::qWait(20); + QVERIFY(!item1->isSelected()); + QVERIFY(item2->isSelected()); // Click on item1 QTest::mouseClick(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(item1->scenePos())); - QTRY_VERIFY(item1->isSelected()); - QTRY_VERIFY(!item2->isSelected()); + QTest::qWait(20); + QVERIFY(item1->isSelected()); + QVERIFY(!item2->isSelected()); // Ctrl-click on item1 QTest::mouseClick(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(item1->scenePos())); - QTRY_VERIFY(!item1->isSelected()); - QTRY_VERIFY(!item2->isSelected()); + QTest::qWait(20); + QVERIFY(!item1->isSelected()); + QVERIFY(!item2->isSelected()); // Ctrl-press on item1 QTest::mousePress(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(item1->scenePos())); - QTRY_VERIFY(!item1->isSelected()); - QTRY_VERIFY(!item2->isSelected()); + QTest::qWait(20); + QVERIFY(!item1->isSelected()); + QVERIFY(!item2->isSelected()); { // Ctrl-move on item1 QMouseEvent event(QEvent::MouseMove, view.mapFromScene(item1->scenePos()) + QPoint(1, 0), Qt::LeftButton, Qt::LeftButton, Qt::ControlModifier); QApplication::sendEvent(view.viewport(), &event); - QTRY_VERIFY(!item1->isSelected()); - QTRY_VERIFY(!item2->isSelected()); + QTest::qWait(20); + QVERIFY(!item1->isSelected()); + QVERIFY(!item2->isSelected()); } // Release on item1 QTest::mouseRelease(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(item1->scenePos())); - QTRY_VERIFY(item1->isSelected()); - QTRY_VERIFY(!item2->isSelected()); + QTest::qWait(20); + QVERIFY(item1->isSelected()); + QVERIFY(!item2->isSelected()); item1->setFlag(QGraphicsItem::ItemIsMovable); item1->setSelected(false); // Ctrl-press on item1 QTest::mousePress(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(item1->scenePos())); - QTRY_VERIFY(!item1->isSelected()); - QTRY_VERIFY(!item2->isSelected()); + QTest::qWait(20); + QVERIFY(!item1->isSelected()); + QVERIFY(!item2->isSelected()); { // Ctrl-move on item1 QMouseEvent event(QEvent::MouseMove, view.mapFromScene(item1->scenePos()) + QPoint(1, 0), Qt::LeftButton, Qt::LeftButton, Qt::ControlModifier); QApplication::sendEvent(view.viewport(), &event); - QTRY_VERIFY(item1->isSelected()); - QTRY_VERIFY(!item2->isSelected()); + QTest::qWait(20); + QVERIFY(item1->isSelected()); + QVERIFY(!item2->isSelected()); } // Release on item1 QTest::mouseRelease(view.viewport(), Qt::LeftButton, Qt::ControlModifier, view.mapFromScene(item1->scenePos())); - QTRY_VERIFY(item1->isSelected()); - QTRY_VERIFY(!item2->isSelected()); + QTest::qWait(20); + QVERIFY(item1->isSelected()); + QVERIFY(!item2->isSelected()); } void tst_QGraphicsItem::acceptedMouseButtons() @@ -3038,6 +3061,7 @@ void tst_QGraphicsItem::hoverEventsGenerateRepaints() QGraphicsView view(&scene); view.show(); QTest::qWaitForWindowShown(&view); + QTest::qWait(150); EventTester *tester = new EventTester; scene.addItem(tester); @@ -3053,9 +3077,11 @@ void tst_QGraphicsItem::hoverEventsGenerateRepaints() // Check that we get a repaint int npaints = tester->repaints; - QTRY_COMPARE(tester->events.size(), 2); // enter + move - QTRY_COMPARE(tester->repaints, npaints + 1); - QTRY_COMPARE(tester->events.last(), QEvent::GraphicsSceneHoverMove); + qApp->processEvents(); + qApp->processEvents(); + QCOMPARE(tester->events.size(), 2); // enter + move + QCOMPARE(tester->repaints, npaints + 1); + QCOMPARE(tester->events.last(), QEvent::GraphicsSceneHoverMove); // Send a hover move event QGraphicsSceneHoverEvent hoverMoveEvent(QEvent::GraphicsSceneHoverMove); @@ -3064,9 +3090,12 @@ void tst_QGraphicsItem::hoverEventsGenerateRepaints() QApplication::sendEvent(&scene, &hoverMoveEvent); // Check that we don't get a repaint - QTRY_COMPARE(tester->events.size(), 3); - QTRY_COMPARE(tester->repaints, npaints + 1); - QTRY_COMPARE(tester->events.last(), QEvent::GraphicsSceneHoverMove); + qApp->processEvents(); + qApp->processEvents(); + + QCOMPARE(tester->events.size(), 3); + QCOMPARE(tester->repaints, npaints + 1); + QCOMPARE(tester->events.last(), QEvent::GraphicsSceneHoverMove); // Send a hover leave event QGraphicsSceneHoverEvent hoverLeaveEvent(QEvent::GraphicsSceneHoverLeave); @@ -3075,9 +3104,12 @@ void tst_QGraphicsItem::hoverEventsGenerateRepaints() QApplication::sendEvent(&scene, &hoverLeaveEvent); // Check that we get a repaint - QTRY_COMPARE(tester->events.size(), 4); - QTRY_COMPARE(tester->repaints, npaints + 2); - QTRY_COMPARE(tester->events.last(), QEvent::GraphicsSceneHoverLeave); + qApp->processEvents(); + qApp->processEvents(); + + QCOMPARE(tester->events.size(), 4); + QCOMPARE(tester->repaints, npaints + 2); + QCOMPARE(tester->events.last(), QEvent::GraphicsSceneHoverLeave); } void tst_QGraphicsItem::boundingRects_data() @@ -3161,8 +3193,9 @@ void tst_QGraphicsItem::childrenBoundingRect() view.show(); QTest::qWaitForWindowShown(&view); + QTest::qWait(30); - QTRY_COMPARE(parent->childrenBoundingRect(), QRectF(-500, -100, 600, 800)); + QCOMPARE(parent->childrenBoundingRect(), QRectF(-500, -100, 600, 800)); } void tst_QGraphicsItem::childrenBoundingRectTransformed() @@ -3308,6 +3341,8 @@ void tst_QGraphicsItem::group() QCOMPARE(scene.items().size(), 4); QCOMPARE(scene.items(group->sceneBoundingRect()).size(), 3); + QTest::qWait(25); + QRectF parent2SceneBoundingRect = parent2->sceneBoundingRect(); group->addToGroup(parent2); QCOMPARE(parent2->group(), group); @@ -3318,6 +3353,8 @@ void tst_QGraphicsItem::group() QCOMPARE(scene.items().size(), 4); QCOMPARE(scene.items(group->sceneBoundingRect()).size(), 4); + QTest::qWait(25); + QList newItems; for (int i = 0; i < 100; ++i) { QGraphicsItem *item = scene.addRect(QRectF(-25, -25, 50, 50), QPen(Qt::black, 0), @@ -3334,7 +3371,9 @@ void tst_QGraphicsItem::group() int n = 0; foreach (QGraphicsItem *item, newItems) { group->addToGroup(item); - QTRY_COMPARE(item->group(), group); + QCOMPARE(item->group(), group); + if ((n++ % 100) == 0) + QTest::qWait(10); } } @@ -3524,6 +3563,7 @@ void tst_QGraphicsItem::handlesChildEvents() QGraphicsView view(&scene); view.show(); QTest::qWaitForWindowShown(&view); + QTest::qWait(20); // Pull out the items, closest item first QList items = scene.items(scene.itemsBoundingRect()); @@ -3736,6 +3776,7 @@ void tst_QGraphicsItem::filtersChildEvents() QGraphicsView view(&scene); view.show(); QTest::qWaitForWindowShown(&view); + QTest::qWait(20); QGraphicsSceneMouseEvent pressEvent(QEvent::GraphicsSceneMousePress); QGraphicsSceneMouseEvent releaseEvent(QEvent::GraphicsSceneMouseRelease); @@ -3861,6 +3902,7 @@ void tst_QGraphicsItem::ensureVisible() } item->ensureVisible(-100, -100, 25, 25); + QTest::qWait(25); for (int x = -100; x < 100; x += 25) { for (int y = -100; y < 100; y += 25) { @@ -3894,6 +3936,7 @@ void tst_QGraphicsItem::ensureVisible() } item->ensureVisible(100, 100, 25, 25); + QTest::qWait(25); } void tst_QGraphicsItem::cursor() @@ -3934,6 +3977,8 @@ void tst_QGraphicsItem::cursor() view.show(); QTest::mouseMove(&view, view.rect().center()); + QTest::qWait(25); + QCursor cursor = view.viewport()->cursor(); { @@ -3941,7 +3986,9 @@ void tst_QGraphicsItem::cursor() QApplication::sendEvent(view.viewport(), &event); } - QTRY_COMPARE(view.viewport()->cursor().shape(), cursor.shape()); + QTest::qWait(25); + + QCOMPARE(view.viewport()->cursor().shape(), cursor.shape()); { QTest::mouseMove(view.viewport(), view.mapFromScene(item1->sceneBoundingRect().center())); @@ -3956,7 +4003,7 @@ void tst_QGraphicsItem::cursor() return; #endif - QTRY_COMPARE(view.viewport()->cursor().shape(), item1->cursor().shape()); + QCOMPARE(view.viewport()->cursor().shape(), item1->cursor().shape()); { QTest::mouseMove(view.viewport(), view.mapFromScene(item2->sceneBoundingRect().center())); @@ -3964,7 +4011,9 @@ void tst_QGraphicsItem::cursor() QApplication::sendEvent(view.viewport(), &event); } - QTRY_COMPARE(view.viewport()->cursor().shape(), item2->cursor().shape()); + QTest::qWait(25); + + QCOMPARE(view.viewport()->cursor().shape(), item2->cursor().shape()); { QTest::mouseMove(view.viewport(), view.rect().center()); @@ -3972,7 +4021,9 @@ void tst_QGraphicsItem::cursor() QApplication::sendEvent(view.viewport(), &event); } - QTRY_COMPARE(view.viewport()->cursor().shape(), cursor.shape()); + QTest::qWait(25); + + QCOMPARE(view.viewport()->cursor().shape(), cursor.shape()); #endif } /* @@ -4636,6 +4687,7 @@ void tst_QGraphicsItem::sceneEventFilter() view.show(); QApplication::setActiveWindow(&view); QTest::qWaitForWindowShown(&view); + QTest::qWait(25); QGraphicsTextItem *text1 = scene.addText(QLatin1String("Text1")); QGraphicsTextItem *text2 = scene.addText(QLatin1String("Text2")); @@ -4699,6 +4751,7 @@ void tst_QGraphicsItem::sceneEventFilter() gv.setScene(anotherScene); gv.show(); QTest::qWaitForWindowShown(&gv); + QTest::qWait(25); ti->installSceneEventFilter(ti2); ti3->installSceneEventFilter(ti); delete ti2; @@ -4769,25 +4822,30 @@ void tst_QGraphicsItem::paint() QGraphicsView view2(&scene2); view2.show(); QTest::qWaitForWindowShown(&view2); + QTest::qWait(25); PaintTester tester2; scene2.addItem(&tester2); + qApp->processEvents(); //First show one paint QTRY_COMPARE(tester2.painted, 1); //nominal case, update call paint tester2.update(); + qApp->processEvents(); QTRY_VERIFY(tester2.painted == 2); //we remove the item from the scene, number of updates is still the same tester2.update(); scene2.removeItem(&tester2); + qApp->processEvents(); QTRY_VERIFY(tester2.painted == 2); //We re-add the item, the number of paint should increase scene2.addItem(&tester2); tester2.update(); + qApp->processEvents(); QTRY_VERIFY(tester2.painted == 3); } @@ -5181,6 +5239,7 @@ void tst_QGraphicsItem::itemClipsChildrenToShape2() #else QGraphicsView view(&scene); view.show(); + QTest::qWait(5000); #endif } @@ -5590,29 +5649,29 @@ void tst_QGraphicsItem::untransformable() for (int i = 0; i < 10; ++i) { QPoint center = view.viewport()->rect().center(); - QTRY_COMPARE(view.itemAt(center), item1); - QTRY_COMPARE(view.itemAt(center - QPoint(40, 0)), item1); - QTRY_COMPARE(view.itemAt(center - QPoint(-40, 0)), item1); - QTRY_COMPARE(view.itemAt(center - QPoint(0, 40)), item1); - QTRY_COMPARE(view.itemAt(center - QPoint(0, -40)), item1); + QCOMPARE(view.itemAt(center), item1); + QCOMPARE(view.itemAt(center - QPoint(40, 0)), item1); + QCOMPARE(view.itemAt(center - QPoint(-40, 0)), item1); + QCOMPARE(view.itemAt(center - QPoint(0, 40)), item1); + QCOMPARE(view.itemAt(center - QPoint(0, -40)), item1); center += QPoint(70, 70); - QTRY_COMPARE(view.itemAt(center - QPoint(40, 0)), item2); - QTRY_COMPARE(view.itemAt(center - QPoint(-40, 0)), item2); - QTRY_COMPARE(view.itemAt(center - QPoint(0, 40)), item2); - QTRY_COMPARE(view.itemAt(center - QPoint(0, -40)), item2); + QCOMPARE(view.itemAt(center - QPoint(40, 0)), item2); + QCOMPARE(view.itemAt(center - QPoint(-40, 0)), item2); + QCOMPARE(view.itemAt(center - QPoint(0, 40)), item2); + QCOMPARE(view.itemAt(center - QPoint(0, -40)), item2); center += QPoint(0, 100); - QTRY_COMPARE(view.itemAt(center - QPoint(40, 0)), item3); - QTRY_COMPARE(view.itemAt(center - QPoint(-40, 0)), item3); - QTRY_COMPARE(view.itemAt(center - QPoint(0, 40)), item3); - QTRY_COMPARE(view.itemAt(center - QPoint(0, -40)), item3); + QCOMPARE(view.itemAt(center - QPoint(40, 0)), item3); + QCOMPARE(view.itemAt(center - QPoint(-40, 0)), item3); + QCOMPARE(view.itemAt(center - QPoint(0, 40)), item3); + QCOMPARE(view.itemAt(center - QPoint(0, -40)), item3); view.scale(0.5, 0.5); view.rotate(13); view.shear(qreal(0.01), qreal(0.01)); view.translate(10, 10); - qApp->processEvents(); + QTest::qWait(25); } } @@ -5650,6 +5709,7 @@ void tst_QGraphicsItem::contextMenuEventPropagation() view.show(); view.resize(200, 200); QTest::qWaitForWindowShown(&view); + QTest::qWait(20); QContextMenuEvent event(QContextMenuEvent::Mouse, QPoint(10, 10), view.viewport()->mapToGlobal(QPoint(10, 10))); @@ -5756,6 +5816,8 @@ void tst_QGraphicsItem::task141694_textItemEnsureVisible() int hscroll = view.horizontalScrollBar()->value(); int vscroll = view.verticalScrollBar()->value(); + QTest::qWait(10); + // This should not cause the view to scroll QTRY_COMPARE(view.horizontalScrollBar()->value(), hscroll); QCOMPARE(view.verticalScrollBar()->value(), vscroll); @@ -5923,6 +5985,7 @@ void tst_QGraphicsItem::ensureUpdateOnTextItem() QGraphicsView view(&scene); view.show(); QTest::qWaitForWindowShown(&view); + QTest::qWait(25); TextItem *text1 = new TextItem(QLatin1String("123")); scene.addItem(text1); qApp->processEvents(); @@ -6224,6 +6287,7 @@ void tst_QGraphicsItem::opacity2() RESET_REPAINT_COUNTERS child->setOpacity(0.0); + QTest::qWait(10); QTRY_COMPARE(view.repaints, 1); QCOMPARE(parent->repaints, 1); QCOMPARE(child->repaints, 0); @@ -6232,6 +6296,7 @@ void tst_QGraphicsItem::opacity2() RESET_REPAINT_COUNTERS child->setOpacity(1.0); + QTest::qWait(10); QTRY_COMPARE(view.repaints, 1); QCOMPARE(parent->repaints, 1); QCOMPARE(child->repaints, 1); @@ -6240,6 +6305,7 @@ void tst_QGraphicsItem::opacity2() RESET_REPAINT_COUNTERS parent->setOpacity(0.0); + QTest::qWait(10); QTRY_COMPARE(view.repaints, 1); QCOMPARE(parent->repaints, 0); QCOMPARE(child->repaints, 0); @@ -6248,6 +6314,7 @@ void tst_QGraphicsItem::opacity2() RESET_REPAINT_COUNTERS parent->setOpacity(1.0); + QTest::qWait(10); QTRY_COMPARE(view.repaints, 1); QCOMPARE(parent->repaints, 1); QCOMPARE(child->repaints, 1); @@ -6257,6 +6324,7 @@ void tst_QGraphicsItem::opacity2() RESET_REPAINT_COUNTERS child->setOpacity(0.0); + QTest::qWait(10); QTRY_COMPARE(view.repaints, 1); QCOMPARE(parent->repaints, 1); QCOMPARE(child->repaints, 0); @@ -6265,6 +6333,7 @@ void tst_QGraphicsItem::opacity2() RESET_REPAINT_COUNTERS child->setOpacity(0.0); // Already 0.0; no change. + QTest::qWait(10); QTRY_COMPARE(view.repaints, 0); QCOMPARE(parent->repaints, 0); QCOMPARE(child->repaints, 0); @@ -6289,6 +6358,8 @@ void tst_QGraphicsItem::opacityZeroUpdates() view.reset(); parent->setOpacity(0.0); + QTest::qWait(20); + // transforming items bounding rect to view coordinates const QRect childDeviceBoundingRect = child->deviceTransform(view.viewportTransform()) .mapRect(child->boundingRect()).toRect(); @@ -6356,6 +6427,7 @@ void tst_QGraphicsItem::itemStacksBehindParent() view.show(); QTest::qWaitForWindowShown(&view); QTRY_VERIFY(!paintedItems.isEmpty()); + QTest::qWait(100); paintedItems.clear(); view.viewport()->update(); QApplication::processEvents(); @@ -6452,6 +6524,7 @@ void tst_QGraphicsItem::nestedClipping() view.setOptimizationFlag(QGraphicsView::IndirectPainting); view.show(); QTest::qWaitForWindowShown(&view); + QTest::qWait(25); QList expected; expected << root << l1 << l2 << l3; @@ -6639,13 +6712,16 @@ void tst_QGraphicsItem::tabChangesFocus() QTRY_VERIFY(scene.isActive()); dial1->setFocus(); + QTest::qWait(15); QTRY_VERIFY(dial1->hasFocus()); QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); + QTest::qWait(15); QTRY_VERIFY(view->hasFocus()); QTRY_VERIFY(item->hasFocus()); QTest::keyPress(QApplication::focusWidget(), Qt::Key_Tab); + QTest::qWait(15); if (tabChangesFocus) { QTRY_VERIFY(!view->hasFocus()); @@ -6679,21 +6755,24 @@ void tst_QGraphicsItem::cacheMode() testerChild2->setFlag(QGraphicsItem::ItemIgnoresTransformations); scene.addItem(tester); + QTest::qWait(10); for (int i = 0; i < 2; ++i) { // No visual change. QTRY_COMPARE(tester->repaints, 1); - QTRY_COMPARE(testerChild->repaints, 1); - QTRY_COMPARE(testerChild2->repaints, 1); + QCOMPARE(testerChild->repaints, 1); + QCOMPARE(testerChild2->repaints, 1); tester->setCacheMode(QGraphicsItem::NoCache); testerChild->setCacheMode(QGraphicsItem::NoCache); testerChild2->setCacheMode(QGraphicsItem::NoCache); + QTest::qWait(25); QTRY_COMPARE(tester->repaints, 1); - QTRY_COMPARE(testerChild->repaints, 1); - QTRY_COMPARE(testerChild2->repaints, 1); + QCOMPARE(testerChild->repaints, 1); + QCOMPARE(testerChild2->repaints, 1); tester->setCacheMode(QGraphicsItem::DeviceCoordinateCache); testerChild->setCacheMode(QGraphicsItem::DeviceCoordinateCache); testerChild2->setCacheMode(QGraphicsItem::DeviceCoordinateCache); + QTest::qWait(25); } // The first move causes a repaint as the item is painted into its pixmap. @@ -6701,42 +6780,48 @@ void tst_QGraphicsItem::cacheMode() tester->setPos(10, 10); testerChild->setPos(10, 10); testerChild2->setPos(10, 10); + QTest::qWait(25); QTRY_COMPARE(tester->repaints, 2); - QTRY_COMPARE(testerChild->repaints, 2); - QTRY_COMPARE(testerChild2->repaints, 2); + QCOMPARE(testerChild->repaints, 2); + QCOMPARE(testerChild2->repaints, 2); // Consecutive moves should not repaint. tester->setPos(20, 20); testerChild->setPos(20, 20); testerChild2->setPos(20, 20); - QTRY_COMPARE(tester->repaints, 2); - QTRY_COMPARE(testerChild->repaints, 2); - QTRY_COMPARE(testerChild2->repaints, 2); + QTest::qWait(250); + QCOMPARE(tester->repaints, 2); + QCOMPARE(testerChild->repaints, 2); + QCOMPARE(testerChild2->repaints, 2); // Translating does not result in a repaint. tester->translate(10, 10); + QTest::qWait(25); QTRY_COMPARE(tester->repaints, 2); - QTRY_COMPARE(testerChild->repaints, 2); - QTRY_COMPARE(testerChild2->repaints, 2); + QCOMPARE(testerChild->repaints, 2); + QCOMPARE(testerChild2->repaints, 2); // Rotating results in a repaint. tester->rotate(45); + QTest::qWait(25); QTRY_COMPARE(tester->repaints, 3); - QTRY_COMPARE(testerChild->repaints, 3); - QTRY_COMPARE(testerChild2->repaints, 2); + QCOMPARE(testerChild->repaints, 3); + QCOMPARE(testerChild2->repaints, 2); // Change to ItemCoordinateCache (triggers repaint). tester->setCacheMode(QGraphicsItem::ItemCoordinateCache); // autosize testerChild->setCacheMode(QGraphicsItem::ItemCoordinateCache); // autosize testerChild2->setCacheMode(QGraphicsItem::ItemCoordinateCache); // autosize + QTest::qWait(25); QTRY_COMPARE(tester->repaints, 4); - QTRY_COMPARE(testerChild->repaints, 4); - QTRY_COMPARE(testerChild2->repaints, 3); + QCOMPARE(testerChild->repaints, 4); + QCOMPARE(testerChild2->repaints, 3); // Rotating items with ItemCoordinateCache doesn't cause a repaint. tester->rotate(22); testerChild->rotate(22); testerChild2->rotate(22); + QTest::qWait(25); QTRY_COMPARE(tester->repaints, 4); QTRY_COMPARE(testerChild->repaints, 4); QTRY_COMPARE(testerChild2->repaints, 3); @@ -6746,66 +6831,76 @@ void tst_QGraphicsItem::cacheMode() // Explicit update causes a repaint. tester->update(0, 0, 5, 5); + QTest::qWait(25); QTRY_COMPARE(tester->repaints, 5); - QTRY_COMPARE(testerChild->repaints, 4); - QTRY_COMPARE(testerChild2->repaints, 3); + QCOMPARE(testerChild->repaints, 4); + QCOMPARE(testerChild2->repaints, 3); // Updating outside the item's bounds does not cause a repaint. tester->update(10, 10, 5, 5); + QTest::qWait(25); QTRY_COMPARE(tester->repaints, 5); - QTRY_COMPARE(testerChild->repaints, 4); - QTRY_COMPARE(testerChild2->repaints, 3); + QCOMPARE(testerChild->repaints, 4); + QCOMPARE(testerChild2->repaints, 3); // Resizing an item should cause a repaint of that item. (because of // autosize). tester->setGeometry(QRectF(-15, -15, 30, 30)); + QTest::qWait(25); QTRY_COMPARE(tester->repaints, 6); - QTRY_COMPARE(testerChild->repaints, 4); - QTRY_COMPARE(testerChild2->repaints, 3); + QCOMPARE(testerChild->repaints, 4); + QCOMPARE(testerChild2->repaints, 3); // Set fixed size. tester->setCacheMode(QGraphicsItem::ItemCoordinateCache, QSize(30, 30)); testerChild->setCacheMode(QGraphicsItem::ItemCoordinateCache, QSize(30, 30)); testerChild2->setCacheMode(QGraphicsItem::ItemCoordinateCache, QSize(30, 30)); + QTest::qWait(20); QTRY_COMPARE(tester->repaints, 7); - QTRY_COMPARE(testerChild->repaints, 5); - QTRY_COMPARE(testerChild2->repaints, 4); + QCOMPARE(testerChild->repaints, 5); + QCOMPARE(testerChild2->repaints, 4); // Resizing the item should cause a repaint. testerChild->setGeometry(QRectF(-15, -15, 30, 30)); + QTest::qWait(25); QTRY_COMPARE(tester->repaints, 7); - QTRY_COMPARE(testerChild->repaints, 6); - QTRY_COMPARE(testerChild2->repaints, 4); + QCOMPARE(testerChild->repaints, 6); + QCOMPARE(testerChild2->repaints, 4); // Scaling the view does not cause a repaint. view.scale(0.7, 0.7); + QTest::qWait(25); QTRY_COMPARE(tester->repaints, 7); - QTRY_COMPARE(testerChild->repaints, 6); - QTRY_COMPARE(testerChild2->repaints, 4); + QCOMPARE(testerChild->repaints, 6); + QCOMPARE(testerChild2->repaints, 4); // Switch to device coordinate cache. tester->setCacheMode(QGraphicsItem::DeviceCoordinateCache); testerChild->setCacheMode(QGraphicsItem::DeviceCoordinateCache); testerChild2->setCacheMode(QGraphicsItem::DeviceCoordinateCache); + QTest::qWait(25); QTRY_COMPARE(tester->repaints, 8); - QTRY_COMPARE(testerChild->repaints, 7); - QTRY_COMPARE(testerChild2->repaints, 5); + QCOMPARE(testerChild->repaints, 7); + QCOMPARE(testerChild2->repaints, 5); // Scaling the view back should cause repaints for two of the items. view.setTransform(QTransform()); + QTest::qWait(25); QTRY_COMPARE(tester->repaints, 9); - QTRY_COMPARE(testerChild->repaints, 8); - QTRY_COMPARE(testerChild2->repaints, 5); + QCOMPARE(testerChild->repaints, 8); + QCOMPARE(testerChild2->repaints, 5); // Rotating the base item (perspective) should repaint two items. tester->setTransform(QTransform().rotate(10, Qt::XAxis)); + QTest::qWait(25); QTRY_COMPARE(tester->repaints, 10); - QTRY_COMPARE(testerChild->repaints, 9); - QTRY_COMPARE(testerChild2->repaints, 5); + QCOMPARE(testerChild->repaints, 9); + QCOMPARE(testerChild2->repaints, 5); // Moving the middle item should case a repaint even if it's a move, // because the parent is rotated with a perspective. testerChild->setPos(1, 1); + QTest::qWait(25); QTRY_COMPARE(tester->repaints, 10); QTRY_COMPARE(testerChild->repaints, 10); QTRY_COMPARE(testerChild2->repaints, 5); @@ -6826,6 +6921,7 @@ void tst_QGraphicsItem::cacheMode() // Hiding and showing should invalidate the cache tester->hide(); + QTest::qWait(25); tester->show(); QTRY_COMPARE(tester->repaints, 14); QTRY_COMPARE(testerChild->repaints, 12); @@ -6918,26 +7014,31 @@ void tst_QGraphicsItem::updateCachedItemAfterMove() view.show(); QTest::qWaitForWindowShown(&view); + QTest::qWait(12); QTRY_VERIFY(tester->repaints > 0); tester->repaints = 0; // Move the item, should not cause repaints tester->setPos(10, 0); - QTRY_COMPARE(tester->repaints, 0); + QTest::qWait(12); + QCOMPARE(tester->repaints, 0); // Move then update, should cause one repaint tester->setPos(20, 0); tester->update(); - QTRY_COMPARE(tester->repaints, 1); + QTest::qWait(12); + QCOMPARE(tester->repaints, 1); // Hiding the item doesn't cause a repaint tester->hide(); - QTRY_COMPARE(tester->repaints, 1); + QTest::qWait(12); + QCOMPARE(tester->repaints, 1); // Moving a hidden item doesn't cause a repaint tester->setPos(30, 0); tester->update(); - QTRY_COMPARE(tester->repaints, 1); + QTest::qWait(12); + QCOMPARE(tester->repaints, 1); } class Track : public QGraphicsRectItem @@ -7058,6 +7159,7 @@ void tst_QGraphicsItem::update() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&view); #endif + QTest::qWait(100); EventTester *item = new EventTester; scene.addItem(item); @@ -7066,20 +7168,23 @@ void tst_QGraphicsItem::update() item->update(); // Item marked as dirty scene.update(); // Entire scene marked as dirty - QTRY_COMPARE(item->repaints, 1); + qApp->processEvents(); + QCOMPARE(item->repaints, 1); // Make sure the dirty state from the previous update is reset so that // the item don't think it is already dirty and discards this update. item->update(); - QTRY_COMPARE(item->repaints, 2); + qApp->processEvents(); + QCOMPARE(item->repaints, 2); // Make sure a partial update doesn't cause a full update to be discarded. view.reset(); item->repaints = 0; item->update(QRectF(0, 0, 5, 5)); item->update(); - QTRY_COMPARE(item->repaints, 1); - QTRY_COMPARE(view.repaints, 1); + qApp->processEvents(); + QCOMPARE(item->repaints, 1); + QCOMPARE(view.repaints, 1); QRect itemDeviceBoundingRect = item->deviceTransform(view.viewportTransform()) .mapRect(item->boundingRect()).toRect(); QRegion expectedRegion = itemDeviceBoundingRect.adjusted(-2, -2, 2, 2); @@ -7090,55 +7195,65 @@ void tst_QGraphicsItem::update() view.reset(); item->repaints = 0; item->update(-15, -15, 5, 5); // Item's brect: (-10, -10, 20, 20) - QTRY_COMPARE(item->repaints, 0); - QTRY_COMPARE(view.repaints, 0); + qApp->processEvents(); + QCOMPARE(item->repaints, 0); + QCOMPARE(view.repaints, 0); // Make sure the area occupied by an item is repainted when hiding it. view.reset(); item->repaints = 0; item->update(); // Full update; all sub-sequent update requests are discarded. item->hide(); // visible set to 0. ignoreVisible must be set to 1; the item won't be processed otherwise. - QTRY_COMPARE(item->repaints, 0); - QTRY_COMPARE(view.repaints, 1); + qApp->processEvents(); + QCOMPARE(item->repaints, 0); + QCOMPARE(view.repaints, 1); // The entire item's bounding rect (adjusted for antialiasing) should have been painted. - QTRY_COMPARE(view.paintedRegion, expectedRegion); + QCOMPARE(view.paintedRegion, expectedRegion); // Make sure item is repainted when shown (after being hidden). view.reset(); item->repaints = 0; item->show(); - QTRY_COMPARE(item->repaints, 1); - QTRY_COMPARE(view.repaints, 1); + qApp->processEvents(); + QCOMPARE(item->repaints, 1); + QCOMPARE(view.repaints, 1); // The entire item's bounding rect (adjusted for antialiasing) should have been painted. - QTRY_COMPARE(view.paintedRegion, expectedRegion); + QCOMPARE(view.paintedRegion, expectedRegion); item->repaints = 0; item->hide(); + qApp->processEvents(); view.reset(); const QPointF originalPos = item->pos(); item->setPos(5000, 5000); - QTRY_COMPARE(item->repaints, 0); - QTRY_COMPARE(view.repaints, 0); + qApp->processEvents(); + QCOMPARE(item->repaints, 0); + QCOMPARE(view.repaints, 0); + qApp->processEvents(); item->setPos(originalPos); - QTRY_COMPARE(item->repaints, 0); - QTRY_COMPARE(view.repaints, 0); + qApp->processEvents(); + QCOMPARE(item->repaints, 0); + QCOMPARE(view.repaints, 0); item->show(); - QTRY_COMPARE(item->repaints, 1); - QTRY_COMPARE(view.repaints, 1); + qApp->processEvents(); + QCOMPARE(item->repaints, 1); + QCOMPARE(view.repaints, 1); // The entire item's bounding rect (adjusted for antialiasing) should have been painted. QCOMPARE(view.paintedRegion, expectedRegion); QGraphicsViewPrivate *viewPrivate = static_cast(qt_widget_private(&view)); item->setPos(originalPos + QPoint(50, 50)); viewPrivate->updateAll(); - QVERIFY(viewPrivate->fullUpdatePending); // test to ensure object will be updated - QTRY_VERIFY(!(viewPrivate->fullUpdatePending)); // test to ensure object has been updated + QVERIFY(viewPrivate->fullUpdatePending); + QTest::qWait(50); item->repaints = 0; view.reset(); item->setPos(originalPos); - QTRY_COMPARE(item->repaints, 1); - QTRY_COMPARE(view.repaints, 1); + QTest::qWait(50); + qApp->processEvents(); + QCOMPARE(item->repaints, 1); + QCOMPARE(view.repaints, 1); COMPARE_REGIONS(view.paintedRegion, expectedRegion + expectedRegion.translated(50, 50)); // Make sure moving a parent item triggers an update on the children @@ -7155,16 +7270,18 @@ void tst_QGraphicsItem::update() view.reset(); item->repaints = 0; parent->translate(-400, 0); - QTRY_COMPARE(item->repaints, 0); - QTRY_COMPARE(view.repaints, 1); - QTRY_COMPARE(view.paintedRegion, expectedRegion); + qApp->processEvents(); + QCOMPARE(item->repaints, 0); + QCOMPARE(view.repaints, 1); + QCOMPARE(view.paintedRegion, expectedRegion); view.reset(); item->repaints = 0; parent->translate(400, 0); - QTRY_COMPARE(item->repaints, 1); - QTRY_COMPARE(view.repaints, 1); - QTRY_COMPARE(view.paintedRegion, expectedRegion); - QTRY_COMPARE(view.paintedRegion, expectedRegion); + qApp->processEvents(); + QCOMPARE(item->repaints, 1); + QCOMPARE(view.repaints, 1); + QCOMPARE(view.paintedRegion, expectedRegion); + QCOMPARE(view.paintedRegion, expectedRegion); } void tst_QGraphicsItem::setTransformProperties_data() @@ -7321,13 +7438,17 @@ void tst_QGraphicsItem::itemUsesExtendedStyleOption() rect->startTrack = false; view.show(); QTest::qWaitForWindowShown(&view); + QTest::qWait(60); rect->startTrack = true; rect->update(10, 10, 10, 10); + QTest::qWait(60); rect->startTrack = false; rect->setFlag(QGraphicsItem::ItemUsesExtendedStyleOption, true); - QTRY_VERIFY((rect->flags() & QGraphicsItem::ItemUsesExtendedStyleOption)); + QVERIFY((rect->flags() & QGraphicsItem::ItemUsesExtendedStyleOption)); + QTest::qWait(60); rect->startTrack = true; rect->update(10, 10, 10, 10); + QTest::qWait(60); } void tst_QGraphicsItem::itemSendsGeometryChanges() @@ -7379,6 +7500,7 @@ void tst_QGraphicsItem::moveItem() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&view); #endif + QTest::qWait(100); EventTester *parent = new EventTester; EventTester *child = new EventTester(parent); @@ -7401,8 +7523,9 @@ void tst_QGraphicsItem::moveItem() .adjusted(-2, -2, 2, 2); // Adjusted for antialiasing. parent->setPos(20, 20); - QTRY_COMPARE(parent->repaints, 1); - QTRY_COMPARE(view.repaints, 1); + qApp->processEvents(); + QCOMPARE(parent->repaints, 1); + QCOMPARE(view.repaints, 1); QRegion expectedParentRegion = parentDeviceBoundingRect; // old position parentDeviceBoundingRect.translate(20, 20); expectedParentRegion += parentDeviceBoundingRect; // new position @@ -7411,29 +7534,32 @@ void tst_QGraphicsItem::moveItem() RESET_COUNTERS child->setPos(20, 20); - QTRY_COMPARE(parent->repaints, 1); - QTRY_COMPARE(child->repaints, 1); - QTRY_COMPARE(view.repaints, 1); + qApp->processEvents(); + QCOMPARE(parent->repaints, 1); + QCOMPARE(child->repaints, 1); + QCOMPARE(view.repaints, 1); const QRegion expectedChildRegion = expectedParentRegion.translated(20, 20); COMPARE_REGIONS(view.paintedRegion, expectedChildRegion); RESET_COUNTERS grandChild->setPos(20, 20); - QTRY_COMPARE(parent->repaints, 1); - QTRY_COMPARE(child->repaints, 1); - QTRY_COMPARE(grandChild->repaints, 1); - QTRY_COMPARE(view.repaints, 1); + qApp->processEvents(); + QCOMPARE(parent->repaints, 1); + QCOMPARE(child->repaints, 1); + QCOMPARE(grandChild->repaints, 1); + QCOMPARE(view.repaints, 1); const QRegion expectedGrandChildRegion = expectedParentRegion.translated(40, 40); COMPARE_REGIONS(view.paintedRegion, expectedGrandChildRegion); RESET_COUNTERS parent->translate(20, 20); - QTRY_COMPARE(parent->repaints, 1); - QTRY_COMPARE(child->repaints, 1); - QTRY_COMPARE(grandChild->repaints, 1); - QTRY_COMPARE(view.repaints, 1); + qApp->processEvents(); + QCOMPARE(parent->repaints, 1); + QCOMPARE(child->repaints, 1); + QCOMPARE(grandChild->repaints, 1); + QCOMPARE(view.repaints, 1); expectedParentRegion.translate(20, 20); expectedParentRegion += expectedChildRegion.translated(20, 20); expectedParentRegion += expectedGrandChildRegion.translated(20, 20); @@ -7453,6 +7579,7 @@ void tst_QGraphicsItem::moveLineItem() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&view); #endif + QTest::qWait(200); view.reset(); const QRect itemDeviceBoundingRect = item->deviceTransform(view.viewportTransform()) @@ -7461,13 +7588,15 @@ void tst_QGraphicsItem::moveLineItem() // Make sure the calculated region is correct. item->update(); + QTest::qWait(10); QTRY_COMPARE(view.paintedRegion, expectedRegion); view.reset(); // Old position: (50, 50) item->setPos(50, 100); expectedRegion += expectedRegion.translated(0, 50); - QTRY_COMPARE(view.paintedRegion, expectedRegion); + QTest::qWait(10); + QCOMPARE(view.paintedRegion, expectedRegion); } void tst_QGraphicsItem::sorting_data() @@ -7510,6 +7639,7 @@ void tst_QGraphicsItem::sorting() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&view); #endif + QTest::qWait(100); _paintedItems.clear(); @@ -7568,6 +7698,7 @@ void tst_QGraphicsItem::hitTestUntransformableItem() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&view); #endif + QTest::qWait(100); // Confuse the BSP with dummy items. QGraphicsRectItem *dummy = new QGraphicsRectItem(0, 0, 20, 20); @@ -7593,16 +7724,18 @@ void tst_QGraphicsItem::hitTestUntransformableItem() item3->setPos(80, 80); scene.addItem(item1); + QTest::qWait(100); QList items = scene.items(QPointF(80, 80)); - QTRY_COMPARE(items.size(), 1); - QTRY_COMPARE(items.at(0), static_cast(item3)); + QCOMPARE(items.size(), 1); + QCOMPARE(items.at(0), static_cast(item3)); scene.setItemIndexMethod(QGraphicsScene::NoIndex); + QTest::qWait(100); items = scene.items(QPointF(80, 80)); - QTRY_COMPARE(items.size(), 1); - QTRY_COMPARE(items.at(0), static_cast(item3)); + QCOMPARE(items.size(), 1); + QCOMPARE(items.at(0), static_cast(item3)); } void tst_QGraphicsItem::hitTestGraphicsEffectItem() @@ -7615,6 +7748,7 @@ void tst_QGraphicsItem::hitTestGraphicsEffectItem() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&view); #endif + QTest::qWait(100); // Confuse the BSP with dummy items. QGraphicsRectItem *dummy = new QGraphicsRectItem(0, 0, 20, 20); @@ -7647,6 +7781,7 @@ void tst_QGraphicsItem::hitTestGraphicsEffectItem() item3->brush = Qt::blue; scene.addItem(item1); + QTest::qWait(100); item1->repaints = 0; item2->repaints = 0; @@ -7656,26 +7791,28 @@ void tst_QGraphicsItem::hitTestGraphicsEffectItem() QGraphicsDropShadowEffect *shadow = new QGraphicsDropShadowEffect; shadow->setOffset(-20, -20); item1->setGraphicsEffect(shadow); + QTest::qWait(50); // Make sure all visible items are repainted. - QTRY_COMPARE(item1->repaints, 0); - QTRY_COMPARE(item2->repaints, 1); - QTRY_COMPARE(item3->repaints, 1); + QCOMPARE(item1->repaints, 0); + QCOMPARE(item2->repaints, 1); + QCOMPARE(item3->repaints, 1); // Make sure an item doesn't respond to a click on its shadow. QList items = scene.items(QPointF(75, 75)); - QTRY_VERIFY(items.isEmpty()); + QVERIFY(items.isEmpty()); items = scene.items(QPointF(80, 80)); - QTRY_COMPARE(items.size(), 1); - QTRY_COMPARE(items.at(0), static_cast(item3)); + QCOMPARE(items.size(), 1); + QCOMPARE(items.at(0), static_cast(item3)); scene.setItemIndexMethod(QGraphicsScene::NoIndex); + QTest::qWait(100); items = scene.items(QPointF(75, 75)); - QTRY_VERIFY(items.isEmpty()); + QVERIFY(items.isEmpty()); items = scene.items(QPointF(80, 80)); - QTRY_COMPARE(items.size(), 1); - QTRY_COMPARE(items.at(0), static_cast(item3)); + QCOMPARE(items.size(), 1); + QCOMPARE(items.at(0), static_cast(item3)); } void tst_QGraphicsItem::focusProxy() @@ -8334,6 +8471,7 @@ void tst_QGraphicsItem::moveWhileDeleting() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&view); #endif + QTest::qWait(125); delete rect; @@ -8342,6 +8480,8 @@ void tst_QGraphicsItem::moveWhileDeleting() silly = new MoveWhileDying(rect); child = new QGraphicsRectItem(silly); + QTest::qWait(125); + delete rect; rect = new MoveWhileDying; @@ -8349,6 +8489,8 @@ void tst_QGraphicsItem::moveWhileDeleting() child = new QGraphicsRectItem(rect); silly = new MoveWhileDying(child); + QTest::qWait(125); + delete rect; } -- cgit v0.12 From 3e287de62f677dd0a88d2fa9299059025f2db546 Mon Sep 17 00:00:00 2001 From: Jens Bache-Wiig Date: Thu, 1 Apr 2010 14:57:21 +0200 Subject: Fix crash in the fileiconprovider for Windows In some cases the fileiconprovider has been reported to crash while accessing icons with overlays. This situation got worse with change b67bd25be08b54c3e6e49b2b9429e54ff58db268 since these cases were often hidden by broken caching. The workaround for now is to simply check that the hIcon structure is non empty before converting the icon. Task-number: QTBUG-8324 Reviewed-by: ogoffart --- src/gui/itemviews/qfileiconprovider.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/gui/itemviews/qfileiconprovider.cpp b/src/gui/itemviews/qfileiconprovider.cpp index fcc61e5..673065c 100644 --- a/src/gui/itemviews/qfileiconprovider.cpp +++ b/src/gui/itemviews/qfileiconprovider.cpp @@ -254,7 +254,9 @@ QIcon QFileIconProviderPrivate::getWinIcon(const QFileInfo &fileInfo) const val = SHGetFileInfo((const wchar_t *)QDir::toNativeSeparators(fileInfo.filePath()).utf16(), 0, &info, sizeof(SHFILEINFO), SHGFI_SMALLICON|SHGFI_SYSICONINDEX); #endif - if (val) { + + // Even if GetFileInfo returns a valid result, hIcon can be empty in some cases + if (val && info.hIcon) { if (fileInfo.isDir() && !fileInfo.isRoot()) { //using the unique icon index provided by windows save us from duplicate keys key = QString::fromLatin1("qt_dir_%1").arg(info.iIcon); @@ -293,7 +295,7 @@ QIcon QFileIconProviderPrivate::getWinIcon(const QFileInfo &fileInfo) const val = SHGetFileInfo((const wchar_t *)QDir::toNativeSeparators(fileInfo.filePath()).utf16(), 0, &info, sizeof(SHFILEINFO), SHGFI_LARGEICON|SHGFI_SYSICONINDEX); #endif - if (val) { + if (val && info.hIcon) { if (fileInfo.isDir() && !fileInfo.isRoot()) { //using the unique icon index provided by windows save us from duplicate keys key = QString::fromLatin1("qt_dir_%1").arg(info.iIcon); -- cgit v0.12 From f1550140010d5fdd431bbbc190d11848107bbdb8 Mon Sep 17 00:00:00 2001 From: David Faure Date: Sat, 3 Apr 2010 19:23:56 +0200 Subject: qDebug() << myPointF would remove spaces in following arguments. Merge-request: 544 Reviewed-by: Benjamin Poulain --- src/corelib/tools/qpoint.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qpoint.cpp b/src/corelib/tools/qpoint.cpp index d60087f..9850ee7 100644 --- a/src/corelib/tools/qpoint.cpp +++ b/src/corelib/tools/qpoint.cpp @@ -374,7 +374,7 @@ QDebug operator<<(QDebug dbg, const QPoint &p) { QDebug operator<<(QDebug d, const QPointF &p) { d.nospace() << "QPointF(" << p.x() << ", " << p.y() << ')'; - return d; + return d.space(); } #endif -- cgit v0.12 From 271a90c962ca6e419b2a6831f35a6a06be80a85d Mon Sep 17 00:00:00 2001 From: David Faure Date: Sat, 3 Apr 2010 19:23:57 +0200 Subject: Fix doc for deprecated QGridLayout::colSpacing: point to existing method Merge-request: 544 Reviewed-by: Benjamin Poulain --- src/gui/kernel/qgridlayout.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/kernel/qgridlayout.cpp b/src/gui/kernel/qgridlayout.cpp index dbd3c01..81a4d04 100644 --- a/src/gui/kernel/qgridlayout.cpp +++ b/src/gui/kernel/qgridlayout.cpp @@ -1852,7 +1852,7 @@ void QGridLayout::invalidate() /*! \fn int QGridLayout::colSpacing(int col) const - Use columnSpacing() instead. + Use columnMinimumWidth() instead. */ /*! -- cgit v0.12 From 29763aa66334a68011ddcc0fb817514ac67cd248 Mon Sep 17 00:00:00 2001 From: Alessandro Portale Date: Mon, 5 Apr 2010 13:20:27 +0200 Subject: Implementing QFontEngineS60::getSfntTableData() That function was not yet implementing. Its absense caused some Harfbuzz based shaping not to happen. See Robert DeWolf's comment on task QTBUG-5857 Since QFontEngineS60 is private implementation and generally not exported, no symbols need to be added to the .def files for this patch. Task-number: QTBUG-5857 Reviewed-by: trustme --- src/gui/text/qfontengine_s60.cpp | 30 ++++++++++++++++++++++++++++++ src/gui/text/qfontengine_s60_p.h | 2 ++ 2 files changed, 32 insertions(+) diff --git a/src/gui/text/qfontengine_s60.cpp b/src/gui/text/qfontengine_s60.cpp index 3ea084b..c9ff661 100644 --- a/src/gui/text/qfontengine_s60.cpp +++ b/src/gui/text/qfontengine_s60.cpp @@ -79,6 +79,31 @@ QByteArray QFontEngineS60Extensions::getSfntTable(uint tag) const return result; } +bool QFontEngineS60Extensions::getSfntTableData(uint tag, uchar *buffer, uint *length) const +{ + if (!m_trueTypeExtension->HasTrueTypeTable(tag)) + return false; + + bool result = true; + TInt error = KErrNone; + TInt tableByteLength; + TAny *table = + q_check_ptr(m_trueTypeExtension->GetTrueTypeTable(error, tag, &tableByteLength)); + + if (error != KErrNone) { + return false; + } else if (*length > 0 && *length < tableByteLength) { + result = false; // Caller did not allocate enough memory + } else { + *length = tableByteLength; + if (buffer) + qMemCopy(buffer, table, tableByteLength); + } + + m_trueTypeExtension->ReleaseTrueTypeTable(table); + return result; +} + const unsigned char *QFontEngineS60Extensions::cmap() const { if (!m_cmap) { @@ -326,6 +351,11 @@ QByteArray QFontEngineS60::getSfntTable(uint tag) const return m_extensions->getSfntTable(tag); } +bool QFontEngineS60::getSfntTableData(uint tag, uchar *buffer, uint *length) const +{ + return m_extensions->getSfntTableData(tag, buffer, length); +} + QFontEngine::Type QFontEngineS60::type() const { return QFontEngine::S60FontEngine; diff --git a/src/gui/text/qfontengine_s60_p.h b/src/gui/text/qfontengine_s60_p.h index 5834cc4..a80af4d 100644 --- a/src/gui/text/qfontengine_s60_p.h +++ b/src/gui/text/qfontengine_s60_p.h @@ -69,6 +69,7 @@ public: QFontEngineS60Extensions(CFont* fontOwner, COpenFont *font); QByteArray getSfntTable(uint tag) const; + bool getSfntTableData(uint tag, uchar *buffer, uint *length) const; const unsigned char *cmap() const; QPainterPath glyphOutline(glyph_t glyph) const; CFont *fontOwner() const; @@ -106,6 +107,7 @@ public: qreal minRightBearing() const { return 0; } QByteArray getSfntTable(uint tag) const; + bool getSfntTableData(uint tag, uchar *buffer, uint *length) const; static qreal pixelsToPoints(qreal pixels, Qt::Orientation orientation = Qt::Horizontal); static qreal pointsToPixels(qreal points, Qt::Orientation orientation = Qt::Horizontal); -- cgit v0.12 From ff8f6b0e5f76e4d4b1612a80325d6f66c825597f Mon Sep 17 00:00:00 2001 From: Toby Tomkins Date: Tue, 6 Apr 2010 11:54:19 +1000 Subject: Did not include updated repaint number for parent item in revert. --- tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index 7fdd9c9..bec4950 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -6901,7 +6901,7 @@ void tst_QGraphicsItem::cacheMode() // because the parent is rotated with a perspective. testerChild->setPos(1, 1); QTest::qWait(25); - QTRY_COMPARE(tester->repaints, 10); + QTRY_COMPARE(tester->repaints, 11); QTRY_COMPARE(testerChild->repaints, 10); QTRY_COMPARE(testerChild2->repaints, 5); tester->resetTransform(); -- cgit v0.12 From 1f6d3c9cddaf1e44ae9f0a18e9df5d4affe3f8b2 Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Tue, 6 Apr 2010 12:35:01 +1000 Subject: QAudioInput: possible change of state without emitting stateChange() Removed state change from close() function, should be set by caller depending on context. Task-number:QTBUG-9357 Reviewed-by:Dmytro Poplavskiy --- src/multimedia/audio/qaudioinput_alsa_p.cpp | 1 - src/multimedia/audio/qaudiooutput_alsa_p.cpp | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/src/multimedia/audio/qaudioinput_alsa_p.cpp b/src/multimedia/audio/qaudioinput_alsa_p.cpp index ead9995..6b15008 100644 --- a/src/multimedia/audio/qaudioinput_alsa_p.cpp +++ b/src/multimedia/audio/qaudioinput_alsa_p.cpp @@ -428,7 +428,6 @@ bool QAudioInputPrivate::open() void QAudioInputPrivate::close() { - deviceState = QAudio::StoppedState; timer->stop(); if ( handle ) { diff --git a/src/multimedia/audio/qaudiooutput_alsa_p.cpp b/src/multimedia/audio/qaudiooutput_alsa_p.cpp index 1cef335..cf3726b 100644 --- a/src/multimedia/audio/qaudiooutput_alsa_p.cpp +++ b/src/multimedia/audio/qaudiooutput_alsa_p.cpp @@ -485,7 +485,6 @@ bool QAudioOutputPrivate::open() void QAudioOutputPrivate::close() { - deviceState = QAudio::StoppedState; timer->stop(); if ( handle ) { @@ -701,6 +700,7 @@ bool QAudioOutputPrivate::deviceReady() } else if(l < 0) { close(); + deviceState = QAudio::StoppedState; errorState = QAudio::IOError; emit stateChanged(deviceState); } -- cgit v0.12 From 5f377ecf7a473094908f9355b4c22fdcbd83c0d5 Mon Sep 17 00:00:00 2001 From: Toby Tomkins Date: Tue, 6 Apr 2010 13:43:38 +1000 Subject: Remove qWait functions as it is used in QTRY_* macros. Reviewed-by: rohan mcgovern --- tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp | 36 ++++++++-------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp index 49b840f..dbd4a23 100644 --- a/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp +++ b/tests/auto/qgraphicseffect/tst_qgraphicseffect.cpp @@ -277,9 +277,8 @@ void tst_QGraphicsEffect::draw() // Make sure installing the effect triggers a repaint. CustomEffect *effect = new CustomEffect; item->setGraphicsEffect(effect); - QTest::qWait(50); - QCOMPARE(effect->numRepaints, 1); - QCOMPARE(item->numRepaints, 1); + QTRY_COMPARE(effect->numRepaints, 1); + QTRY_COMPARE(item->numRepaints, 1); // Make sure QPainter* and QStyleOptionGraphicsItem* stays persistent // during QGraphicsEffect::draw/QGraphicsItem::paint. @@ -293,26 +292,23 @@ void tst_QGraphicsEffect::draw() // Make sure updating the source triggers a repaint. item->update(); - QTest::qWait(50); - QCOMPARE(effect->numRepaints, 1); - QCOMPARE(item->numRepaints, 1); + QTRY_COMPARE(effect->numRepaints, 1); + QTRY_COMPARE(item->numRepaints, 1); QVERIFY(effect->m_sourceChangedFlags & QGraphicsEffect::SourceInvalidated); effect->reset(); item->reset(); // Make sure changing the effect's bounding rect triggers a repaint. effect->setMargin(20); - QTest::qWait(50); - QCOMPARE(effect->numRepaints, 1); - QCOMPARE(item->numRepaints, 1); + QTRY_COMPARE(effect->numRepaints, 1); + QTRY_COMPARE(item->numRepaints, 1); effect->reset(); item->reset(); // Make sure change the item's bounding rect triggers a repaint. item->setRect(0, 0, 50, 50); - QTest::qWait(50); - QCOMPARE(effect->numRepaints, 1); - QCOMPARE(item->numRepaints, 1); + QTRY_COMPARE(effect->numRepaints, 1); + QTRY_COMPARE(item->numRepaints, 1); QVERIFY(effect->m_sourceChangedFlags & QGraphicsEffect::SourceBoundingRectChanged); effect->reset(); item->reset(); @@ -320,8 +316,7 @@ void tst_QGraphicsEffect::draw() // Make sure the effect is the one to issue a repaint of the item. effect->doNothingInDraw = true; item->update(); - QTest::qWait(50); - QCOMPARE(effect->numRepaints, 1); + QTRY_COMPARE(effect->numRepaints, 1); QCOMPARE(item->numRepaints, 0); effect->doNothingInDraw = false; effect->reset(); @@ -336,9 +331,8 @@ void tst_QGraphicsEffect::draw() item->reset(); effect->setEnabled(true); - QTest::qWait(50); - QCOMPARE(effect->numRepaints, 1); - QCOMPARE(item->numRepaints, 1); + QTRY_COMPARE(effect->numRepaints, 1); + QTRY_COMPARE(item->numRepaints, 1); effect->reset(); item->reset(); @@ -352,8 +346,7 @@ void tst_QGraphicsEffect::draw() QPointer ptr = effect; item->setGraphicsEffect(0); QVERIFY(!ptr); - QTest::qWait(50); - QCOMPARE(item->numRepaints, 1); + QTRY_COMPARE(item->numRepaints, 1); } void tst_QGraphicsEffect::opacity() @@ -515,7 +508,6 @@ void tst_QGraphicsEffect::drawPixmapItem() QTRY_VERIFY(effect->repaints >= 1); item->rotate(180); - QTest::qWait(50); QTRY_VERIFY(effect->repaints >= 2); } @@ -560,9 +552,8 @@ void tst_QGraphicsEffect::deviceCoordinateTranslateCaching() int numRepaints = item->numRepaints; item->translate(10, 0); - QTest::qWait(50); - QVERIFY(item->numRepaints == numRepaints); + QTRY_VERIFY(item->numRepaints == numRepaints); } void tst_QGraphicsEffect::inheritOpacity() @@ -588,7 +579,6 @@ void tst_QGraphicsEffect::inheritOpacity() int numRepaints = item->numRepaints; rectItem->setOpacity(1); - QTest::qWait(50); // item should have been rerendered due to opacity changing QTRY_VERIFY(item->numRepaints > numRepaints); -- cgit v0.12 From f8f83e3a9177531169c3c2b525c868b6f4016381 Mon Sep 17 00:00:00 2001 From: Janne Anttila Date: Tue, 6 Apr 2010 13:25:59 +0300 Subject: Fixed modal dialog not to have automatic "Exit" right softkey in S60. During softkey refactoring this piece of code get changes, but the changed code did not work correctly if window had no softkey actions. Switched back to old way where softkey source is stored to variable, and windowType is asked from stored variable. If softkey source is dialog or popup, "Exit" is not added automatically to RSK. Task-number: QT-2203 Reviewed-by: Sami Merila --- src/gui/kernel/qsoftkeymanager.cpp | 1 + src/gui/kernel/qsoftkeymanager_common_p.h | 3 ++- src/gui/kernel/qsoftkeymanager_s60.cpp | 13 ++----------- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/src/gui/kernel/qsoftkeymanager.cpp b/src/gui/kernel/qsoftkeymanager.cpp index 923144a..23f1481 100644 --- a/src/gui/kernel/qsoftkeymanager.cpp +++ b/src/gui/kernel/qsoftkeymanager.cpp @@ -242,6 +242,7 @@ bool QSoftKeyManager::handleUpdateSoftKeys() d->requestedSoftKeyActions.clear(); bool recursiveMerging = false; QWidget *source = softkeySource(NULL, recursiveMerging); + d->initialSoftKeySource = source; while (source) { if (appendSoftkeys(*source, level)) ++level; diff --git a/src/gui/kernel/qsoftkeymanager_common_p.h b/src/gui/kernel/qsoftkeymanager_common_p.h index 460d0dc..04ddf7d 100644 --- a/src/gui/kernel/qsoftkeymanager_common_p.h +++ b/src/gui/kernel/qsoftkeymanager_common_p.h @@ -70,6 +70,7 @@ protected: static QSoftKeyManager *self; QHash keyedActions; QMultiHash requestedSoftKeyActions; + QWidget *initialSoftKeySource; }; @@ -79,4 +80,4 @@ QT_END_NAMESPACE QT_END_HEADER -#endif // QSOFTKEYMANAGER_COMMON_P_H \ No newline at end of file +#endif // QSOFTKEYMANAGER_COMMON_P_H diff --git a/src/gui/kernel/qsoftkeymanager_s60.cpp b/src/gui/kernel/qsoftkeymanager_s60.cpp index 9812d72..7d643c2 100644 --- a/src/gui/kernel/qsoftkeymanager_s60.cpp +++ b/src/gui/kernel/qsoftkeymanager_s60.cpp @@ -312,17 +312,8 @@ bool QSoftKeyManagerPrivateS60::setMiddleSoftkey(CEikButtonGroupContainer &cba) bool QSoftKeyManagerPrivateS60::setRightSoftkey(CEikButtonGroupContainer &cba) { if (!setSoftkey(cba, QAction::NegativeSoftKey, RSK_POSITION)) { - Qt::WindowType windowType = Qt::Window; - QAction *action = requestedSoftKeyActions.value(0); - if (action) { - QWidget *actionParent = action->parentWidget(); - Q_ASSERT_X(actionParent, Q_FUNC_INFO, "No parent set for softkey action!"); - - QWidget *actionWindow = actionParent->window(); - Q_ASSERT_X(actionWindow, Q_FUNC_INFO, "Softkey action does not have window!"); - windowType = actionWindow->windowType(); - } - + const Qt::WindowType windowType = initialSoftKeySource + ? initialSoftKeySource->window()->windowType() : Qt::Window; if (windowType != Qt::Dialog && windowType != Qt::Popup) { QString text(QSoftKeyManager::tr("Exit")); TPtrC nativeText = qt_QString2TPtrC(text); -- cgit v0.12 From a70d247d81d2f49faab522af5e4c2a815682c78a Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 6 Apr 2010 15:32:29 +0200 Subject: Fix crash for multiscript text in QTextEngine::boundingBox() The logClusters pointer is already adjusted for the item, so it should be indexed relative to the item, hence from 0 to itemLength-1. Adding pos to the index would give us a random value for all script items > 0. Thus this would sometimes crash for text that spanned several scripts, since we would sometimes get a value back which was outside the bounds of the glyph array. Task-number: QTBUG-9374 Reviewed-by: Samuel --- src/gui/text/qtextengine.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index b826588..eaa80d3 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -1648,7 +1648,7 @@ glyph_metrics_t QTextEngine::boundingBox(int from, int len) const } } - glyph_t glyph = glyphs.glyphs[logClusters[pos + ilen - 1]]; + glyph_t glyph = glyphs.glyphs[logClusters[ilen - 1]]; glyph_metrics_t gi = fe->boundingBox(glyph); if (gi.isValid()) gm.width -= qRound(gi.xoff - gi.x - gi.width); -- cgit v0.12 From 307d9d3f5f95fe0ebcd834adca9f3f8c46264ab2 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Tue, 6 Apr 2010 16:49:25 +0200 Subject: Updated WebKit from /home/shausman/src/webkit/trunk to qtwebkit/qtwebkit-4.6 ( e3dc4ef2b801d91e115c54f833fa7766d392ceda ) Changes in WebKit/qt since the last update: * r51006 -- https://bugs.webkit.org/show_bug.cgi?id=31475 -- Crash in StringHash::equal due to unaligned string data --- src/3rdparty/webkit/VERSION | 2 +- src/3rdparty/webkit/WebCore/ChangeLog | 14 ++++++++++++++ src/3rdparty/webkit/WebCore/platform/text/StringHash.h | 12 ++++++++++++ 3 files changed, 27 insertions(+), 1 deletion(-) diff --git a/src/3rdparty/webkit/VERSION b/src/3rdparty/webkit/VERSION index 4de7ad8..45608c5 100644 --- a/src/3rdparty/webkit/VERSION +++ b/src/3rdparty/webkit/VERSION @@ -8,4 +8,4 @@ The commit imported was from the and has the sha1 checksum - ecfa4583e573ce4dff1f0df12f6bdba3022376e5 + e3dc4ef2b801d91e115c54f833fa7766d392ceda diff --git a/src/3rdparty/webkit/WebCore/ChangeLog b/src/3rdparty/webkit/WebCore/ChangeLog index 2bd506b..a2bd5c3 100644 --- a/src/3rdparty/webkit/WebCore/ChangeLog +++ b/src/3rdparty/webkit/WebCore/ChangeLog @@ -1,3 +1,17 @@ +2009-11-15 Dave Tapuska + + Reviewed by George Staikos. + + Compare UChars single unit at a time as opposed to the uint32_t + approach as casting to unaligned addresses may cause a bus failure + on ARMv5 and below. This change replicates the same defines that + exists in AtomicString.cpp + + https://bugs.webkit.org/show_bug.cgi?id=31475 + + * platform/text/StringHash.h: + (WebCore::StringHash::equal): + 2010-03-25 yael aharon Reviewed by Laszlo Gombos. diff --git a/src/3rdparty/webkit/WebCore/platform/text/StringHash.h b/src/3rdparty/webkit/WebCore/platform/text/StringHash.h index 336dce3..5d01ea8 100644 --- a/src/3rdparty/webkit/WebCore/platform/text/StringHash.h +++ b/src/3rdparty/webkit/WebCore/platform/text/StringHash.h @@ -1,5 +1,6 @@ /* * Copyright (C) 2006, 2007, 2008 Apple Inc. All rights reserved + * Copyright (C) Research In Motion Limited 2009. All rights reserved. * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Library General Public @@ -47,6 +48,16 @@ namespace WebCore { if (aLength != bLength) return false; +#if PLATFORM(ARM) || PLATFORM(SH4) + const UChar* aChars = a->characters(); + const UChar* bChars = b->characters(); + for (unsigned i = 0; i != aLength; ++i) { + if (*aChars++ != *bChars++) + return false; + } + return true; +#else + /* Do it 4-bytes-at-a-time on architectures where it's safe */ const uint32_t* aChars = reinterpret_cast(a->characters()); const uint32_t* bChars = reinterpret_cast(b->characters()); @@ -59,6 +70,7 @@ namespace WebCore { return false; return true; +#endif } static unsigned hash(const RefPtr& key) { return key->hash(); } -- cgit v0.12 From b81f90ac0ff2be8f73bda785bb644281d515c291 Mon Sep 17 00:00:00 2001 From: Toby Tomkins Date: Wed, 7 Apr 2010 14:12:37 +1000 Subject: Remove qWait functions as it is used in QTRY_* macros. Reviewed-by: jason mcdonald --- .../tst_qgraphicseffectsource.cpp | 25 ++++++++--------- tests/auto/qgraphicslayout/tst_qgraphicslayout.cpp | 21 ++++++--------- .../tst_qgraphicsproxywidget.cpp | 31 +++++----------------- 3 files changed, 25 insertions(+), 52 deletions(-) diff --git a/tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp b/tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp index be03481..49f110e 100644 --- a/tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp +++ b/tests/auto/qgraphicseffectsource/tst_qgraphicseffectsource.cpp @@ -48,6 +48,8 @@ #include +#include "../../shared/util.h" + //TESTED_CLASS= //TESTED_FILES= @@ -220,9 +222,8 @@ void tst_QGraphicsEffectSource::styleOption() QCOMPARE(item->numRepaints, 0); QCOMPARE(effect->numRepaints, 0); item->update(); - QTest::qWait(50); - QCOMPARE(item->numRepaints, 1); - QCOMPARE(effect->numRepaints, 1); + QTRY_COMPARE(item->numRepaints, 1); + QTRY_COMPARE(effect->numRepaints, 1); } void tst_QGraphicsEffectSource::isPixmap() @@ -255,10 +256,9 @@ void tst_QGraphicsEffectSource::update() QCOMPARE(effect->numRepaints, 0); effect->source()->update(); - QTest::qWait(50); - QCOMPARE(item->numRepaints, 1); - QCOMPARE(effect->numRepaints, 1); + QTRY_COMPARE(item->numRepaints, 1); + QTRY_COMPARE(effect->numRepaints, 1); } void tst_QGraphicsEffectSource::boundingRect() @@ -273,22 +273,20 @@ void tst_QGraphicsEffectSource::boundingRect() // We can at least check that the device bounding rect was correct in QGraphicsEffect::draw. effect->storeDeviceDependentStuff = true; effect->source()->update(); - QTest::qWait(50); const QTransform deviceTransform = item->deviceTransform(view->viewportTransform()); - QCOMPARE(effect->sourceDeviceBoundingRect, deviceTransform.mapRect(itemBoundingRect)); + QTRY_COMPARE(effect->sourceDeviceBoundingRect, deviceTransform.mapRect(itemBoundingRect)); // Bounding rect in logical coordinates is of course fine. - QCOMPARE(effect->source()->boundingRect(Qt::LogicalCoordinates), itemBoundingRect); + QTRY_COMPARE(effect->source()->boundingRect(Qt::LogicalCoordinates), itemBoundingRect); // Make sure default value is Qt::LogicalCoordinates. - QCOMPARE(effect->source()->boundingRect(), itemBoundingRect); + QTRY_COMPARE(effect->source()->boundingRect(), itemBoundingRect); } void tst_QGraphicsEffectSource::deviceRect() { effect->storeDeviceDependentStuff = true; effect->source()->update(); - QTest::qWait(50); - QCOMPARE(effect->deviceRect, view->viewport()->rect()); + QTRY_COMPARE(effect->deviceRect, view->viewport()->rect()); } void tst_QGraphicsEffectSource::pixmap() @@ -299,8 +297,7 @@ void tst_QGraphicsEffectSource::pixmap() // We can at least verify a valid pixmap from QGraphicsEffect::draw. effect->storeDeviceDependentStuff = true; effect->source()->update(); - QTest::qWait(50); - QVERIFY(!effect->deviceCoordinatesPixmap.isNull()); + QTRY_VERIFY(!effect->deviceCoordinatesPixmap.isNull()); // Pixmaps in logical coordinates we can do fine. QPixmap pixmap1 = effect->source()->pixmap(Qt::LogicalCoordinates); diff --git a/tests/auto/qgraphicslayout/tst_qgraphicslayout.cpp b/tests/auto/qgraphicslayout/tst_qgraphicslayout.cpp index fb2e145..dad3279 100644 --- a/tests/auto/qgraphicslayout/tst_qgraphicslayout.cpp +++ b/tests/auto/qgraphicslayout/tst_qgraphicslayout.cpp @@ -44,6 +44,8 @@ #include #include +#include "../../shared/util.h" + //TESTED_CLASS=QGraphicsLayout //TESTED_FILES= @@ -423,22 +425,15 @@ void tst_QGraphicsLayout::alternativeLayoutItems() view.resize(150, 150); view.show(); - QApplication::processEvents(); - QTest::qWait(750); - QApplication::processEvents(); - - QCOMPARE(static_cast(li1->graphicsItem())->rect(), QRectF( 0, 0, 33, 99)); - QCOMPARE(static_cast(li2->graphicsItem())->rect(), QRectF(33, 0, 33, 99)); - QCOMPARE(static_cast(li3->graphicsItem())->rect(), QRectF(66, 0, 33, 99)); + QTRY_COMPARE(static_cast(li1->graphicsItem())->rect(), QRectF( 0, 0, 33, 99)); + QTRY_COMPARE(static_cast(li2->graphicsItem())->rect(), QRectF(33, 0, 33, 99)); + QTRY_COMPARE(static_cast(li3->graphicsItem())->rect(), QRectF(66, 0, 33, 99)); lout->setOrientation(Qt::Vertical); - QApplication::processEvents(); - QTest::qWait(750); - QApplication::processEvents(); - QCOMPARE(static_cast(li1->graphicsItem())->rect(), QRectF(0, 0, 99, 33)); - QCOMPARE(static_cast(li2->graphicsItem())->rect(), QRectF(0, 33, 99, 33)); - QCOMPARE(static_cast(li3->graphicsItem())->rect(), QRectF(0, 66, 99, 33)); + QTRY_COMPARE(static_cast(li1->graphicsItem())->rect(), QRectF(0, 0, 99, 33)); + QTRY_COMPARE(static_cast(li2->graphicsItem())->rect(), QRectF(0, 33, 99, 33)); + QTRY_COMPARE(static_cast(li3->graphicsItem())->rect(), QRectF(0, 66, 99, 33)); } diff --git a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp index 23b3458..e46709b 100644 --- a/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp +++ b/tests/auto/qgraphicsproxywidget/tst_qgraphicsproxywidget.cpp @@ -787,7 +787,6 @@ void tst_QGraphicsProxyWidget::focusNextPrevChild() view.show(); QApplication::setActiveWindow(&view); QTest::qWaitForWindowShown(&view); - QApplication::processEvents(); QTRY_COMPARE(QApplication::activeWindow(), &view); if (hasScene) { scene.addItem(proxy); @@ -836,7 +835,6 @@ void tst_QGraphicsProxyWidget::focusOutEvent() view.activateWindow(); view.setFocus(); QTest::qWaitForWindowShown(&view); - QApplication::processEvents(); QTRY_VERIFY(view.isVisible()); QTRY_COMPARE(QApplication::activeWindow(), &view); @@ -989,7 +987,6 @@ void tst_QGraphicsProxyWidget::hoverEnterLeaveEvent() // in QTest::mouseMove(&view, QPoint(50, 50)); - QTest::qWait(25); QTRY_COMPARE(widget->testAttribute(Qt::WA_UnderMouse), hasWidget ? true : false); // ### this attribute isn't supported QCOMPARE(widget->enterCount, hasWidget ? 1 : 0); @@ -999,11 +996,10 @@ void tst_QGraphicsProxyWidget::hoverEnterLeaveEvent() // out QTest::mouseMove(&view, QPoint(10, 10)); - QTest::qWait(25); // QTRY_COMPARE(widget->testAttribute(Qt::WA_UnderMouse), false); // ### this attribute isn't supported - QCOMPARE(widget->leaveCount, hasWidget ? 1 : 0); - QCOMPARE(widget->hoverLeave, (hasWidget && hoverEnabled) ? 1 : 0); + QTRY_COMPARE(widget->leaveCount, hasWidget ? 1 : 0); + QTRY_COMPARE(widget->hoverLeave, (hasWidget && hoverEnabled) ? 1 : 0); // does not work on all platforms //QCOMPARE(widget->moveCount, 0); @@ -1071,7 +1067,6 @@ void tst_QGraphicsProxyWidget::hoverMoveEvent() // move a little bit QTest::mouseMove(&view, QPoint(60, 60)); - QTest::qWait(12); QTRY_COMPARE(widget->hoverEnter, (hasWidget && hoverEnabled) ? 1 : 0); QCOMPARE(widget->moveCount, (hasWidget && mouseTracking) || (hasWidget && mouseDown) ? 1 : 0); @@ -1097,7 +1092,6 @@ void tst_QGraphicsProxyWidget::keyPressEvent() view.viewport()->setFocus(); QApplication::setActiveWindow(&view); QTest::qWaitForWindowShown(&view); - QApplication::processEvents(); QTRY_COMPARE(QApplication::activeWindow(), &view); SubQGraphicsProxyWidget *proxy = new SubQGraphicsProxyWidget; @@ -1305,13 +1299,11 @@ void tst_QGraphicsProxyWidget::paintEvent() scene.addItem(&proxy); //make sure we flush all the paint events - QTest::qWait(30); QTRY_VERIFY(proxy.paintCount > 1); QTest::qWait(30); proxy.paintCount = 0; w->update(); - QTest::qWait(30); QTRY_COMPARE(proxy.paintCount, 1); //the widget should have been painted now } @@ -1504,7 +1496,6 @@ void tst_QGraphicsProxyWidget::scrollUpdate() view.paintEventRegion = QRegion(); view.npaints = 0; QTimer::singleShot(0, widget, SLOT(updateScroll())); - QTest::qWait(50); QTRY_COMPARE(view.npaints, 2); // QRect(0, 0, 200, 12) is the first update, expanded (-2, -2, 2, 2) // QRect(0, 12, 102, 10) is the scroll update, expanded (-2, -2, 2, 2), @@ -2483,9 +2474,7 @@ void tst_QGraphicsProxyWidget::popup_basic() QTest::mousePress(view.viewport(), Qt::LeftButton, 0, view.mapFromScene(proxy->mapToScene(proxy->boundingRect().center()))); - QTest::qWait(12); - - QCOMPARE(box->pos(), QPoint()); + QTRY_COMPARE(box->pos(), QPoint()); QCOMPARE(proxy->childItems().count(), 1); QGraphicsProxyWidget *child = (QGraphicsProxyWidget*)(proxy->childItems())[0]; @@ -2498,7 +2487,6 @@ void tst_QGraphicsProxyWidget::popup_basic() QSKIP("Does not work due to SH_Combobox_Popup", SkipAll); QCOMPARE(child->widget()->parent(), static_cast(box)); - QTest::qWait(12); QTRY_COMPARE(proxy->pos(), QPointF(box->pos())); QCOMPARE(child->x(), qreal(box->x())); QCOMPARE(child->y(), qreal(box->rect().bottom())); @@ -2583,13 +2571,11 @@ void tst_QGraphicsProxyWidget::changingCursor_basic() // in QTest::mouseMove(view.viewport(), view.mapFromScene(proxy->mapToScene(proxy->boundingRect().center()))); sendMouseMove(view.viewport(), view.mapFromScene(proxy->mapToScene(proxy->boundingRect().center()))); - QTest::qWait(12); QTRY_COMPARE(view.viewport()->cursor().shape(), Qt::IBeamCursor); // out QTest::mouseMove(view.viewport(), QPoint(1, 1)); sendMouseMove(view.viewport(), QPoint(1, 1)); - QTest::qWait(12); QTRY_COMPARE(view.viewport()->cursor().shape(), Qt::ArrowCursor); #endif } @@ -2615,9 +2601,8 @@ void tst_QGraphicsProxyWidget::tooltip_basic() // in QTest::mouseMove(view.viewport(), view.mapFromScene(proxy->mapToScene(proxy->boundingRect().center()))); - QTest::qWait(3000); - QCOMPARE(proxy->childItems().count(), 1); + QTRY_COMPARE(proxy->childItems().count(), 1); QGraphicsProxyWidget *child = (QGraphicsProxyWidget*)(proxy->childItems())[0]; QVERIFY(child->isWidget()); QVERIFY(child->widget()); @@ -3348,7 +3333,6 @@ void tst_QGraphicsProxyWidget::updateAndDelete() #ifdef Q_WS_X11 qt_x11_wait_for_window_manager(&view); #endif - QTest::qWait(20); QTRY_VERIFY(view.npaints > 0); const QRect itemDeviceBoundingRect = proxy->deviceTransform(view.viewportTransform()) @@ -3361,8 +3345,7 @@ void tst_QGraphicsProxyWidget::updateAndDelete() // Update and hide. proxy->update(); proxy->hide(); - QTest::qWait(50); - QCOMPARE(view.npaints, 1); + QTRY_COMPARE(view.npaints, 1); QCOMPARE(view.paintEventRegion, expectedRegion); proxy->show(); @@ -3373,8 +3356,7 @@ void tst_QGraphicsProxyWidget::updateAndDelete() // Update and delete. proxy->update(); delete proxy; - QTest::qWait(50); - QCOMPARE(view.npaints, 1); + QTRY_COMPARE(view.npaints, 1); QCOMPARE(view.paintEventRegion, expectedRegion); } @@ -3439,7 +3421,6 @@ void tst_QGraphicsProxyWidget::clickFocus() qt_x11_wait_for_window_manager(&view); #endif QApplication::setActiveWindow(&view); - QTest::qWait(25); QTRY_COMPARE(QApplication::activeWindow(), &view); QVERIFY(!proxy->hasFocus()); -- cgit v0.12 From 49218ff73ee151a5820d83c5ec87dc2cf0025235 Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Thu, 8 Apr 2010 08:51:53 +1000 Subject: Mismatch between reported and actual supported sample rates in QtMultimedia backend for Windows -Added 8000 as long as another frequency is available. -options available changed from hard-coded to detected options. Task-number:QTBUG-9100 Reviewed-by:Derick Hawcroft --- src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp | 74 +++++++++++++++++++---- 1 file changed, 63 insertions(+), 11 deletions(-) diff --git a/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp index f6b8154..465bc98 100644 --- a/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp +++ b/src/multimedia/audio/qaudiodeviceinfo_win32_p.cpp @@ -78,6 +78,8 @@ QAudioDeviceInfoInternal::QAudioDeviceInfoInternal(QByteArray dev, QAudio::Mode { device = QLatin1String(dev); this->mode = mode; + + updateLists(); } QAudioDeviceInfoInternal::~QAudioDeviceInfoInternal() @@ -176,22 +178,70 @@ bool QAudioDeviceInfoInternal::testSettings(const QAudioFormat& format) const // See if what is in settings will work (return value). bool failed = false; + bool match = false; - // For now, just accept only audio/pcm codec - if(!format.codec().startsWith(QLatin1String("audio/pcm"))) - failed = true; + // check codec + for( int i = 0; i < codecz.count(); i++) { + if (format.codec() == codecz.at(i)) + match = true; + } + if (!match) failed = true; + + // check channel + match = false; + if (!failed) { + for( int i = 0; i < channelz.count(); i++) { + if (format.channels() == channelz.at(i)) { + match = true; + break; + } + } + } + if (!match) failed = true; + + // check frequency + match = false; + if (!failed) { + for( int i = 0; i < freqz.count(); i++) { + if (format.frequency() == freqz.at(i)) { + match = true; + break; + } + } + } - if(!failed && !(format.channels() == 1 || format.channels() == 2)) - failed = true; + // check sample size + match = false; + if (!failed) { + for( int i = 0; i < sizez.count(); i++) { + if (format.sampleSize() == sizez.at(i)) { + match = true; + break; + } + } + } - if(!failed) { - if(!(format.frequency() == 8000 || format.frequency() == 11025 || format.frequency() == 22050 || - format.frequency() == 44100 || format.frequency() == 48000 || format.frequency() == 96000)) - failed = true; + // check byte order + match = false; + if (!failed) { + for( int i = 0; i < byteOrderz.count(); i++) { + if (format.byteOrder() == byteOrderz.at(i)) { + match = true; + break; + } + } } - if(!failed && !(format.sampleSize() == 8 || format.sampleSize() == 16)) - failed = true; + // check sample type + match = false; + if (!failed) { + for( int i = 0; i < typez.count(); i++) { + if (format.sampleType() == typez.at(i)) { + match = true; + break; + } + } + } if(!failed) { // settings work @@ -332,6 +382,8 @@ void QAudioDeviceInfoInternal::updateLists() codecz.append(QLatin1String("audio/pcm")); } + if (freqz.count() > 0) + freqz.prepend(8000); } QList QAudioDeviceInfoInternal::availableDevices(QAudio::Mode mode) -- cgit v0.12 From a5b4b54820b9266a2916981002e9be66fd0a7710 Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Fri, 9 Apr 2010 12:59:47 +1000 Subject: Just one (static) waveInCriticalSection but multiple QAudioInput to record from different soundcards Task-number:QTBUG-9221 Reviewed-by:Andrew den Exter --- src/multimedia/audio/qaudioinput_win32_p.cpp | 10 ++++------ src/multimedia/audio/qaudioinput_win32_p.h | 2 ++ src/multimedia/audio/qaudiooutput_win32_p.cpp | 8 +++----- src/multimedia/audio/qaudiooutput_win32_p.h | 2 ++ 4 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/multimedia/audio/qaudioinput_win32_p.cpp b/src/multimedia/audio/qaudioinput_win32_p.cpp index ec0359a..bf13c43 100644 --- a/src/multimedia/audio/qaudioinput_win32_p.cpp +++ b/src/multimedia/audio/qaudioinput_win32_p.cpp @@ -57,8 +57,6 @@ QT_BEGIN_NAMESPACE //#define DEBUG_AUDIO 1 -static CRITICAL_SECTION waveInCriticalSection; - static const int minimumIntervalTime = 50; QAudioInputPrivate::QAudioInputPrivate(const QByteArray &device, const QAudioFormat& audioFormat): @@ -104,16 +102,16 @@ void CALLBACK QAudioInputPrivate::waveInProc( HWAVEIN hWaveIn, UINT uMsg, case WIM_OPEN: break; case WIM_DATA: - EnterCriticalSection(&waveInCriticalSection); + EnterCriticalSection(&qAudio->waveInCriticalSection); if(qAudio->waveFreeBlockCount > 0) qAudio->waveFreeBlockCount--; qAudio->feedback(); - LeaveCriticalSection(&waveInCriticalSection); + LeaveCriticalSection(&qAudio->waveInCriticalSection); break; case WIM_CLOSE: - EnterCriticalSection(&waveInCriticalSection); + EnterCriticalSection(&qAudio->waveInCriticalSection); qAudio->finished = true; - LeaveCriticalSection(&waveInCriticalSection); + LeaveCriticalSection(&qAudio->waveInCriticalSection); break; default: return; diff --git a/src/multimedia/audio/qaudioinput_win32_p.h b/src/multimedia/audio/qaudioinput_win32_p.h index d555eff..a12c75e 100644 --- a/src/multimedia/audio/qaudioinput_win32_p.h +++ b/src/multimedia/audio/qaudioinput_win32_p.h @@ -122,6 +122,8 @@ private: volatile int waveFreeBlockCount; int waveCurrentBlock; + CRITICAL_SECTION waveInCriticalSection; + static void CALLBACK waveInProc( HWAVEIN hWaveIn, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2 ); diff --git a/src/multimedia/audio/qaudiooutput_win32_p.cpp b/src/multimedia/audio/qaudiooutput_win32_p.cpp index f3ba079..e818723 100644 --- a/src/multimedia/audio/qaudiooutput_win32_p.cpp +++ b/src/multimedia/audio/qaudiooutput_win32_p.cpp @@ -56,8 +56,6 @@ QT_BEGIN_NAMESPACE -static CRITICAL_SECTION waveOutCriticalSection; - static const int minimumIntervalTime = 50; QAudioOutputPrivate::QAudioOutputPrivate(const QByteArray &device, const QAudioFormat& audioFormat): @@ -107,16 +105,16 @@ void CALLBACK QAudioOutputPrivate::waveOutProc( HWAVEOUT hWaveOut, UINT uMsg, case WOM_CLOSE: return; case WOM_DONE: - EnterCriticalSection(&waveOutCriticalSection); + EnterCriticalSection(&qAudio->waveOutCriticalSection); if(qAudio->finished || qAudio->buffer_size == 0 || qAudio->period_size == 0) { - LeaveCriticalSection(&waveOutCriticalSection); + LeaveCriticalSection(&qAudio->waveOutCriticalSection); return; } qAudio->waveFreeBlockCount++; if(qAudio->waveFreeBlockCount >= qAudio->buffer_size/qAudio->period_size) qAudio->waveFreeBlockCount = qAudio->buffer_size/qAudio->period_size; qAudio->feedback(); - LeaveCriticalSection(&waveOutCriticalSection); + LeaveCriticalSection(&qAudio->waveOutCriticalSection); break; default: return; diff --git a/src/multimedia/audio/qaudiooutput_win32_p.h b/src/multimedia/audio/qaudiooutput_win32_p.h index 6e0899f..a7a0b07 100644 --- a/src/multimedia/audio/qaudiooutput_win32_p.h +++ b/src/multimedia/audio/qaudiooutput_win32_p.h @@ -119,6 +119,8 @@ private: static void CALLBACK waveOutProc( HWAVEOUT hWaveOut, UINT uMsg, DWORD dwInstance, DWORD dwParam1, DWORD dwParam2 ); + CRITICAL_SECTION waveOutCriticalSection; + WAVEHDR* allocateBlocks(int size, int count); void freeBlocks(WAVEHDR* blockArray); bool open(); -- cgit v0.12 From 544bbfadc0703597b7084213261053ca0e2facf6 Mon Sep 17 00:00:00 2001 From: Kurt Korbatits Date: Fri, 9 Apr 2010 15:12:43 +1000 Subject: Corruption in data captured by QAudioInput Increased default buffer size and period size for windows. 11025monoS16LE was choppy, needed bigger periods. Task-number:QTBUG-9101 Reviewed-by:Derick Hawcroft --- src/multimedia/audio/qaudioinput_win32_p.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/multimedia/audio/qaudioinput_win32_p.cpp b/src/multimedia/audio/qaudioinput_win32_p.cpp index bf13c43..df469d7 100644 --- a/src/multimedia/audio/qaudioinput_win32_p.cpp +++ b/src/multimedia/audio/qaudioinput_win32_p.cpp @@ -224,8 +224,8 @@ bool QAudioInputPrivate::open() #endif header = 0; if(buffer_size == 0) { - // Default buffer size, 100ms, default period size is 20ms - buffer_size = settings.frequency()*settings.channels()*(settings.sampleSize()/8)*0.1; + // Default buffer size, 200ms, default period size is 40ms + buffer_size = settings.frequency()*settings.channels()*(settings.sampleSize()/8)*0.2; period_size = buffer_size/5; } else { period_size = buffer_size/5; -- cgit v0.12