From e54e4f19ec2fd06f9d383b2cd83a565479e3cced Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 10 Aug 2009 10:36:01 +1000 Subject: Add a private function for conversion a QPixmap into a VGImage Custom OpenVG pixmap filters written by users will need to access the VGImage form of a QPixmap. The qPixmapToVGImage() function is provided for this purpose, as a private API. Reviewed-by: Sarah Smith --- src/openvg/qpixmapdata_vg.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/openvg/qpixmapdata_vg.cpp b/src/openvg/qpixmapdata_vg.cpp index 90fd9a5..6f2024f 100644 --- a/src/openvg/qpixmapdata_vg.cpp +++ b/src/openvg/qpixmapdata_vg.cpp @@ -341,4 +341,29 @@ QImage::Format QVGPixmapData::sourceFormat() const return QImage::Format_ARGB32_Premultiplied; } +/* + \internal + + Returns the VGImage that is storing the contents of \a pixmap. + Returns VG_INVALID_HANDLE if \a pixmap is not owned by the OpenVG + graphics system or \a pixmap is invalid. + + This function is typically used to access the backing store + for a pixmap when executing raw OpenVG calls. It must only + be used when a QPainter is active and the OpenVG paint engine + is in use by the QPainter. + + \sa {QtOpenVG Module} +*/ +Q_OPENVG_EXPORT VGImage qPixmapToVGImage(const QPixmap& pixmap) +{ + QPixmapData *pd = pixmap.pixmapData(); + if (pd->classId() == QPixmapData::OpenVGClass) { + QVGPixmapData *vgpd = static_cast(pd); + if (vgpd->isValid()) + return vgpd->toVGImage(); + } + return VG_INVALID_HANDLE; +} + QT_END_NAMESPACE -- cgit v0.12 From 341ba562a81c4be1264020c207a940d5c7fd5de7 Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Mon, 10 Aug 2009 14:27:49 +1000 Subject: Make checksdk give a nonzero exit code when it's asked for an SDK which isn't available. Reviewed-by: Michael Goddard --- tools/checksdk/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tools/checksdk/main.cpp b/tools/checksdk/main.cpp index 6322eb7..b36aa32 100644 --- a/tools/checksdk/main.cpp +++ b/tools/checksdk/main.cpp @@ -161,5 +161,5 @@ int main(int argc, char **argv) } } qWarning("Could not find specified SDK: %s" , qPrintable(sdkName)); - return 0; -} \ No newline at end of file + return -1; +} -- cgit v0.12 From bb97f90ef340d668f3dc04026aa034b33a997453 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 10 Aug 2009 14:47:13 +1000 Subject: Set default QGraphicsTransform3D axis to (0, 0, 1) The docs said that the default axis was (0, 0, 1), but the code and unit tests were using (0, 0, 0). Modify the code to match the docs because (0, 0, 0) is not very useful. Also optimize the calculation of sin/cos values for 90, 180, and 270 degrees. Reviewed-by: Aaron Kennedy --- src/gui/graphicsview/qgraphicstransform.cpp | 37 +++++++++++++++------- .../qgraphicstransform/tst_qgraphicstransform.cpp | 22 ++++++++++++- 2 files changed, 47 insertions(+), 12 deletions(-) diff --git a/src/gui/graphicsview/qgraphicstransform.cpp b/src/gui/graphicsview/qgraphicstransform.cpp index 778cd94..ae88641 100644 --- a/src/gui/graphicsview/qgraphicstransform.cpp +++ b/src/gui/graphicsview/qgraphicstransform.cpp @@ -80,11 +80,7 @@ #include "qgraphicsitem_p.h" #include "qgraphicstransform_p.h" #include - -#include -#ifndef M_PI -#define M_PI 3.14159265358979323846 -#endif +#include QT_BEGIN_NAMESPACE @@ -355,7 +351,6 @@ public: QGraphicsRotationPrivate() : angle(0) {} QPointF origin; - qreal originY; qreal angle; }; @@ -475,13 +470,18 @@ void QGraphicsRotation::applyTo(QTransform *t) const By default the axis is (0, 0, 1), giving QGraphicsRotation3D the same default behavior as QGraphicsRotation (i.e., rotation around the Z axis). + Note: the final rotation is the combined effect of a rotation in + 3D space followed by a projection back to 2D. If several rotations + are performed in succession, they will not behave as expected unless + they were all around the Z axis. + \sa QGraphicsTransform, QGraphicsItem::setRotation(), QTransform::rotate() */ class QGraphicsRotation3DPrivate : public QGraphicsRotationPrivate { public: - QGraphicsRotation3DPrivate() {} + QGraphicsRotation3DPrivate() : axis(0, 0, 1) {} QVector3D axis; }; @@ -526,6 +526,7 @@ void QGraphicsRotation3D::setAxis(const QVector3D &axis) update(); } +const qreal deg2rad = qreal(0.017453292519943295769); // pi/180 static const qreal inv_dist_to_plane = 1. / 1024.; /*! @@ -535,13 +536,27 @@ void QGraphicsRotation3D::applyTo(QTransform *t) const { Q_D(const QGraphicsRotation3D); - if (d->angle == 0. || + qreal a = d->angle; + + if (a == 0. || (d->axis.z() == 0. && d->axis.y() == 0 && d->axis.x() == 0)) return; - qreal rad = d->angle * 2. * M_PI / 360.; - qreal c = ::cos(rad); - qreal s = ::sin(rad); + qreal c, s; + if (a == 90. || a == -270.) { + s = 1.; + c = 0.; + } else if (a == 270. || a == -90.) { + s = -1.; + c = 0.; + } else if (a == 180.) { + s = 0.; + c = -1.; + } else { + qreal b = deg2rad*a; + s = qSin(b); + c = qCos(b); + } qreal x = d->axis.x(); qreal y = d->axis.y(); diff --git a/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp b/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp index 672b1f1..c9481da 100644 --- a/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp +++ b/tests/auto/qgraphicstransform/tst_qgraphicstransform.cpp @@ -137,7 +137,10 @@ void tst_QGraphicsTransform::rotation() void tst_QGraphicsTransform::rotation3d() { QGraphicsRotation3D rotation; - rotation.setOrigin(QPointF(10, 10)); + QCOMPARE(rotation.axis().x(), (qreal)0); + QCOMPARE(rotation.axis().y(), (qreal)0); + QCOMPARE(rotation.axis().z(), (qreal)1); + QCOMPARE(rotation.angle(), (qreal)0); QTransform t; rotation.applyTo(&t); @@ -147,6 +150,23 @@ void tst_QGraphicsTransform::rotation3d() rotation.setAngle(180); + QTransform t180; + t180.rotate(180.0f); + + QCOMPARE(t, QTransform()); + QVERIFY(qFuzzyCompare(rotation.transform(), t180)); + + rotation.setAxis(QVector3D(0, 0, 0)); + rotation.setOrigin(QPointF(10, 10)); + + t = QTransform(); + rotation.applyTo(&t); + + QCOMPARE(t, QTransform()); + QCOMPARE(rotation.transform(), QTransform()); + + rotation.setAngle(180); + QCOMPARE(t, QTransform()); QCOMPARE(rotation.transform(), QTransform()); -- cgit v0.12 From 5d01d0cde28f2ac1ff9b5d8ca731edcf38725051 Mon Sep 17 00:00:00 2001 From: Rhys Weatherley Date: Mon, 10 Aug 2009 15:31:00 +1000 Subject: Emit axisChanged() when the QGraphicsRotation3D axis changes. Reviewed-by: Aaron Kennedy --- src/gui/graphicsview/qgraphicstransform.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/gui/graphicsview/qgraphicstransform.cpp b/src/gui/graphicsview/qgraphicstransform.cpp index ae88641..775a0d5 100644 --- a/src/gui/graphicsview/qgraphicstransform.cpp +++ b/src/gui/graphicsview/qgraphicstransform.cpp @@ -522,8 +522,11 @@ QVector3D QGraphicsRotation3D::axis() void QGraphicsRotation3D::setAxis(const QVector3D &axis) { Q_D(QGraphicsRotation3D); + if (d->axis == axis) + return; d->axis = axis; update(); + emit axisChanged(); } const qreal deg2rad = qreal(0.017453292519943295769); // pi/180 -- cgit v0.12 From 6cc14b9bd84de30471db40f73b119ba33356a6ba Mon Sep 17 00:00:00 2001 From: Keith Isdale Date: Mon, 10 Aug 2009 17:19:20 +1000 Subject: In a .pro file the include() function does not warn if specified file can not be found change that behavior to warn by default. Currently the default behavior of include() in a .pro file is not to warn if the supplied file argument can not be found which can lead to hard to find build errors. The include() will now,by default, warn if the specified file can not be found. If a warning is not required because the included file is optional then example use in the .pro file: include(SomePriFile.pri", "", true) Task-number:259398 Reviewed-by:Marius Storm-Olsen --- mkspecs/features/qt_config.prf | 2 +- qmake/project.cpp | 13 +++++++++---- src/3rdparty/webkit/WebCore/WebCore.pro | 2 +- src/corelib/arch/arch.pri | 2 +- src/qbase.pri | 2 +- src/xmlpatterns/query.pri | 2 +- src/xmlpatterns/xmlpatterns.pro | 2 +- tests/auto/qaccessibility_mac/qaccessibility_mac.pro | 2 +- tests/auto/qmake/testdata/functions/functions.pro | 2 +- tools/assistant/compat/lib/lib.pro | 2 +- tools/designer/src/components/lib/lib.pro | 2 +- tools/designer/src/lib/lib.pro | 2 +- tools/designer/src/uitools/uitools.pro | 2 +- 13 files changed, 21 insertions(+), 16 deletions(-) diff --git a/mkspecs/features/qt_config.prf b/mkspecs/features/qt_config.prf index 779c2e5..0a2d985 100644 --- a/mkspecs/features/qt_config.prf +++ b/mkspecs/features/qt_config.prf @@ -4,7 +4,7 @@ isEmpty(QMAKE_QT_CONFIG)|!exists($$QMAKE_QT_CONFIG) { else:exists($$_QMAKE_CACHE_):infile($$_QMAKE_CACHE_, QT_BUILD_TREE):QMAKE_QT_CONFIG = $$fromfile($$_QMAKE_CACHE_, QT_BUILD_TREE)/mkspecs/qconfig.pri else:exists($$[QT_INSTALL_DATA]/mkspecs/qconfig.pri):QMAKE_QT_CONFIG = $$[QT_INSTALL_DATA]/mkspecs/qconfig.pri } -!exists($$QMAKE_QT_CONFIG)|!include($$QMAKE_QT_CONFIG) { +!exists($$QMAKE_QT_CONFIG)|!include($$QMAKE_QT_CONFIG, "", true) { debug(1, "Cannot load qconfig.pri!") } else { debug(1, "Loaded .qconfig.pri from ($$QMAKE_QT_CONFIG)") diff --git a/qmake/project.cpp b/qmake/project.cpp index 4fefbab..6687e9a 100644 --- a/qmake/project.cpp +++ b/qmake/project.cpp @@ -2693,10 +2693,15 @@ QMakeProject::doProjectTest(QString func, QList args_list, QMap= 2) { if(func_t == T_INCLUDE) { parseInto = args[1]; + if (args.count() == 3){ + QString sarg = args[2]; + if (sarg.toLower() == "true" || sarg.toInt()) + ignore_error = true; + } } else { QString sarg = args[1]; ignore_error = (sarg.toLower() == "true" || sarg.toInt()); @@ -2738,8 +2743,8 @@ QMakeProject::doProjectTest(QString func, QList args_list, QMap= IncludeFailure) { diff --git a/src/3rdparty/webkit/WebCore/WebCore.pro b/src/3rdparty/webkit/WebCore/WebCore.pro index e49ab13..2eb7c08 100644 --- a/src/3rdparty/webkit/WebCore/WebCore.pro +++ b/src/3rdparty/webkit/WebCore/WebCore.pro @@ -3159,7 +3159,7 @@ xpathbison.dependency_type = TYPE_C xpathbison.variable_out = GENERATED_SOURCES addExtraCompilerWithHeader(xpathbison) -include($$PWD/../WebKit/qt/Api/headers.pri) +include($$PWD/../WebKit/qt/Api/headers.pri, "", true) HEADERS += $$WEBKIT_API_HEADERS !CONFIG(QTDIR_build) { target.path = $$[QT_INSTALL_LIBS] diff --git a/src/corelib/arch/arch.pri b/src/corelib/arch/arch.pri index dd3141a..18f54ee 100644 --- a/src/corelib/arch/arch.pri +++ b/src/corelib/arch/arch.pri @@ -25,4 +25,4 @@ vxworks:HEADERS += arch/qatomic_vxworks.h QT_ARCH_CPP = $$QT_SOURCE_TREE/src/corelib/arch/$$QT_ARCH DEPENDPATH += $$QT_ARCH_CPP -include($$QT_ARCH_CPP/arch.pri) +include($$QT_ARCH_CPP/arch.pri, "", true) diff --git a/src/qbase.pri b/src/qbase.pri index 0ab04e6..9e2d26f 100644 --- a/src/qbase.pri +++ b/src/qbase.pri @@ -13,7 +13,7 @@ mac:!contains(QMAKE_EXT_C, .mm):QMAKE_EXT_C += .mm #load up the headers info CONFIG += qt_install_headers HEADERS_PRI = $$QT_BUILD_TREE/include/$$TARGET/headers.pri -include($$HEADERS_PRI)|clear(HEADERS_PRI) +include($$HEADERS_PRI, "", true)|clear(HEADERS_PRI) #version overriding win32 { diff --git a/src/xmlpatterns/query.pri b/src/xmlpatterns/query.pri index e09a618..fab1940 100644 --- a/src/xmlpatterns/query.pri +++ b/src/xmlpatterns/query.pri @@ -11,4 +11,4 @@ include($$PWD/parser/parser.pri) include($$PWD/projection/projection.pri) include($$PWD/type/type.pri) include($$PWD/utils/utils.pri) -include($$PWD/qobjectmodel/qobjectmodel.pri) +include($$PWD/qobjectmodel/qobjectmodel.pri, "", true) diff --git a/src/xmlpatterns/xmlpatterns.pro b/src/xmlpatterns/xmlpatterns.pro index fb6aa1a..0e6270e 100644 --- a/src/xmlpatterns/xmlpatterns.pro +++ b/src/xmlpatterns/xmlpatterns.pro @@ -25,7 +25,7 @@ include($$PWD/schema/schema.pri) include($$PWD/schematron/schematron.pri) include($$PWD/type/type.pri) include($$PWD/utils/utils.pri) -include($$PWD/qobjectmodel/qobjectmodel.pri) +include($$PWD/qobjectmodel/qobjectmodel.pri, "", true) wince*: { # The Microsoft MIPS compiler crashes if /Og is specified diff --git a/tests/auto/qaccessibility_mac/qaccessibility_mac.pro b/tests/auto/qaccessibility_mac/qaccessibility_mac.pro index b32a7e5..47f72d1 100644 --- a/tests/auto/qaccessibility_mac/qaccessibility_mac.pro +++ b/tests/auto/qaccessibility_mac/qaccessibility_mac.pro @@ -11,7 +11,7 @@ requires(mac) # builds (where QTDIR points to the build directory). # autotest + shadow build is not supported :) exists($$(QTDIR)/tools/designer/src/lib/uilib/uilib.pri) { - include($$(QTDIR)/tools/designer/src/lib/uilib/uilib.pri) + include($$(QTDIR)/tools/designer/src/lib/uilib/uilib.pri, "", true) INCLUDEPATH += $$(QTDIR)/tools/designer/src/uitools SOURCES += $$(QTDIR)/tools/designer/src/uitools/quiloader.cpp HEADERS += $$(QTDIR)/tools/designer/src/uitools/quiloader.h diff --git a/tests/auto/qmake/testdata/functions/functions.pro b/tests/auto/qmake/testdata/functions/functions.pro index 9ed92f96..5e089e4 100644 --- a/tests/auto/qmake/testdata/functions/functions.pro +++ b/tests/auto/qmake/testdata/functions/functions.pro @@ -46,7 +46,7 @@ isEmpty( CONFIG ) { } #include -include( infiletest.pro ) +include( infiletest.pro, "", true ) !contains( DEFINES, QT_DLL ) { message( "FAILED: include function: $$DEFINES" ) } diff --git a/tools/assistant/compat/lib/lib.pro b/tools/assistant/compat/lib/lib.pro index d4b5a47..e50d470 100644 --- a/tools/assistant/compat/lib/lib.pro +++ b/tools/assistant/compat/lib/lib.pro @@ -32,7 +32,7 @@ contains(CONFIG, static) { #load up the headers info CONFIG += qt_install_headers HEADERS_PRI = $$QT_BUILD_TREE/include/QtAssistant/headers.pri -include($$HEADERS_PRI)|clear(HEADERS_PRI) +include($$HEADERS_PRI, "", true)|clear(HEADERS_PRI) #mac frameworks mac:!static:contains(QT_CONFIG, qt_framework) { diff --git a/tools/designer/src/components/lib/lib.pro b/tools/designer/src/components/lib/lib.pro index 4515b66..92cf387 100644 --- a/tools/designer/src/components/lib/lib.pro +++ b/tools/designer/src/components/lib/lib.pro @@ -24,7 +24,7 @@ QMAKE_TARGET_DESCRIPTION = Graphical user interface designer. #load up the headers info CONFIG += qt_install_headers HEADERS_PRI = $$QT_BUILD_TREE/include/QtDesigner/headers.pri -include($$HEADERS_PRI)|clear(HEADERS_PRI) +include($$HEADERS_PRI, "", true)|clear(HEADERS_PRI) #mac frameworks mac:!static:contains(QT_CONFIG, qt_framework) { diff --git a/tools/designer/src/lib/lib.pro b/tools/designer/src/lib/lib.pro index e0f2f23..495976d 100644 --- a/tools/designer/src/lib/lib.pro +++ b/tools/designer/src/lib/lib.pro @@ -34,7 +34,7 @@ QMAKE_TARGET_DESCRIPTION = Graphical user interface designer. #load up the headers info CONFIG += qt_install_headers HEADERS_PRI = $$QT_BUILD_TREE/include/QtDesigner/headers.pri -include($$HEADERS_PRI)|clear(HEADERS_PRI) +include($$HEADERS_PRI, "", true)|clear(HEADERS_PRI) #mac frameworks mac:CONFIG += explicitlib diff --git a/tools/designer/src/uitools/uitools.pro b/tools/designer/src/uitools/uitools.pro index a20abf0..34e4877 100644 --- a/tools/designer/src/uitools/uitools.pro +++ b/tools/designer/src/uitools/uitools.pro @@ -22,7 +22,7 @@ include(../lib/uilib/uilib.pri) HEADERS += quiloader.h SOURCES += quiloader.cpp -include($$QT_BUILD_TREE/include/QtUiTools/headers.pri) +include($$QT_BUILD_TREE/include/QtUiTools/headers.pri, "", true) quitools_headers.files = $$SYNCQT.HEADER_FILES $$SYNCQT.HEADER_CLASSES quitools_headers.path = $$[QT_INSTALL_HEADERS]/QtUiTools INSTALLS += quitools_headers -- cgit v0.12 From 2be387f3e94f84cf0167cdc3871de0d0af85c62d Mon Sep 17 00:00:00 2001 From: David Faure Date: Mon, 10 Aug 2009 09:37:18 +0200 Subject: Make QTimeLine::start() restart from the beginning as the documentation says. The documentation implies that start restarts. Which it did, but only if the timeline was finished _and_ the duration hadn't been changed meanwhile. So after a setDuration(), start() would do nothing, which was unexpected. Merge-request: 1145 Reviewed-by: Olivier Goffart --- src/corelib/tools/qtimeline.cpp | 9 ++++---- tests/auto/qtimeline/tst_qtimeline.cpp | 41 +++++++++++++++++++++++++++++++++- 2 files changed, 44 insertions(+), 6 deletions(-) diff --git a/src/corelib/tools/qtimeline.cpp b/src/corelib/tools/qtimeline.cpp index e32fc03..7402ba6 100644 --- a/src/corelib/tools/qtimeline.cpp +++ b/src/corelib/tools/qtimeline.cpp @@ -663,6 +663,7 @@ qreal QTimeLine::valueForTime(int msec) const second). You can change the update interval by calling setUpdateInterval(). + The timeline will start from position 0, or the end if going backward. If you want to resume a stopped timeline without restarting, you can call resume() instead. @@ -675,10 +676,8 @@ void QTimeLine::start() qWarning("QTimeLine::start: already running"); return; } - int curTime = d->currentTime; - if (curTime == d->duration && d->direction == Forward) - curTime = 0; - else if (curTime == 0 && d->direction == Backward) + int curTime = 0; + if (d->direction == Backward) curTime = d->duration; d->timerId = startTimer(d->updateInterval); d->startTime = curTime; @@ -694,7 +693,7 @@ void QTimeLine::start() frame and value at regular intervals. In contrast to start(), this function does not restart the timeline before - is resumes. + it resumes. \sa start(), updateInterval(), frameChanged(), valueChanged() */ diff --git a/tests/auto/qtimeline/tst_qtimeline.cpp b/tests/auto/qtimeline/tst_qtimeline.cpp index e6e75ff..4ce1f4b 100644 --- a/tests/auto/qtimeline/tst_qtimeline.cpp +++ b/tests/auto/qtimeline/tst_qtimeline.cpp @@ -81,6 +81,7 @@ private slots: void outOfRange(); void stateInFinishedSignal(); void resume(); + void restart(); protected slots: void finishedSlot(); @@ -177,7 +178,7 @@ void tst_QTimeLine::currentTime() QCOMPARE(spy.count(), 1); spy.clear(); QCOMPARE(timeLine.currentTime(), timeLine.duration()/2); - timeLine.start(); + timeLine.resume(); // Let it update on its own QTest::qWait(timeLine.duration()/4); QCOMPARE(timeLine.state(), QTimeLine::Running); @@ -699,5 +700,43 @@ void tst_QTimeLine::resume() } } +void tst_QTimeLine::restart() +{ + QTimeLine timeLine(100); + timeLine.setFrameRange(0,9); + + timeLine.start(); + QTest::qWait(timeLine.duration()*2); + QCOMPARE(timeLine.currentFrame(), timeLine.endFrame()); + QCOMPARE(timeLine.state(), QTimeLine::NotRunning); + + // A restart with the same duration + timeLine.start(); + QCOMPARE(timeLine.state(), QTimeLine::Running); + QCOMPARE(timeLine.currentFrame(), timeLine.startFrame()); + QCOMPARE(timeLine.currentTime(), 0); + QTest::qWait(250); + QCOMPARE(timeLine.currentFrame(), timeLine.endFrame()); + QCOMPARE(timeLine.state(), QTimeLine::NotRunning); + + // Set a smaller duration and restart + timeLine.setDuration(50); + timeLine.start(); + QCOMPARE(timeLine.state(), QTimeLine::Running); + QCOMPARE(timeLine.currentFrame(), timeLine.startFrame()); + QCOMPARE(timeLine.currentTime(), 0); + QTest::qWait(250); + QCOMPARE(timeLine.currentFrame(), timeLine.endFrame()); + QCOMPARE(timeLine.state(), QTimeLine::NotRunning); + + // Set a longer duration and restart + timeLine.setDuration(150); + timeLine.start(); + QCOMPARE(timeLine.state(), QTimeLine::Running); + QCOMPARE(timeLine.currentFrame(), timeLine.startFrame()); + QCOMPARE(timeLine.currentTime(), 0); +} + QTEST_MAIN(tst_QTimeLine) + #include "tst_qtimeline.moc" -- cgit v0.12 From 7aa2d76dfc4a107f38c5cb0aac00a0b31d0fbbb6 Mon Sep 17 00:00:00 2001 From: Morten Sorvig Date: Mon, 10 Aug 2009 10:14:12 +0200 Subject: Add QBENCMARK_ONCE to QTestLib. The code block associated with QBENCHMARK_ONCE macro will only be executed once, whether the backend returns a valid result or not. The "-iterations" command line argument is also ignored. This is useful for benchmarking code that has side effects. Revby: jasplin --- src/testlib/qbenchmark.cpp | 13 +++++++++++-- src/testlib/qbenchmark.h | 10 ++++++++-- src/testlib/qbenchmark_p.h | 1 + src/testlib/qtestcase.cpp | 19 +++++++++++++++++++ .../benchlibwalltime/tst_benchlibwalltime.cpp | 11 +++++++++++ tests/auto/selftests/expected_benchlibwalltime.txt | 5 ++++- 6 files changed, 54 insertions(+), 5 deletions(-) diff --git a/src/testlib/qbenchmark.cpp b/src/testlib/qbenchmark.cpp index 9cdf232..bad3379 100644 --- a/src/testlib/qbenchmark.cpp +++ b/src/testlib/qbenchmark.cpp @@ -116,7 +116,7 @@ int QBenchmarkGlobalData::adjustMedianIterationCount() QBenchmarkTestMethodData *QBenchmarkTestMethodData::current; QBenchmarkTestMethodData::QBenchmarkTestMethodData() -:resultAccepted(false), iterationCount(-1) +:resultAccepted(false), runOnce(false), iterationCount(-1) { } @@ -157,6 +157,11 @@ void QBenchmarkTestMethodData::setResult(qint64 value) if (QBenchmarkGlobalData::current->iterationCount != -1) accepted = true; + if (QBenchmarkTestMethodData::current->runOnce) { + iterationCount = 1; + accepted = true; + } + // Test the result directly without calling the measurer if the minimum time // has been specifed on the command line with -minimumvalue. else if (QBenchmarkGlobalData::current->walltimeMinimum != -1) @@ -179,10 +184,12 @@ void QBenchmarkTestMethodData::setResult(qint64 value) drive the benchmarking loop. It is repsonsible for starting and stopping the timing measurements as well as calling the result reporting functions. */ -QTest::QBenchmarkIterationController::QBenchmarkIterationController() +QTest::QBenchmarkIterationController::QBenchmarkIterationController(RunMode runMode) { QTest::beginBenchmarkMeasurement(); i = 0; + if (runMode == RunOnce) + QBenchmarkTestMethodData::current->runOnce = true; } /*! \internal */ @@ -195,6 +202,8 @@ QTest::QBenchmarkIterationController::~QBenchmarkIterationController() */ bool QTest::QBenchmarkIterationController::isDone() { + if (QBenchmarkTestMethodData::current->runOnce) + return i > 0; return i >= QTest::iterationCount(); } diff --git a/src/testlib/qbenchmark.h b/src/testlib/qbenchmark.h index c06bfc0..87d34e7 100644 --- a/src/testlib/qbenchmark.h +++ b/src/testlib/qbenchmark.h @@ -64,7 +64,8 @@ namespace QTest class Q_TESTLIB_EXPORT QBenchmarkIterationController { public: - QBenchmarkIterationController(); + enum RunMode { RepeatUntilValidMeasurement, RunOnce }; + QBenchmarkIterationController(RunMode runMode); ~QBenchmarkIterationController(); bool isDone(); void next(); @@ -74,7 +75,12 @@ public: } #define QBENCHMARK \ - for (QTest::QBenchmarkIterationController __iteration_controller; __iteration_controller.isDone() == false; __iteration_controller.next()) + for (QTest::QBenchmarkIterationController __iteration_controller(QTest::QBenchmarkIterationController::RepeatUntilValidMeasurement); \ + __iteration_controller.isDone() == false; __iteration_controller.next()) + +#define QBENCHMARK_ONCE \ + for (QTest::QBenchmarkIterationController __iteration_controller(QTest::QBenchmarkIterationController::RunOnce); \ + __iteration_controller.isDone() == false; __iteration_controller.next()) QT_END_NAMESPACE diff --git a/src/testlib/qbenchmark_p.h b/src/testlib/qbenchmark_p.h index 25f9cdc..185d656 100644 --- a/src/testlib/qbenchmark_p.h +++ b/src/testlib/qbenchmark_p.h @@ -171,6 +171,7 @@ public: QBenchmarkResult result; bool resultAccepted; + bool runOnce; int iterationCount; }; diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 1866197..21a686e 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -351,6 +351,25 @@ QT_BEGIN_NAMESPACE {Chapter 5: Writing a Benchmark}{Writing a Benchmark} */ +/*! + \macro QBENCHMARK_ONCE + + \relates QTest + + This macro is used to measure the performance of code within a test. + The code to be benchmarked is contained within a code block following + this macro. + + Unlike QBENCHMARK, the contents of the contained code block is only run + once. The elapsed time will be reported as "0" if it's to short to + be measured by the selected backend. (Use) + + \sa {QTestLib Manual#Creating a Benchmark}{Creating a Benchmark}, + {Chapter 5: Writing a Benchmark}{Writing a Benchmark} +*/ + + + /*! \enum QTest::SkipMode This enum describes the modes for skipping tests during execution diff --git a/tests/auto/selftests/benchlibwalltime/tst_benchlibwalltime.cpp b/tests/auto/selftests/benchlibwalltime/tst_benchlibwalltime.cpp index de65599..8474144f 100644 --- a/tests/auto/selftests/benchlibwalltime/tst_benchlibwalltime.cpp +++ b/tests/auto/selftests/benchlibwalltime/tst_benchlibwalltime.cpp @@ -50,6 +50,7 @@ class tst_BenchlibWalltime: public QObject private slots: void waitForOneThousand(); void waitForFourThousand(); + void qbenchmark_once(); }; void tst_BenchlibWalltime::waitForOneThousand() @@ -66,6 +67,16 @@ void tst_BenchlibWalltime::waitForFourThousand() } } +void tst_BenchlibWalltime::qbenchmark_once() +{ + int iterations = 0; + QBENCHMARK_ONCE { + ++iterations; + } + QCOMPARE(iterations, 1); +} + + QTEST_MAIN(tst_BenchlibWalltime) #include "tst_benchlibwalltime.moc" diff --git a/tests/auto/selftests/expected_benchlibwalltime.txt b/tests/auto/selftests/expected_benchlibwalltime.txt index 03f2465..ec2d020 100644 --- a/tests/auto/selftests/expected_benchlibwalltime.txt +++ b/tests/auto/selftests/expected_benchlibwalltime.txt @@ -7,6 +7,9 @@ PASS : tst_BenchlibWalltime::waitForOneThousand() RESULT : tst_BenchlibWalltime::waitForFourThousand(): 4,000 msec per iteration (total: 4000, iterations: 1) PASS : tst_BenchlibWalltime::waitForFourThousand() +RESULT : tst_BenchlibWalltime::qbenchmark_once(): + 0 msec per iteration (total: 0, iterations: 1) +PASS : tst_BenchlibWalltime::qbenchmark_once() PASS : tst_BenchlibWalltime::cleanupTestCase() -Totals: 4 passed, 0 failed, 0 skipped +Totals: 5 passed, 0 failed, 0 skipped ********* Finished testing of tst_BenchlibWalltime ********* -- cgit v0.12 From 76b8707e813c4b139a9ebd38b5ae0585d4afc425 Mon Sep 17 00:00:00 2001 From: hjk Date: Fri, 24 Jul 2009 11:59:07 +0200 Subject: Remove spurious paranthesis in container docs --- doc/src/containers.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/containers.qdoc b/doc/src/containers.qdoc index 11a4b0b..2a34716 100644 --- a/doc/src/containers.qdoc +++ b/doc/src/containers.qdoc @@ -682,7 +682,7 @@ \header \o{1,2} \o{2,1} Key lookup \o{2,1} Insertion \header \o Average \o Worst case \o Average \o Worst case \row \o QMap \o O(log \e n) \o O(log \e n) \o O(log \e n) \o O(log \e n) - \row \o QMultiMap \o O((log \e n) \o O(log \e n) \o O(log \e n) \o O(log \e n) + \row \o QMultiMap \o O(log \e n) \o O(log \e n) \o O(log \e n) \o O(log \e n) \row \o QHash \o Amort. O(1) \o O(\e n) \o Amort. O(1) \o O(\e n) \row \o QSet \o Amort. O(1) \o O(\e n) \o Amort. O(1) \o O(\e n) \endtable -- cgit v0.12 From f0495e760e1e942481b8e0371b2700fd78519bb8 Mon Sep 17 00:00:00 2001 From: Peter Hartmann Date: Mon, 10 Aug 2009 10:57:45 +0200 Subject: Xml patterns: remove line in .pro file that added the schematron dir this line was dragged in from the Xml schema branch, but there is no schematron in Qt. Reviewed-by: TrustMe --- src/xmlpatterns/xmlpatterns.pro | 1 - 1 file changed, 1 deletion(-) diff --git a/src/xmlpatterns/xmlpatterns.pro b/src/xmlpatterns/xmlpatterns.pro index 0e6270e..bb8e452 100644 --- a/src/xmlpatterns/xmlpatterns.pro +++ b/src/xmlpatterns/xmlpatterns.pro @@ -22,7 +22,6 @@ include($$PWD/janitors/janitors.pri) include($$PWD/parser/parser.pri) include($$PWD/projection/projection.pri) include($$PWD/schema/schema.pri) -include($$PWD/schematron/schematron.pri) include($$PWD/type/type.pri) include($$PWD/utils/utils.pri) include($$PWD/qobjectmodel/qobjectmodel.pri, "", true) -- cgit v0.12 From 89f0156b21b4cff8fec0cee283d75f413cf36c61 Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Mon, 10 Aug 2009 11:10:03 +0200 Subject: Link with winscw again compiler mangles "struct" and "class" differently, so make sure that QTestCharBuffer is always forward declared as "struct". --- src/testlib/qtestbasicstreamer.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/testlib/qtestbasicstreamer.h b/src/testlib/qtestbasicstreamer.h index cabbf34..932f5c3 100644 --- a/src/testlib/qtestbasicstreamer.h +++ b/src/testlib/qtestbasicstreamer.h @@ -53,7 +53,7 @@ QT_MODULE(Test) class QTestElement; class QTestElementAttribute; class QTestLogger; -class QTestCharBuffer; +struct QTestCharBuffer; class QTestBasicStreamer { -- cgit v0.12 From 167b333e2c428947264f283f6eec275b27f8f0db Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Mon, 10 Aug 2009 11:21:48 +0200 Subject: Fix default QWidget size on X servers with Xinerama The default widget size is normally calculated from the root window size, but when running on an X server with Xinerama enabled, the root window spans all screens, making the widget far to large. Use the default screen's size instead to give the widget a size that should fit on a single screen. --- src/gui/kernel/qwidget_x11.cpp | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/gui/kernel/qwidget_x11.cpp b/src/gui/kernel/qwidget_x11.cpp index 2a3d2f3..cf65af3 100644 --- a/src/gui/kernel/qwidget_x11.cpp +++ b/src/gui/kernel/qwidget_x11.cpp @@ -512,6 +512,13 @@ void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyO dialog = popup = false; // force these flags off data.crect.setRect(0, 0, sw, sh); } else if (topLevel && !q->testAttribute(Qt::WA_Resized)) { + QDesktopWidget *desktopWidget = qApp->desktop(); + if (desktopWidget->isVirtualDesktop()) { + QRect r = desktopWidget->screenGeometry(); + sw = r.width(); + sh = r.height(); + } + int width = sw / 2; int height = 4 * sh / 10; if (extra) { -- cgit v0.12 From 468b157ab5496cdab6ff751312dba5376901d533 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Mon, 10 Aug 2009 12:47:31 +0200 Subject: Whitespace cleanup --- src/corelib/tools/qtimeline.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/corelib/tools/qtimeline.cpp b/src/corelib/tools/qtimeline.cpp index 7402ba6..b6511d5 100644 --- a/src/corelib/tools/qtimeline.cpp +++ b/src/corelib/tools/qtimeline.cpp @@ -212,7 +212,7 @@ void QTimeLinePrivate::setCurrentTime(int msecs) applies an interpolation algorithm to generate these value. You can choose from a set of predefined timeline algorithms by calling setCurveShape(). - + Note that by default, QTimeLine uses the EaseInOut curve shape, which provides a value that grows slowly, then grows steadily, and finally grows slowly. For a custom timeline, you can reimplement @@ -549,7 +549,7 @@ void QTimeLine::setCurveShape(CurveShape shape) case CosineCurve: setEasingCurve(QEasingCurve(QEasingCurve::CosineCurve)); break; - } + } } /*! @@ -559,7 +559,7 @@ void QTimeLine::setCurveShape(CurveShape shape) Specifies the easing curve that the timeline will use. If both easing curve and curveShape are set, the last set property will - override the previous one. (If valueForTime() is reimplemented it will + override the previous one. (If valueForTime() is reimplemented it will override both) */ -- cgit v0.12 From ec1a146dd7f8582d3053ed54420d26141e98155c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jan-Arve=20S=C3=A6ther?= Date: Mon, 10 Aug 2009 12:48:13 +0200 Subject: Remove unused member. --- src/corelib/tools/qtimeline.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/corelib/tools/qtimeline.cpp b/src/corelib/tools/qtimeline.cpp index b6511d5..6dbad34 100644 --- a/src/corelib/tools/qtimeline.cpp +++ b/src/corelib/tools/qtimeline.cpp @@ -69,7 +69,6 @@ public: int currentLoopCount; int currentTime; - int elapsedTime; int timerId; QTime timer; -- cgit v0.12 From 17bffacda99055831bb4c8c6e7da39ec15415519 Mon Sep 17 00:00:00 2001 From: Leonardo Sobral Cunha Date: Mon, 10 Aug 2009 13:01:34 +0200 Subject: Moved tests/auto/runQtXmlPatternsTests.sh to devtools/shell --- tests/auto/runQtXmlPatternsTests.sh | 61 ------------------------------------- 1 file changed, 61 deletions(-) delete mode 100755 tests/auto/runQtXmlPatternsTests.sh diff --git a/tests/auto/runQtXmlPatternsTests.sh b/tests/auto/runQtXmlPatternsTests.sh deleted file mode 100755 index 41d6c83..0000000 --- a/tests/auto/runQtXmlPatternsTests.sh +++ /dev/null @@ -1,61 +0,0 @@ -#!/bin/sh -# Runs all the tests specific to QtXmlPatterns in one go. - -# If you add a test, remember to update ./auto.pro too. -# checkxmlfiles is not part of Patternist, but since it shares test code -# and use Patternist, we include it as well. -# -# Sorted alphabetically, with the difference that xmlpatternsxqts appears -# before xmlpattersview, xmlpatternsdiagnosticsts, and xmlpatternsxslts, since -# they have the former as dependency. -tests=" \ -checkxmlfiles \ -patternistexamplefiletree \ -patternistexamples \ -patternistheaders \ -qabstractmessagehandler \ -qabstracturiresolver \ -qabstractxmlforwarditerator \ -qabstractxmlnodemodel \ -qabstractxmlreceiver \ -qapplicationargumentparser \ -qautoptr \ -qsimplexmlnodemodel \ -qsourcelocation \ -qtokenautomaton \ -qxmlformatter \ -qxmlitem \ -qxmlname \ -qxmlnamepool \ -qxmlnodemodelindex \ -qxmlquery \ -qxmlresultitems \ -qxmlserializer \ -xmlpatterns \ -xmlpatternsxqts \ -xmlpatternsdiagnosticsts \ -xmlpatternsschema \ -xmlpatternsschemats \ -xmlpatternsview \ -xmlpatternsxslts" - -os=`uname` - -for test in $tests; do - cd $test - make distclean - qmake - make - - if [ $os = "Darwin" ]; then - ./tst_"$test".app/Contents/MacOS/tst_"$test" - else - ./tst_$test - fi - - if [ $? -ne 0 ]; then - exit $? - else - cd .. - fi -done -- cgit v0.12