From 5a4877c5cb3cce096aafed5eab619c44b660901b Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Wed, 12 Aug 2009 13:34:41 +0200 Subject: fixing warnings for qreal=float Reviewed-by: Joerg --- src/gui/painting/qtransform.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/gui/painting/qtransform.cpp b/src/gui/painting/qtransform.cpp index b6d784239..8832a3dd6 100644 --- a/src/gui/painting/qtransform.cpp +++ b/src/gui/painting/qtransform.cpp @@ -81,7 +81,7 @@ QT_BEGIN_NAMESPACE ny = affine._m12 * FX_ + affine._m22 * FY_ + affine._dy; \ if (t == TxProject) { \ qreal w = (m_13 * FX_ + m_23 * FY_ + m_33); \ - if (w < Q_NEAR_CLIP) w = Q_NEAR_CLIP; \ + if (w < qreal(Q_NEAR_CLIP)) w = qreal(Q_NEAR_CLIP); \ w = 1./w; \ nx *= w; \ ny *= w; \ -- cgit v1.2.3 From 4747765bc41fbe3c1ead61693a86b280601dda6e Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 12 Aug 2009 13:57:25 +0200 Subject: Fix import of WebKit. Don't try to remove WebCore/svg/graphics/wince, it doesn't exist anymore. Reviewed-by: Trust me --- util/webkit/mkdist-webkit | 1 - 1 file changed, 1 deletion(-) diff --git a/util/webkit/mkdist-webkit b/util/webkit/mkdist-webkit index c601f76f2..5550cf8eb 100755 --- a/util/webkit/mkdist-webkit +++ b/util/webkit/mkdist-webkit @@ -133,7 +133,6 @@ excluded_directories="$excluded_directories WebCore/accessibility/win" excluded_directories="$excluded_directories WebCore/accessibility/wx" excluded_directories="$excluded_directories WebCore/storage/wince" -excluded_directories="$excluded_directories WebCore/svg/graphics/wince" excluded_directories="$excluded_directories WebCore/platform/wx" excluded_directories="$excluded_directories WebKit/gtk" -- cgit v1.2.3 From 4cf8deb5da96b00a3b89c5c328aab3d47e1dfbb3 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Wed, 12 Aug 2009 14:19:15 +0200 Subject: qdoc: Added google CSE to each page. Task-number: 258950 --- tools/qdoc3/test/qt-html-templates.qdocconf | 29 ++++++++++++++++++----------- 1 file changed, 18 insertions(+), 11 deletions(-) diff --git a/tools/qdoc3/test/qt-html-templates.qdocconf b/tools/qdoc3/test/qt-html-templates.qdocconf index e4e60dc97..c18e4f0f9 100644 --- a/tools/qdoc3/test/qt-html-templates.qdocconf +++ b/tools/qdoc3/test/qt-html-templates.qdocconf @@ -8,20 +8,27 @@ HTML.postheader = "" \ "" \ "Home ·" \ - " " \ - "All Namespaces ·" \ - " " \ - "All Classes ·" \ - " " \ - "Main Classes ·" \ - " " \ - "Grouped Classes ·" \ " " \ "Modules ·" \ + " " \ + "Classes ·" \ " " \ - "Functions" \ - "\n" \ - "
" + "Functions ·" \ + " " \ + "Namespaces" \ + "" \ + "" \ + "
" \ + "
" \ + "" \ + "" \ + "" \ + "" \ + "
" \ + "
" \ + "" \ + "\n" \ + "" HTML.footer = "


\n" \ "\n" \ -- cgit v1.2.3 From 657de489549bab1f9d2ba759739dd55f65a8532e Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Wed, 12 Aug 2009 14:19:15 +0200 Subject: Make QPropertyAnimation symetric wrt direction It is now possible to set a start value and no end value and starting the animation will pick the default end value from the current value of the property that's being animated. --- src/corelib/animation/qvariantanimation.cpp | 77 +++++++++++----------- src/corelib/animation/qvariantanimation_p.h | 1 - .../qpropertyanimation/tst_qpropertyanimation.cpp | 42 ++++++++++++ 3 files changed, 81 insertions(+), 39 deletions(-) diff --git a/src/corelib/animation/qvariantanimation.cpp b/src/corelib/animation/qvariantanimation.cpp index 61321c89a..04e09806a 100644 --- a/src/corelib/animation/qvariantanimation.cpp +++ b/src/corelib/animation/qvariantanimation.cpp @@ -178,8 +178,7 @@ template<> Q_INLINE_TEMPLATE QLineF _q_interpolate(const QLineF &f, const QLineF return QLineF( _q_interpolate(f.p1(), t.p1(), progress), _q_interpolate(f.p2(), t.p2(), progress)); } -QVariantAnimationPrivate::QVariantAnimationPrivate() : duration(250), hasStartValue(false), - interpolator(&defaultInterpolator), +QVariantAnimationPrivate::QVariantAnimationPrivate() : duration(250), interpolator(&defaultInterpolator), changedSignalMask(1 << QVariantAnimation::staticMetaObject.indexOfSignal("valueChanged(QVariant)")) { //we keep the mask so that we emit valueChanged only when needed (for performance reasons) @@ -222,34 +221,52 @@ void QVariantAnimationPrivate::updateInterpolator() void QVariantAnimationPrivate::recalculateCurrentInterval(bool force/*=false*/) { // can't interpolate if we have only 1 key value - if (keyValues.count() <= 1) + if ((keyValues.count() + (defaultStartValue.isValid() ? 1 : 0)) <=1) return; const qreal progress = easing.valueForProgress(((duration == 0) ? qreal(1) : qreal(currentTime) / qreal(duration))); if (force || progress < currentInterval.start.first || progress > currentInterval.end.first) { //let's update currentInterval - QVariantAnimation::KeyValues::const_iterator itStart = qLowerBound(keyValues.constBegin(), + QVariantAnimation::KeyValues::const_iterator it = qLowerBound(keyValues.constBegin(), keyValues.constEnd(), qMakePair(progress, QVariant()), animationValueLessThan); - QVariantAnimation::KeyValues::const_iterator itEnd = itStart; - - // If we are at the end we should continue to use the last keyValues in case of extrapolation (progress > 1.0). - // This is because the easing function can return a value slightly outside the range [0, 1] - if (itStart != keyValues.constEnd()) { - // this can't happen because we always prepend the default start value there - if (itStart == keyValues.constBegin()) { - ++itEnd; + if (it == keyValues.constEnd()) { + if (direction == QVariantAnimation::Backward && defaultStartValue.isValid()) { + --it; + if (it->first == 1) { + //we have an end value (item with progress = 1) + currentInterval.start = *(it-1); + currentInterval.end = *it; + } else if (direction == QVariantAnimation::Backward && defaultStartValue.isValid()) { + //the default start value should be used as the default end value + currentInterval.start = *it; + currentInterval.end = qMakePair(qreal(1), defaultStartValue); + } else { + ///This should not happen + } + } + } else if (it == keyValues.constBegin()) { + if (it->first == progress || it->first == 0) { + //the item pointed to by it is the start element in the range + //we also test if the current element is for progress 0 (ie the real start) because + //some easing curves might get the progress below 0. + currentInterval.start = *it; + currentInterval.end = *(it+1); + } else if (direction == QVariantAnimation::Forward && defaultStartValue.isValid()) { + currentInterval.start = qMakePair(qreal(0), defaultStartValue); + currentInterval.end = *it; } else { - --itStart; + ///this should not happen } - - // update all the values of the currentInterval - currentInterval.start = *itStart; - currentInterval.end = *itEnd; - updateInterpolator(); + } else { + currentInterval.start = *(it-1); + currentInterval.end = *it; } + + // update all the values of the currentInterval + updateInterpolator(); } setCurrentValueForProgress(progress); } @@ -298,8 +315,6 @@ void QVariantAnimationPrivate::setValueAt(qreal step, const QVariant &value) } else { if (value.isValid()) result->second = value; // replaces the previous value - else if (step == 0 && !hasStartValue && defaultStartValue.isValid()) - result->second = defaultStartValue; // resets to the default start value else keyValues.erase(result); // removes the previous value } @@ -310,8 +325,7 @@ void QVariantAnimationPrivate::setValueAt(qreal step, const QVariant &value) void QVariantAnimationPrivate::setDefaultStartValue(const QVariant &value) { defaultStartValue = value; - if (!hasStartValue) - setValueAt(0, value); + recalculateCurrentInterval(/*force=*/true); } /*! @@ -526,11 +540,7 @@ void QVariantAnimation::setEndValue(const QVariant &value) */ QVariant QVariantAnimation::keyValueAt(qreal step) const { - Q_D(const QVariantAnimation); - if (step == 0 && !d->hasStartValue) - return QVariant(); //special case where we don't have an explicit startValue - - return d->valueAt(step); + return d_func()->valueAt(step); } /*! @@ -552,10 +562,7 @@ QVariant QVariantAnimation::keyValueAt(qreal step) const */ void QVariantAnimation::setKeyValueAt(qreal step, const QVariant &value) { - Q_D(QVariantAnimation); - if (step == 0) - d->hasStartValue = value.isValid(); - d->setValueAt(step, value); + d_func()->setValueAt(step, value); } /*! @@ -565,12 +572,7 @@ void QVariantAnimation::setKeyValueAt(qreal step, const QVariant &value) */ QVariantAnimation::KeyValues QVariantAnimation::keyValues() const { - Q_D(const QVariantAnimation); - QVariantAnimation::KeyValues ret = d->keyValues; - //in case we added the default start value, we remove it - if (!d->hasStartValue && !ret.isEmpty() && ret.at(0).first == 0) - ret.remove(0); - return ret; + return d_func()->keyValues; } /*! @@ -584,7 +586,6 @@ void QVariantAnimation::setKeyValues(const KeyValues &keyValues) Q_D(QVariantAnimation); d->keyValues = keyValues; qSort(d->keyValues.begin(), d->keyValues.end(), animationValueLessThan); - d->hasStartValue = !d->keyValues.isEmpty() && d->keyValues.at(0).first == 0; d->recalculateCurrentInterval(/*force=*/true); } diff --git a/src/corelib/animation/qvariantanimation_p.h b/src/corelib/animation/qvariantanimation_p.h index dbfd956e5..9c9d25bde 100644 --- a/src/corelib/animation/qvariantanimation_p.h +++ b/src/corelib/animation/qvariantanimation_p.h @@ -84,7 +84,6 @@ public: QVariantAnimation::KeyValues keyValues; QVariant currentValue; QVariant defaultStartValue; - bool hasStartValue; //this is used to keep track of the KeyValue interval in which we currently are struct diff --git a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp index 6f49d8e10..5af6f39cd 100644 --- a/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp +++ b/tests/auto/qpropertyanimation/tst_qpropertyanimation.cpp @@ -102,6 +102,7 @@ private slots: void easingcurve_data(); void easingcurve(); void startWithoutStartValue(); + void startBackwardWithoutEndValue(); void playForwardBackward(); void interpolated(); void setStartEndValues_data(); @@ -582,6 +583,47 @@ void tst_QPropertyAnimation::startWithoutStartValue() QVERIFY(current <= 110); } +void tst_QPropertyAnimation::startBackwardWithoutEndValue() +{ + QObject o; + o.setProperty("ole", 42); + QCOMPARE(o.property("ole").toInt(), 42); + + QPropertyAnimation anim(&o, "ole"); + anim.setStartValue(100); + anim.setDirection(QAbstractAnimation::Backward); + + //we start without an end value + anim.start(); + QCOMPARE(anim.state(), QAbstractAnimation::Running); + QCOMPARE(o.property("ole").toInt(), 42); //the initial value + + QTest::qWait(100); + int current = anim.currentValue().toInt(); + //it is somewhere in the animation + QVERIFY(current > 42); + QVERIFY(current < 100); + + QTest::qWait(200); + QCOMPARE(anim.state(), QVariantAnimation::Stopped); + current = anim.currentValue().toInt(); + QCOMPARE(current, 100); + QCOMPARE(o.property("ole").toInt(), current); + + anim.setStartValue(110); + anim.start(); + current = anim.currentValue().toInt(); + // the default start value will reevaluate the current property + // and set it to the end value of the last iteration + QCOMPARE(current, 100); + QTest::qWait(100); + current = anim.currentValue().toInt(); + //it is somewhere in the animation + QVERIFY(current >= 100); + QVERIFY(current <= 110); +} + + void tst_QPropertyAnimation::playForwardBackward() { QObject o; -- cgit v1.2.3 From 573ba5ded65a83e75589152071bac182ca8bcda3 Mon Sep 17 00:00:00 2001 From: Simon Hausmann Date: Wed, 12 Aug 2009 14:02:37 +0200 Subject: Fix WebKit import from the trunk (part 2) Fix generation of WebKit version file by including the xcconfig file. Reviewed-by: Trust me --- util/webkit/mkdist-webkit | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/util/webkit/mkdist-webkit b/util/webkit/mkdist-webkit index 5550cf8eb..5c80e7347 100755 --- a/util/webkit/mkdist-webkit +++ b/util/webkit/mkdist-webkit @@ -137,7 +137,6 @@ excluded_directories="$excluded_directories WebCore/storage/wince" excluded_directories="$excluded_directories WebCore/platform/wx" excluded_directories="$excluded_directories WebKit/gtk" excluded_directories="$excluded_directories WebKit/win" -excluded_directories="$excluded_directories WebKit/mac" excluded_directories="$excluded_directories WebKit/wx" excluded_directories="$excluded_directories WebKit/cf" excluded_directories="$excluded_directories WebKit/haiku" @@ -147,6 +146,33 @@ excluded_directories="$excluded_directories WebCore/English.lproj" exclude_with_exceptions_list="WebCore/platform/win/:WebCore/platform/win/SystemTimeWin.cpp" +excluded_directories="$excluded_directories WebKit/mac/Carbon" +excluded_directories="$excluded_directories WebKit/mac/ChangeLog" +excluded_directories="$excluded_directories WebKit/mac/ChangeLog-2002-12-03" +excluded_directories="$excluded_directories WebKit/mac/ChangeLog-2006-02-09" +excluded_directories="$excluded_directories WebKit/mac/ChangeLog-2007-10-14" +excluded_directories="$excluded_directories WebKit/mac/DefaultDelegates" +excluded_directories="$excluded_directories WebKit/mac/DOM" +excluded_directories="$excluded_directories WebKit/mac/ForwardingHeaders" +excluded_directories="$excluded_directories WebKit/mac/History" +excluded_directories="$excluded_directories WebKit/mac/icu" +excluded_directories="$excluded_directories WebKit/mac/Info.plist" +excluded_directories="$excluded_directories WebKit/mac/MigrateHeaders.make" +excluded_directories="$excluded_directories WebKit/mac/Misc" +excluded_directories="$excluded_directories WebKit/mac/Panels" +excluded_directories="$excluded_directories WebKit/mac/Plugins" +excluded_directories="$excluded_directories WebKit/mac/PublicHeaderChangesFromTiger.txt" +excluded_directories="$excluded_directories WebKit/mac/Resources" +excluded_directories="$excluded_directories WebKit/mac/Storage" +excluded_directories="$excluded_directories WebKit/mac/WebCoreSupport" +excluded_directories="$excluded_directories WebKit/mac/WebInspector" +excluded_directories="$excluded_directories WebKit/mac/WebKit.exp" +excluded_directories="$excluded_directories WebKit/mac/WebKit.order" +excluded_directories="$excluded_directories WebKit/mac/WebKitPrefix.h" +excluded_directories="$excluded_directories WebKit/mac/WebView" + +exclude_with_exceptions_list="$exclude_with_exceptions_list WebKit/mac/Configurations/:WebKit/mac/Configurations/Version.xcconfig" + files_to_remove="" files_to_remove="$files_to_remove WebKit/qt/Api/qwebnetworkinterface.cpp" files_to_remove="$files_to_remove WebKit/qt/Api/qwebnetworkinterface.h" -- cgit v1.2.3 From 8059a73315e0a3a05eb0ff4281ebdda73a336150 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Wed, 12 Aug 2009 14:39:24 +0200 Subject: qdoc: Changed the scripts for the google search box Task-number: 258950 --- tools/qdoc3/test/qt-html-templates.qdocconf | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tools/qdoc3/test/qt-html-templates.qdocconf b/tools/qdoc3/test/qt-html-templates.qdocconf index c18e4f0f9..8c5bec5da 100644 --- a/tools/qdoc3/test/qt-html-templates.qdocconf +++ b/tools/qdoc3/test/qt-html-templates.qdocconf @@ -26,7 +26,12 @@ HTML.postheader = "
" \ "" \ "" \ - "" \ + \ + "" \ + "" \ + "" \ + \ + ""\ "\n" \ "
" -- cgit v1.2.3 From e7ae75aa315ee3e5ce465b1bcc878aeccea742c2 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Wed, 12 Aug 2009 14:42:51 +0200 Subject: don't test mouse over on Windows mobile in tst_QWidget::setToolTip Reviewed-by: mauricek --- tests/auto/qwidget/tst_qwidget.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tests/auto/qwidget/tst_qwidget.cpp b/tests/auto/qwidget/tst_qwidget.cpp index fc91b7498..34971a9e4 100644 --- a/tests/auto/qwidget/tst_qwidget.cpp +++ b/tests/auto/qwidget/tst_qwidget.cpp @@ -5827,7 +5827,9 @@ void tst_QWidget::setToolTip() QCOMPARE(widget.toolTip(), QString()); QCOMPARE(spy.count(), 2); - +#ifdef Q_OS_WINCE_WM + QSKIP("Mouse over doesn't work on Windows mobile.", SkipAll); +#endif for (int pass = 0; pass < 2; ++pass) { QWidget *popup = new QWidget(0, Qt::Popup); -- cgit v1.2.3 From e7e31867ed9857b17dbb4aa4e6cb06c93234be4f Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Wed, 12 Aug 2009 14:53:44 +0200 Subject: extern the Qt helper functions with Q_CORE_EXPORT The q* helper functions are declared as Q_CORE_EXPORT, so they have to be extern'd like that as well. This fixes a problem where adding a resource to a project would result in undefined symbols on some RVCT versions. Reviewed-by: Andy Shaw --- src/tools/rcc/rcc.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/tools/rcc/rcc.cpp b/src/tools/rcc/rcc.cpp index 3b877ae38..1d22decc4 100644 --- a/src/tools/rcc/rcc.cpp +++ b/src/tools/rcc/rcc.cpp @@ -894,10 +894,10 @@ bool RCCResourceLibrary::writeInitializer() if (m_useNameSpace) writeString("QT_BEGIN_NAMESPACE\n\n"); if (m_root) { - writeString("extern bool qRegisterResourceData\n " + writeString("extern Q_CORE_EXPORT bool qRegisterResourceData\n " "(int, const unsigned char *, " "const unsigned char *, const unsigned char *);\n\n"); - writeString("extern bool qUnregisterResourceData\n " + writeString("extern Q_CORE_EXPORT bool qUnregisterResourceData\n " "(int, const unsigned char *, " "const unsigned char *, const unsigned char *);\n\n"); } -- cgit v1.2.3 From 385f98c222154f3af402f2f3b13103add9cfa757 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Wed, 12 Aug 2009 14:56:19 +0200 Subject: oops: fix an issue when going backward and there is only 1 key value set --- src/corelib/animation/qvariantanimation.cpp | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/corelib/animation/qvariantanimation.cpp b/src/corelib/animation/qvariantanimation.cpp index 04e09806a..e64731819 100644 --- a/src/corelib/animation/qvariantanimation.cpp +++ b/src/corelib/animation/qvariantanimation.cpp @@ -248,15 +248,22 @@ void QVariantAnimationPrivate::recalculateCurrentInterval(bool force/*=false*/) } } } else if (it == keyValues.constBegin()) { - if (it->first == progress || it->first == 0) { + if (it+1 != keyValues.constEnd() && (it->first == progress || it->first == 0)) { //the item pointed to by it is the start element in the range //we also test if the current element is for progress 0 (ie the real start) because //some easing curves might get the progress below 0. currentInterval.start = *it; currentInterval.end = *(it+1); - } else if (direction == QVariantAnimation::Forward && defaultStartValue.isValid()) { - currentInterval.start = qMakePair(qreal(0), defaultStartValue); - currentInterval.end = *it; + } else if (defaultStartValue.isValid()) { + if (direction == QVariantAnimation::Forward) { + //we should have an end value + currentInterval.start = qMakePair(qreal(0), defaultStartValue); + currentInterval.end = *it; + } else { + //we should have a start value + currentInterval.start = *it; + currentInterval.end = qMakePair(qreal(1), defaultStartValue); + } } else { ///this should not happen } -- cgit v1.2.3 From fe5d0c32887b17a76c259bea951beaaaad675968 Mon Sep 17 00:00:00 2001 From: Kent Hansen Date: Wed, 12 Aug 2009 15:17:01 +0200 Subject: add some benchmarks for QScriptEngine and QScriptValue --- tests/benchmarks/qscriptengine/qscriptengine.pro | 7 + .../benchmarks/qscriptengine/tst_qscriptengine.cpp | 229 +++++++++++++++++++++ tests/benchmarks/qscriptvalue/qscriptvalue.pro | 7 + tests/benchmarks/qscriptvalue/tst_qscriptvalue.cpp | 193 +++++++++++++++++ 4 files changed, 436 insertions(+) create mode 100644 tests/benchmarks/qscriptengine/qscriptengine.pro create mode 100644 tests/benchmarks/qscriptengine/tst_qscriptengine.cpp create mode 100644 tests/benchmarks/qscriptvalue/qscriptvalue.pro create mode 100644 tests/benchmarks/qscriptvalue/tst_qscriptvalue.cpp diff --git a/tests/benchmarks/qscriptengine/qscriptengine.pro b/tests/benchmarks/qscriptengine/qscriptengine.pro new file mode 100644 index 000000000..22bbccd0a --- /dev/null +++ b/tests/benchmarks/qscriptengine/qscriptengine.pro @@ -0,0 +1,7 @@ +load(qttest_p4) +TEMPLATE = app +TARGET = tst_qscriptengine + +SOURCES += tst_qscriptengine.cpp + +QT += script diff --git a/tests/benchmarks/qscriptengine/tst_qscriptengine.cpp b/tests/benchmarks/qscriptengine/tst_qscriptengine.cpp new file mode 100644 index 000000000..81dedfac8 --- /dev/null +++ b/tests/benchmarks/qscriptengine/tst_qscriptengine.cpp @@ -0,0 +1,229 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +//TESTED_FILES= + +class tst_QScriptEngine : public QObject +{ + Q_OBJECT + +public: + tst_QScriptEngine(); + virtual ~tst_QScriptEngine(); + +public slots: + void init(); + void cleanup(); + +private slots: + void constructor(); + void evaluate_data(); + void evaluate(); + void connectAndDisconnect(); + void newObject(); + void newQObject(); + void newFunction(); + void newVariant(); + void collectGarbage(); + void pushAndPopContext(); + void toStringHandle(); + void castValueToQreal(); +}; + +tst_QScriptEngine::tst_QScriptEngine() +{ +} + +tst_QScriptEngine::~tst_QScriptEngine() +{ +} + +void tst_QScriptEngine::init() +{ +} + +void tst_QScriptEngine::cleanup() +{ +} + +void tst_QScriptEngine::constructor() +{ + QBENCHMARK { + QScriptEngine engine; + (void)engine.parent(); + } +} + +void tst_QScriptEngine::evaluate_data() +{ + QTest::addColumn("code"); + QTest::newRow("empty script") << QString::fromLatin1(""); + QTest::newRow("number literal") << QString::fromLatin1("123"); + QTest::newRow("string literal") << QString::fromLatin1("'ciao'"); + QTest::newRow("regexp literal") << QString::fromLatin1("/foo/gim"); + QTest::newRow("null literal") << QString::fromLatin1("null"); + QTest::newRow("undefined literal") << QString::fromLatin1("undefined"); + QTest::newRow("null literal") << QString::fromLatin1("null"); + QTest::newRow("empty object literal") << QString::fromLatin1("{}"); + QTest::newRow("this") << QString::fromLatin1("this"); + QTest::newRow("object literal with one property") << QString::fromLatin1("{ foo: 123 }"); + QTest::newRow("object literal with two properties") << QString::fromLatin1("{ foo: 123, bar: 456 }"); + QTest::newRow("object literal with many properties") << QString::fromLatin1("{ a: 1, b: 2, c: 3, d: 4, e: 5, f: 6, g: 7, h: 8, i: 9, j: 10 }"); + QTest::newRow("empty array literal") << QString::fromLatin1("[]"); + QTest::newRow("array literal with one element") << QString::fromLatin1("[1]"); + QTest::newRow("array literal with two elements") << QString::fromLatin1("[1,2]"); + QTest::newRow("array literal with many elements") << QString::fromLatin1("[1,2,3,4,5,6,7,8,9,10,9,8,7,6,5,4,3,2,1]"); + QTest::newRow("empty function definition") << QString::fromLatin1("function foo() { }"); + QTest::newRow("function definition") << QString::fromLatin1("function foo() { return 123; }"); + QTest::newRow("for loop with empty body (1000 iterations)") << QString::fromLatin1("for (i = 0; i < 1000; ++i) {}"); + QTest::newRow("for loop with empty body (10000 iterations)") << QString::fromLatin1("for (i = 0; i < 10000; ++i) {}"); + QTest::newRow("for loop with empty body (100000 iterations)") << QString::fromLatin1("for (i = 0; i < 100000; ++i) {}"); + QTest::newRow("for loop with empty body (1000000 iterations)") << QString::fromLatin1("for (i = 0; i < 1000000; ++i) {}"); + QTest::newRow("for loop (1000 iterations)") << QString::fromLatin1("j = 0; for (i = 0; i < 1000; ++i) { j += i; }; j"); + QTest::newRow("for loop (10000 iterations)") << QString::fromLatin1("j = 0; for (i = 0; i < 10000; ++i) { j += i; }; j"); + QTest::newRow("for loop (100000 iterations)") << QString::fromLatin1("j = 0; for (i = 0; i < 100000; ++i) { j += i; }; j"); + QTest::newRow("for loop (1000000 iterations)") << QString::fromLatin1("j = 0; for (i = 0; i < 1000000; ++i) { j += i; }; j"); + QTest::newRow("assignments") << QString::fromLatin1("a = 1; b = 2; c = 3; d = 4"); + QTest::newRow("while loop (1000 iterations)") << QString::fromLatin1("i = 0; while (i < 1000) { ++i; }; i"); + QTest::newRow("while loop (10000 iterations)") << QString::fromLatin1("i = 0; while (i < 10000) { ++i; }; i"); + QTest::newRow("while loop (100000 iterations)") << QString::fromLatin1("i = 0; while (i < 100000) { ++i; }; i"); + QTest::newRow("while loop (1000000 iterations)") << QString::fromLatin1("i = 0; while (i < 1000000) { ++i; }; i"); + QTest::newRow("function expression") << QString::fromLatin1("(function(a, b, c){ return a + b + c; })(1, 2, 3)"); +} + +void tst_QScriptEngine::evaluate() +{ + QFETCH(QString, code); + QScriptEngine engine; + + QBENCHMARK { + (void)engine.evaluate(code); + } +} + +void tst_QScriptEngine::connectAndDisconnect() +{ + QScriptEngine engine; + QScriptValue fun = engine.evaluate("(function() { })"); + QBENCHMARK { + qScriptConnect(&engine, SIGNAL(destroyed()), QScriptValue(), fun); + qScriptDisconnect(&engine, SIGNAL(destroyed()), QScriptValue(), fun); + } +} + +void tst_QScriptEngine::newObject() +{ + QScriptEngine engine; + QBENCHMARK { + (void)engine.newObject(); + } +} + +void tst_QScriptEngine::newQObject() +{ + QScriptEngine engine; + QBENCHMARK { + (void)engine.newQObject(QCoreApplication::instance()); + } +} + +static QScriptValue testFunction(QScriptContext *, QScriptEngine *) +{ + return 0; +} + +void tst_QScriptEngine::newFunction() +{ + QScriptEngine engine; + QBENCHMARK { + (void)engine.newFunction(testFunction); + } +} + +void tst_QScriptEngine::newVariant() +{ + QScriptEngine engine; + QVariant var(123); + QBENCHMARK { + (void)engine.newVariant(var); + } +} + +void tst_QScriptEngine::collectGarbage() +{ + QScriptEngine engine; + QBENCHMARK { + engine.collectGarbage(); + } +} + +void tst_QScriptEngine::pushAndPopContext() +{ + QScriptEngine engine; + QBENCHMARK { + (void)engine.pushContext(); + engine.popContext(); + } +} + +void tst_QScriptEngine::toStringHandle() +{ + QScriptEngine engine; + QString str = QString::fromLatin1("foobarbaz"); + QBENCHMARK { + (void)engine.toStringHandle(str); + } +} + +void tst_QScriptEngine::castValueToQreal() +{ + QScriptEngine engine; + QScriptValue val(123); + QBENCHMARK { + (void)qscriptvalue_cast(val); + } +} + +QTEST_MAIN(tst_QScriptEngine) +#include "tst_qscriptengine.moc" diff --git a/tests/benchmarks/qscriptvalue/qscriptvalue.pro b/tests/benchmarks/qscriptvalue/qscriptvalue.pro new file mode 100644 index 000000000..04ea324a0 --- /dev/null +++ b/tests/benchmarks/qscriptvalue/qscriptvalue.pro @@ -0,0 +1,7 @@ +load(qttest_p4) +TEMPLATE = app +TARGET = tst_qscriptvalue + +SOURCES += tst_qscriptvalue.cpp + +QT += script diff --git a/tests/benchmarks/qscriptvalue/tst_qscriptvalue.cpp b/tests/benchmarks/qscriptvalue/tst_qscriptvalue.cpp new file mode 100644 index 000000000..904674e12 --- /dev/null +++ b/tests/benchmarks/qscriptvalue/tst_qscriptvalue.cpp @@ -0,0 +1,193 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain +** additional rights. These rights are described in the Nokia Qt LGPL +** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at http://qt.nokia.com/contact. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include +#include + +//TESTED_FILES= + +class tst_QScriptValue : public QObject +{ + Q_OBJECT + +public: + tst_QScriptValue(); + virtual ~tst_QScriptValue(); + +public slots: + void init(); + void cleanup(); + +private slots: + void numberConstructor(); + void stringConstructor(); + void call_data(); + void call(); + void construct_data(); + void construct(); + void toString_data(); + void toString(); + void toQObject(); + void property(); + void setProperty(); +}; + +tst_QScriptValue::tst_QScriptValue() +{ +} + +tst_QScriptValue::~tst_QScriptValue() +{ +} + +void tst_QScriptValue::init() +{ +} + +void tst_QScriptValue::cleanup() +{ +} + +void tst_QScriptValue::numberConstructor() +{ + QBENCHMARK { + (void)QScriptValue(123); + } +} + +void tst_QScriptValue::stringConstructor() +{ + QString str = QString::fromLatin1("ciao"); + QBENCHMARK { + (void)QScriptValue(str); + } +} + +void tst_QScriptValue::call_data() +{ + QTest::addColumn("code"); + QTest::newRow("empty function") << QString::fromLatin1("(function(){})"); + QTest::newRow("function returning number") << QString::fromLatin1("(function(){ return 123; })"); + QTest::newRow("closure") << QString::fromLatin1("(function(a, b){ return function() { return a + b; }; })(1, 2)"); +} + +void tst_QScriptValue::call() +{ + QFETCH(QString, code); + QScriptEngine engine; + QScriptValue fun = engine.evaluate(code); + QVERIFY(fun.isFunction()); + QBENCHMARK { + (void)fun.call(); + } +} + +void tst_QScriptValue::construct_data() +{ + QTest::addColumn("code"); + QTest::newRow("empty function") << QString::fromLatin1("(function(){})"); + QTest::newRow("simple constructor") << QString::fromLatin1("(function(){ this.x = 10; this.y = 20; })"); +} + +void tst_QScriptValue::construct() +{ + QFETCH(QString, code); + QScriptEngine engine; + QScriptValue fun = engine.evaluate(code); + QVERIFY(fun.isFunction()); + QBENCHMARK { + (void)fun.construct(); + } +} + +void tst_QScriptValue::toString_data() +{ + QTest::addColumn("code"); + QTest::newRow("number") << QString::fromLatin1("123"); + QTest::newRow("string") << QString::fromLatin1("'ciao'"); + QTest::newRow("null") << QString::fromLatin1("null"); + QTest::newRow("undefined") << QString::fromLatin1("undefined"); + QTest::newRow("function") << QString::fromLatin1("(function foo(a, b, c) { return a + b + c; })"); +} + +void tst_QScriptValue::toString() +{ + QFETCH(QString, code); + QScriptEngine engine; + QScriptValue val = engine.evaluate(code); + QBENCHMARK { + (void)val.toString(); + } +} + +void tst_QScriptValue::toQObject() +{ + QScriptEngine engine; + QScriptValue obj = engine.newQObject(QCoreApplication::instance()); + QBENCHMARK { + (void)obj.toQObject(); + } +} + +void tst_QScriptValue::property() +{ + QScriptEngine engine; + QScriptValue obj = engine.newObject(); + QString propertyName = QString::fromLatin1("foo"); + obj.setProperty(propertyName, 123); + QBENCHMARK { + (void)obj.property(propertyName); + } +} + +void tst_QScriptValue::setProperty() +{ + QScriptEngine engine; + QScriptValue obj = engine.newObject(); + QString propertyName = QString::fromLatin1("foo"); + QScriptValue val(123); + QBENCHMARK { + obj.setProperty(propertyName, val); + } +} + +QTEST_MAIN(tst_QScriptValue) +#include "tst_qscriptvalue.moc" -- cgit v1.2.3 From 77feedfa3c00dc39df65bd4f567c9d43e8e25b4f Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Wed, 12 Aug 2009 16:11:54 +0200 Subject: Add QGraphicsView to the QTouchEvent test Since QTouchEvents can also be sent to QGraphicsItems, we want to test that it actually works. --- tests/auto/qtouchevent/tst_qtouchevent.cpp | 508 ++++++++++++++++++++++------- 1 file changed, 387 insertions(+), 121 deletions(-) diff --git a/tests/auto/qtouchevent/tst_qtouchevent.cpp b/tests/auto/qtouchevent/tst_qtouchevent.cpp index f30c4dba4..69b8888e6 100644 --- a/tests/auto/qtouchevent/tst_qtouchevent.cpp +++ b/tests/auto/qtouchevent/tst_qtouchevent.cpp @@ -96,6 +96,63 @@ public: } }; +class tst_QTouchEventGraphicsItem : public QGraphicsItem +{ +public: + QList touchBeginPoints, touchUpdatePoints, touchEndPoints; + bool seenTouchBegin, seenTouchUpdate, seenTouchEnd; + bool acceptTouchBegin, acceptTouchUpdate, acceptTouchEnd; + + tst_QTouchEventGraphicsItem() + : QGraphicsItem() + { + reset(); + } + + void reset() + { + touchBeginPoints.clear(); + touchUpdatePoints.clear(); + touchEndPoints.clear(); + seenTouchBegin = seenTouchUpdate = seenTouchEnd = false; + acceptTouchBegin = acceptTouchUpdate = acceptTouchEnd = true; + } + + QRectF boundingRect() const { return QRectF(0, 0, 10, 10); } + void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *) { } + + bool sceneEvent(QEvent *event) + { + switch (event->type()) { + case QEvent::TouchBegin: + if (seenTouchBegin) qWarning("TouchBegin: already seen a TouchBegin"); + if (seenTouchUpdate) qWarning("TouchBegin: TouchUpdate cannot happen before TouchBegin"); + if (seenTouchEnd) qWarning("TouchBegin: TouchEnd cannot happen before TouchBegin"); + seenTouchBegin = !seenTouchBegin && !seenTouchUpdate && !seenTouchEnd; + touchBeginPoints = static_cast(event)->touchPoints(); + event->setAccepted(acceptTouchBegin); + break; + case QEvent::TouchUpdate: + if (!seenTouchBegin) qWarning("TouchUpdate: have not seen TouchBegin"); + if (seenTouchEnd) qWarning("TouchUpdate: TouchEnd cannot happen before TouchUpdate"); + seenTouchUpdate = seenTouchBegin && !seenTouchEnd; + touchUpdatePoints = static_cast(event)->touchPoints(); + event->setAccepted(acceptTouchUpdate); + break; + case QEvent::TouchEnd: + if (!seenTouchBegin) qWarning("TouchEnd: have not seen TouchBegin"); + if (seenTouchEnd) qWarning("TouchEnd: already seen a TouchEnd"); + seenTouchEnd = seenTouchBegin && !seenTouchEnd; + touchEndPoints = static_cast(event)->touchPoints(); + event->setAccepted(acceptTouchEnd); + break; + default: + return QGraphicsItem::sceneEvent(event); + } + return true; + } +}; + class tst_QTouchEvent : public QObject { Q_OBJECT @@ -115,139 +172,348 @@ private slots: void tst_QTouchEvent::touchDisabledByDefault() { - // the widget attribute is not enabled by default - QWidget widget; - QVERIFY(!widget.testAttribute(Qt::WA_AcceptTouchEvents)); - - // events should not be accepted since they are not enabled - QList touchPoints; - touchPoints.append(QTouchEvent::TouchPoint(0)); - QTouchEvent touchEvent(QEvent::TouchBegin, - QTouchEvent::TouchScreen, - Qt::NoModifier, - Qt::TouchPointPressed, - touchPoints); - bool res = QApplication::sendEvent(&widget, &touchEvent); - QVERIFY(!res); - QVERIFY(!touchEvent.isAccepted()); + // QWidget + { + // the widget attribute is not enabled by default + QWidget widget; + QVERIFY(!widget.testAttribute(Qt::WA_AcceptTouchEvents)); + + // events should not be accepted since they are not enabled + QList touchPoints; + touchPoints.append(QTouchEvent::TouchPoint(0)); + QTouchEvent touchEvent(QEvent::TouchBegin, + QTouchEvent::TouchScreen, + Qt::NoModifier, + Qt::TouchPointPressed, + touchPoints); + bool res = QApplication::sendEvent(&widget, &touchEvent); + QVERIFY(!res); + QVERIFY(!touchEvent.isAccepted()); + } + + // QGraphicsView + { + QGraphicsScene scene; + tst_QTouchEventGraphicsItem item; + QGraphicsView view(&scene); + scene.addItem(&item); + item.setPos(100, 100); + view.resize(200, 200); + view.fitInView(scene.sceneRect()); + + // touch events are not accepted by default + QVERIFY(!item.acceptTouchEvents()); + + // compose an event to the scene that is over the item + QTouchEvent::TouchPoint touchPoint(0); + touchPoint.setState(Qt::TouchPointPressed); + touchPoint.setPos(view.mapFromScene(item.mapToScene(item.boundingRect().center()))); + touchPoint.setScreenPos(view.mapToGlobal(touchPoint.pos().toPoint())); + touchPoint.setScenePos(view.mapToScene(touchPoint.pos().toPoint())); + QTouchEvent touchEvent(QEvent::TouchBegin, + QTouchEvent::TouchScreen, + Qt::NoModifier, + Qt::TouchPointPressed, + (QList() << touchPoint)); + bool res = QApplication::sendEvent(view.viewport(), &touchEvent); + QVERIFY(!res); + QVERIFY(!touchEvent.isAccepted()); + QVERIFY(!item.seenTouchBegin); + } } void tst_QTouchEvent::touchEventAcceptedByDefault() { - // enabling touch events should automatically accept touch events - QWidget widget; - widget.setAttribute(Qt::WA_AcceptTouchEvents); - - // QWidget handles touch event by converting them into a mouse event, so the event is both - // accepted and handled (res == true) - QList touchPoints; - touchPoints.append(QTouchEvent::TouchPoint(0)); - QTouchEvent touchEvent(QEvent::TouchBegin, - QTouchEvent::TouchScreen, - Qt::NoModifier, - Qt::TouchPointPressed, - touchPoints); - bool res = QApplication::sendEvent(&widget, &touchEvent); - QVERIFY(res); - QVERIFY(touchEvent.isAccepted()); - - // tst_QTouchEventWidget does handle, sending succeeds - tst_QTouchEventWidget touchWidget; - touchWidget.setAttribute(Qt::WA_AcceptTouchEvents); - touchEvent.ignore(); - res = QApplication::sendEvent(&touchWidget, &touchEvent); - QVERIFY(res); - QVERIFY(touchEvent.isAccepted()); + // QWidget + { + // enabling touch events should automatically accept touch events + QWidget widget; + widget.setAttribute(Qt::WA_AcceptTouchEvents); + + // QWidget handles touch event by converting them into a mouse event, so the event is both + // accepted and handled (res == true) + QList touchPoints; + touchPoints.append(QTouchEvent::TouchPoint(0)); + QTouchEvent touchEvent(QEvent::TouchBegin, + QTouchEvent::TouchScreen, + Qt::NoModifier, + Qt::TouchPointPressed, + touchPoints); + bool res = QApplication::sendEvent(&widget, &touchEvent); + QVERIFY(res); + QVERIFY(touchEvent.isAccepted()); + + // tst_QTouchEventWidget does handle, sending succeeds + tst_QTouchEventWidget touchWidget; + touchWidget.setAttribute(Qt::WA_AcceptTouchEvents); + touchEvent.ignore(); + res = QApplication::sendEvent(&touchWidget, &touchEvent); + QVERIFY(res); + QVERIFY(touchEvent.isAccepted()); + } + + // QGraphicsView + { + QGraphicsScene scene; + tst_QTouchEventGraphicsItem item; + QGraphicsView view(&scene); + scene.addItem(&item); + item.setPos(100, 100); + view.resize(200, 200); + view.fitInView(scene.sceneRect()); + + // enabling touch events on the item also enables events on the viewport + item.setAcceptTouchEvents(true); + QVERIFY(view.viewport()->testAttribute(Qt::WA_AcceptTouchEvents)); + + // compose an event to the scene that is over the item + QTouchEvent::TouchPoint touchPoint(0); + touchPoint.setState(Qt::TouchPointPressed); + touchPoint.setPos(view.mapFromScene(item.mapToScene(item.boundingRect().center()))); + touchPoint.setScreenPos(view.mapToGlobal(touchPoint.pos().toPoint())); + touchPoint.setScenePos(view.mapToScene(touchPoint.pos().toPoint())); + QTouchEvent touchEvent(QEvent::TouchBegin, + QTouchEvent::TouchScreen, + Qt::NoModifier, + Qt::TouchPointPressed, + (QList() << touchPoint)); + bool res = QApplication::sendEvent(view.viewport(), &touchEvent); + QVERIFY(res); + QVERIFY(touchEvent.isAccepted()); + QVERIFY(item.seenTouchBegin); + } } void tst_QTouchEvent::touchBeginPropagatesWhenIgnored() { - tst_QTouchEventWidget window, child, grandchild; - child.setParent(&window); - grandchild.setParent(&child); - - // all widgets accept touch events, grandchild ignores, so child sees the event, but not window - window.setAttribute(Qt::WA_AcceptTouchEvents); - child.setAttribute(Qt::WA_AcceptTouchEvents); - grandchild.setAttribute(Qt::WA_AcceptTouchEvents); - grandchild.acceptTouchBegin = false; - - QList touchPoints; - touchPoints.append(QTouchEvent::TouchPoint(0)); - QTouchEvent touchEvent(QEvent::TouchBegin, - QTouchEvent::TouchScreen, - Qt::NoModifier, - Qt::TouchPointPressed, - touchPoints); - bool res = QApplication::sendEvent(&grandchild, &touchEvent); - QVERIFY(res); - QVERIFY(touchEvent.isAccepted()); - QVERIFY(grandchild.seenTouchBegin); - QVERIFY(child.seenTouchBegin); - QVERIFY(!window.seenTouchBegin); - - // disable touch on grandchild. even though it doesn't accept it, child should still get the - // TouchBegin - grandchild.reset(); - child.reset(); - window.reset(); - grandchild.setAttribute(Qt::WA_AcceptTouchEvents, false); - - touchEvent.ignore(); - res = QApplication::sendEvent(&grandchild, &touchEvent); - QVERIFY(res); - QVERIFY(touchEvent.isAccepted()); - QVERIFY(!grandchild.seenTouchBegin); - QVERIFY(child.seenTouchBegin); - QVERIFY(!window.seenTouchBegin); + // QWidget + { + tst_QTouchEventWidget window, child, grandchild; + child.setParent(&window); + grandchild.setParent(&child); + + // all widgets accept touch events, grandchild ignores, so child sees the event, but not window + window.setAttribute(Qt::WA_AcceptTouchEvents); + child.setAttribute(Qt::WA_AcceptTouchEvents); + grandchild.setAttribute(Qt::WA_AcceptTouchEvents); + grandchild.acceptTouchBegin = false; + + QList touchPoints; + touchPoints.append(QTouchEvent::TouchPoint(0)); + QTouchEvent touchEvent(QEvent::TouchBegin, + QTouchEvent::TouchScreen, + Qt::NoModifier, + Qt::TouchPointPressed, + touchPoints); + bool res = QApplication::sendEvent(&grandchild, &touchEvent); + QVERIFY(res); + QVERIFY(touchEvent.isAccepted()); + QVERIFY(grandchild.seenTouchBegin); + QVERIFY(child.seenTouchBegin); + QVERIFY(!window.seenTouchBegin); + + // disable touch on grandchild. even though it doesn't accept it, child should still get the + // TouchBegin + grandchild.reset(); + child.reset(); + window.reset(); + grandchild.setAttribute(Qt::WA_AcceptTouchEvents, false); + + touchEvent.ignore(); + res = QApplication::sendEvent(&grandchild, &touchEvent); + QVERIFY(res); + QVERIFY(touchEvent.isAccepted()); + QVERIFY(!grandchild.seenTouchBegin); + QVERIFY(child.seenTouchBegin); + QVERIFY(!window.seenTouchBegin); + } + + // QGraphicsView + { + QGraphicsScene scene; + tst_QTouchEventGraphicsItem root, child, grandchild; + QGraphicsView view(&scene); + scene.addItem(&root); + root.setPos(100, 100); + child.setParentItem(&root); + grandchild.setParentItem(&child); + view.resize(200, 200); + view.fitInView(scene.sceneRect()); + + // all items accept touch events, grandchild ignores, so child sees the event, but not root + root.setAcceptTouchEvents(true); + child.setAcceptTouchEvents(true); + grandchild.setAcceptTouchEvents(true); + grandchild.acceptTouchBegin = false; + + // compose an event to the scene that is over the grandchild + QTouchEvent::TouchPoint touchPoint(0); + touchPoint.setState(Qt::TouchPointPressed); + touchPoint.setPos(view.mapFromScene(grandchild.mapToScene(grandchild.boundingRect().center()))); + touchPoint.setScreenPos(view.mapToGlobal(touchPoint.pos().toPoint())); + touchPoint.setScenePos(view.mapToScene(touchPoint.pos().toPoint())); + QTouchEvent touchEvent(QEvent::TouchBegin, + QTouchEvent::TouchScreen, + Qt::NoModifier, + Qt::TouchPointPressed, + (QList() << touchPoint)); + bool res = QApplication::sendEvent(view.viewport(), &touchEvent); + QVERIFY(res); + QVERIFY(touchEvent.isAccepted()); + QVERIFY(grandchild.seenTouchBegin); + QVERIFY(child.seenTouchBegin); + QVERIFY(!root.seenTouchBegin); + } + + // QGraphicsView + { + QGraphicsScene scene; + tst_QTouchEventGraphicsItem root, child, grandchild; + QGraphicsView view(&scene); + scene.addItem(&root); + root.setPos(100, 100); + child.setParentItem(&root); + grandchild.setParentItem(&child); + view.resize(200, 200); + view.fitInView(scene.sceneRect()); + + // leave touch disabled on grandchild. even though it doesn't accept it, child should + // still get the TouchBegin + root.setAcceptTouchEvents(true); + child.setAcceptTouchEvents(true); + + // compose an event to the scene that is over the grandchild + QTouchEvent::TouchPoint touchPoint(0); + touchPoint.setState(Qt::TouchPointPressed); + touchPoint.setPos(view.mapFromScene(grandchild.mapToScene(grandchild.boundingRect().center()))); + touchPoint.setScreenPos(view.mapToGlobal(touchPoint.pos().toPoint())); + touchPoint.setScenePos(view.mapToScene(touchPoint.pos().toPoint())); + QTouchEvent touchEvent(QEvent::TouchBegin, + QTouchEvent::TouchScreen, + Qt::NoModifier, + Qt::TouchPointPressed, + (QList() << touchPoint)); + bool res = QApplication::sendEvent(view.viewport(), &touchEvent); + QVERIFY(res); + QVERIFY(touchEvent.isAccepted()); + QVERIFY(!grandchild.seenTouchBegin); + QVERIFY(child.seenTouchBegin); + QVERIFY(!root.seenTouchBegin); + } } void tst_QTouchEvent::touchUpdateAndEndNeverPropagate() { - tst_QTouchEventWidget window, child; - child.setParent(&window); - - window.setAttribute(Qt::WA_AcceptTouchEvents); - child.setAttribute(Qt::WA_AcceptTouchEvents); - child.acceptTouchUpdate = false; - child.acceptTouchEnd = false; - - QList touchPoints; - touchPoints.append(QTouchEvent::TouchPoint(0)); - QTouchEvent touchBeginEvent(QEvent::TouchBegin, - QTouchEvent::TouchScreen, - Qt::NoModifier, - Qt::TouchPointPressed, - touchPoints); - bool res = QApplication::sendEvent(&child, &touchBeginEvent); - QVERIFY(res); - QVERIFY(touchBeginEvent.isAccepted()); - QVERIFY(child.seenTouchBegin); - QVERIFY(!window.seenTouchBegin); - - // send the touch update to the child, but ignore it, it doesn't propagate - QTouchEvent touchUpdateEvent(QEvent::TouchUpdate, - QTouchEvent::TouchScreen, - Qt::NoModifier, - Qt::TouchPointMoved, - touchPoints); - res = QApplication::sendEvent(&child, &touchUpdateEvent); - QVERIFY(res); - QVERIFY(!touchUpdateEvent.isAccepted()); - QVERIFY(child.seenTouchUpdate); - QVERIFY(!window.seenTouchUpdate); - - // send the touch end, same thing should happen as with touch update - QTouchEvent touchEndEvent(QEvent::TouchEnd, - QTouchEvent::TouchScreen, - Qt::NoModifier, - Qt::TouchPointReleased, - touchPoints); - res = QApplication::sendEvent(&child, &touchEndEvent); - QVERIFY(res); - QVERIFY(!touchEndEvent.isAccepted()); - QVERIFY(child.seenTouchEnd); - QVERIFY(!window.seenTouchEnd); + // QWidget + { + tst_QTouchEventWidget window, child; + child.setParent(&window); + + window.setAttribute(Qt::WA_AcceptTouchEvents); + child.setAttribute(Qt::WA_AcceptTouchEvents); + child.acceptTouchUpdate = false; + child.acceptTouchEnd = false; + + QList touchPoints; + touchPoints.append(QTouchEvent::TouchPoint(0)); + QTouchEvent touchBeginEvent(QEvent::TouchBegin, + QTouchEvent::TouchScreen, + Qt::NoModifier, + Qt::TouchPointPressed, + touchPoints); + bool res = QApplication::sendEvent(&child, &touchBeginEvent); + QVERIFY(res); + QVERIFY(touchBeginEvent.isAccepted()); + QVERIFY(child.seenTouchBegin); + QVERIFY(!window.seenTouchBegin); + + // send the touch update to the child, but ignore it, it doesn't propagate + QTouchEvent touchUpdateEvent(QEvent::TouchUpdate, + QTouchEvent::TouchScreen, + Qt::NoModifier, + Qt::TouchPointMoved, + touchPoints); + res = QApplication::sendEvent(&child, &touchUpdateEvent); + QVERIFY(res); + QVERIFY(!touchUpdateEvent.isAccepted()); + QVERIFY(child.seenTouchUpdate); + QVERIFY(!window.seenTouchUpdate); + + // send the touch end, same thing should happen as with touch update + QTouchEvent touchEndEvent(QEvent::TouchEnd, + QTouchEvent::TouchScreen, + Qt::NoModifier, + Qt::TouchPointReleased, + touchPoints); + res = QApplication::sendEvent(&child, &touchEndEvent); + QVERIFY(res); + QVERIFY(!touchEndEvent.isAccepted()); + QVERIFY(child.seenTouchEnd); + QVERIFY(!window.seenTouchEnd); + } + + // QGraphicsView + { + QGraphicsScene scene; + tst_QTouchEventGraphicsItem root, child, grandchild; + QGraphicsView view(&scene); + scene.addItem(&root); + root.setPos(100, 100); + child.setParentItem(&root); + grandchild.setParentItem(&child); + view.resize(200, 200); + view.fitInView(scene.sceneRect()); + + root.setAcceptTouchEvents(true); + child.setAcceptTouchEvents(true); + child.acceptTouchUpdate = false; + child.acceptTouchEnd = false; + + // compose an event to the scene that is over the child + QTouchEvent::TouchPoint touchPoint(0); + touchPoint.setState(Qt::TouchPointPressed); + touchPoint.setPos(view.mapFromScene(grandchild.mapToScene(grandchild.boundingRect().center()))); + touchPoint.setScreenPos(view.mapToGlobal(touchPoint.pos().toPoint())); + touchPoint.setScenePos(view.mapToScene(touchPoint.pos().toPoint())); + QTouchEvent touchBeginEvent(QEvent::TouchBegin, + QTouchEvent::TouchScreen, + Qt::NoModifier, + Qt::TouchPointPressed, + (QList() << touchPoint)); + bool res = QApplication::sendEvent(view.viewport(), &touchBeginEvent); + QVERIFY(res); + QVERIFY(touchBeginEvent.isAccepted()); + QVERIFY(child.seenTouchBegin); + QVERIFY(!root.seenTouchBegin); + + // send the touch update to the child, but ignore it, it doesn't propagate + touchPoint.setState(Qt::TouchPointMoved); + QTouchEvent touchUpdateEvent(QEvent::TouchUpdate, + QTouchEvent::TouchScreen, + Qt::NoModifier, + Qt::TouchPointMoved, + (QList() << touchPoint)); + res = QApplication::sendEvent(view.viewport(), &touchUpdateEvent); + QVERIFY(res); + // the scene accepts the event, since it found an item to send the event to + QVERIFY(touchUpdateEvent.isAccepted()); + QVERIFY(child.seenTouchUpdate); + QVERIFY(!root.seenTouchUpdate); + + // send the touch end, same thing should happen as with touch update + touchPoint.setState(Qt::TouchPointReleased); + QTouchEvent touchEndEvent(QEvent::TouchEnd, + QTouchEvent::TouchScreen, + Qt::NoModifier, + Qt::TouchPointReleased, + (QList() << touchPoint)); + res = QApplication::sendEvent(view.viewport(), &touchEndEvent); + QVERIFY(res); + // the scene accepts the event, since it found an item to send the event to + QVERIFY(touchEndEvent.isAccepted()); + QVERIFY(child.seenTouchEnd); + QVERIFY(!root.seenTouchEnd); + } } QPointF normalized(const QPointF &pos, const QRectF &rect) -- cgit v1.2.3 From 0c992f560a0872ccdc4a44cf4d1c7da627cc6807 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 12 Aug 2009 17:41:11 +0200 Subject: Ugly round corners when no border is drawn When specifying round corners with QStyleSheetStyle and no border-width specified, the round corners were not rendered with antialiasing. Furthermore, if border-width was set to 0, part of the border was rendered in discordance with CSS3. The background in now rendered directly instead of drawing a clipped rectangle. The actual border width is checked before rendering. A test has been added at tests/auto/uiloader/baseline/css_borderradius_allwidgets.ui Task-number: 230362 Reviewed-by: olivier --- src/gui/painting/qcssutil.cpp | 8 +- src/gui/styles/qstylesheetstyle.cpp | 13 +- .../baseline/css_borderradius_allwidgets.ui | 433 +++++++++++++++++++++ 3 files changed, 447 insertions(+), 7 deletions(-) create mode 100644 tests/auto/uiloader/baseline/css_borderradius_allwidgets.ui diff --git a/src/gui/painting/qcssutil.cpp b/src/gui/painting/qcssutil.cpp index ac0ea08b8..ae8afedbf 100644 --- a/src/gui/painting/qcssutil.cpp +++ b/src/gui/painting/qcssutil.cpp @@ -353,7 +353,7 @@ void qDrawBorder(QPainter *p, const QRect &rect, const QCss::BorderStyle *styles qNormalizeRadii(rect, radii, &tlr, &trr, &blr, &brr); // Drawn in increasing order of precendence - if (styles[BottomEdge] != BorderStyle_None) { + if (styles[BottomEdge] != BorderStyle_None && borders[BottomEdge] > 0) { qreal dw1 = (blr.width() || paintsOver(styles, colors, BottomEdge, LeftEdge)) ? 0 : borders[LeftEdge]; qreal dw2 = (brr.width() || paintsOver(styles, colors, BottomEdge, RightEdge)) ? 0 : borders[RightEdge]; qreal x1 = br.x() + blr.width(); @@ -365,7 +365,7 @@ void qDrawBorder(QPainter *p, const QRect &rect, const QCss::BorderStyle *styles if (blr.width() || brr.width()) qDrawRoundedCorners(p, x1, y1, x2, y2, blr, brr, BottomEdge, styles[BottomEdge], colors[BottomEdge]); } - if (styles[RightEdge] != BorderStyle_None) { + if (styles[RightEdge] != BorderStyle_None && borders[RightEdge] > 0) { qreal dw1 = (trr.height() || paintsOver(styles, colors, RightEdge, TopEdge)) ? 0 : borders[TopEdge]; qreal dw2 = (brr.height() || paintsOver(styles, colors, RightEdge, BottomEdge)) ? 0 : borders[BottomEdge]; qreal x1 = br.x() + br.width() - borders[RightEdge]; @@ -377,7 +377,7 @@ void qDrawBorder(QPainter *p, const QRect &rect, const QCss::BorderStyle *styles if (trr.height() || brr.height()) qDrawRoundedCorners(p, x1, y1, x2, y2, trr, brr, RightEdge, styles[RightEdge], colors[RightEdge]); } - if (styles[LeftEdge] != BorderStyle_None) { + if (styles[LeftEdge] != BorderStyle_None && borders[LeftEdge] > 0) { qreal dw1 = (tlr.height() || paintsOver(styles, colors, LeftEdge, TopEdge)) ? 0 : borders[TopEdge]; qreal dw2 = (blr.height() || paintsOver(styles, colors, LeftEdge, BottomEdge)) ? 0 : borders[BottomEdge]; qreal x1 = br.x(); @@ -389,7 +389,7 @@ void qDrawBorder(QPainter *p, const QRect &rect, const QCss::BorderStyle *styles if (tlr.height() || blr.height()) qDrawRoundedCorners(p, x1, y1, x2, y2, tlr, blr, LeftEdge, styles[LeftEdge], colors[LeftEdge]); } - if (styles[TopEdge] != BorderStyle_None) { + if (styles[TopEdge] != BorderStyle_None && borders[TopEdge] > 0) { qreal dw1 = (tlr.width() || paintsOver(styles, colors, TopEdge, LeftEdge)) ? 0 : borders[LeftEdge]; qreal dw2 = (trr.width() || paintsOver(styles, colors, TopEdge, RightEdge)) ? 0 : borders[RightEdge]; qreal x1 = br.x() + tlr.width(); diff --git a/src/gui/styles/qstylesheetstyle.cpp b/src/gui/styles/qstylesheetstyle.cpp index 370290ff4..8ac811c6e 100644 --- a/src/gui/styles/qstylesheetstyle.cpp +++ b/src/gui/styles/qstylesheetstyle.cpp @@ -1298,7 +1298,6 @@ void QRenderRule::unsetClip(QPainter *p) void QRenderRule::drawBackground(QPainter *p, const QRect& rect, const QPoint& off) { - setClip(p, borderRect(rect)); QBrush brush = hasBackground() ? background()->brush : QBrush(); if (brush.style() == Qt::NoBrush) brush = defaultBackground; @@ -1306,11 +1305,19 @@ void QRenderRule::drawBackground(QPainter *p, const QRect& rect, const QPoint& o if (brush.style() != Qt::NoBrush) { Origin origin = hasBackground() ? background()->clip : Origin_Border; // ### fix for gradients - p->fillRect(originRect(rect, origin), brush); + const QPainterPath &borderPath = borderClip(originRect(rect, origin)); + if (!borderPath.isEmpty()) { + // Drawn intead of being used as clipping path for better visual quality + bool wasAntialiased = p->renderHints() & QPainter::Antialiasing; + p->setRenderHint(QPainter::Antialiasing); + p->fillPath(borderPath, brush); + p->setRenderHint(QPainter::Antialiasing, wasAntialiased); + } else { + p->fillRect(originRect(rect, origin), brush); + } } drawBackgroundImage(p, rect, off); - unsetClip(p); } void QRenderRule::drawFrame(QPainter *p, const QRect& rect) diff --git a/tests/auto/uiloader/baseline/css_borderradius_allwidgets.ui b/tests/auto/uiloader/baseline/css_borderradius_allwidgets.ui new file mode 100644 index 000000000..96cb7f350 --- /dev/null +++ b/tests/auto/uiloader/baseline/css_borderradius_allwidgets.ui @@ -0,0 +1,433 @@ + + + MainWindow + + + + 0 + 0 + 698 + 589 + + + + MainWindow + + + * { + background: yellow; + padding: 2px; +} + +QAbstractButton, QAbstractSlider { + background: cyan; +} + +QFrame { + background: magenta; +} + +QLineEdit, QSpinBox { + background: white; +} + +#gb1 * { + border-radius: 4px; +} + +#gb2 * { + border: 1px solid blue; + border-radius: 4px; +} + +#gb3 * { + border: 0px solid blue; + border-radius: 4px; +} + +#gb4 * { + border-image: url("images/pushbutton.png") 6 6 6 6; + border-width:6px; + border-radius: 4px; +} + + + + + + + + No border + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + PushButton + + + + + + + + + + RadioButton + + + + + + + CheckBox + + + + + + + + + + + + + + + + + + + + + New Item + + + + + New Item + + + + + New Item + + + + + New Item + + + + + New Item + + + + + + + + + + + 0px border + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + PushButton + + + + + + + + + + RadioButton + + + + + + + CheckBox + + + + + + + + + + + + + + + + + + + + + New Item + + + + + New Item + + + + + New Item + + + + + New Item + + + + + New Item + + + + + + + + + + + border-image + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + PushButton + + + + + + + + + + RadioButton + + + + + + + CheckBox + + + + + + + + + + + + + + + + + + + + + New Item + + + + + New Item + + + + + New Item + + + + + New Item + + + + + New Item + + + + + + + + + + + 1px border + + + + + + QFrame::StyledPanel + + + QFrame::Raised + + + + + + PushButton + + + + + + + + + + RadioButton + + + + + + + CheckBox + + + + + + + + + + + + + + + + + + + + + New Item + + + + + New Item + + + + + New Item + + + + + New Item + + + + + New Item + + + + + + + + + + + + + 0 + 0 + 698 + 24 + + + + + File + + + + + + + Edit + + + + + + + + + Open + + + + + Close + + + + + + -- cgit v1.2.3 From 07d2ce1e6df9f2b5b9c3263741f9a8f160cdbc80 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Wed, 12 Aug 2009 18:50:46 +0200 Subject: Test cleaned-up. --- .../baseline/css_borderradius_allwidgets.ui | 53 ++++++++++++++++------ 1 file changed, 39 insertions(+), 14 deletions(-) diff --git a/tests/auto/uiloader/baseline/css_borderradius_allwidgets.ui b/tests/auto/uiloader/baseline/css_borderradius_allwidgets.ui index 96cb7f350..8c5f57cb1 100644 --- a/tests/auto/uiloader/baseline/css_borderradius_allwidgets.ui +++ b/tests/auto/uiloader/baseline/css_borderradius_allwidgets.ui @@ -17,13 +17,18 @@ * { background: yellow; padding: 2px; + border-radius: 4px; +} + +QGroupBox { + border: 1px solid gray; } -QAbstractButton, QAbstractSlider { +QAbstractButton { background: cyan; } -QFrame { +QFrame, QMenuBar { background: magenta; } @@ -32,23 +37,19 @@ QLineEdit, QSpinBox { } #gb1 * { - border-radius: 4px; } #gb2 * { border: 1px solid blue; - border-radius: 4px; } #gb3 * { border: 0px solid blue; - border-radius: 4px; } #gb4 * { border-image: url("images/pushbutton.png") 6 6 6 6; border-width:6px; - border-radius: 4px; } @@ -96,12 +97,18 @@ QLineEdit, QSpinBox { - + LineEdit - + + + + ComboBox + + + @@ -180,12 +187,18 @@ QLineEdit, QSpinBox { - + LineEdit - + + + + ComboBox + + + @@ -264,12 +277,18 @@ QLineEdit, QSpinBox { - + LineEdit - + + + + ComboBox + + + @@ -348,12 +367,18 @@ QLineEdit, QSpinBox { - + LineEdit - + + + + ComboBox + + + -- cgit v1.2.3 From f4a2451421994cacf5ae79f242f5cdb37ebdd87c Mon Sep 17 00:00:00 2001 From: Rohan McGovern Date: Wed, 12 Aug 2009 14:50:38 +1000 Subject: Test naming convention cleanup. --- tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp | 236 ++++++++++++------------ 1 file changed, 118 insertions(+), 118 deletions(-) diff --git a/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp b/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp index 5e20d066d..5541162d2 100644 --- a/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp +++ b/tests/auto/math3d/qmatrixnxn/tst_qmatrixnxn.cpp @@ -43,12 +43,12 @@ #include #include "math3dincludes.h" -class tst_QMatrix : public QObject +class tst_QMatrixNxN : public QObject { Q_OBJECT public: - tst_QMatrix() {} - ~tst_QMatrix() {} + tst_QMatrixNxN() {} + ~tst_QMatrixNxN() {} private slots: void create2x2(); @@ -298,25 +298,25 @@ static qreal const transposedValues3x4[12] = // Set a matrix to a specified array of values, which are assumed // to be in row-major order. This sets the values using floating-point. -void tst_QMatrix::setMatrix(QMatrix2x2& m, const qreal *values) +void tst_QMatrixNxN::setMatrix(QMatrix2x2& m, const qreal *values) { for (int row = 0; row < 2; ++row) for (int col = 0; col < 2; ++col) m(row, col) = values[row * 2 + col]; } -void tst_QMatrix::setMatrix(QMatrix3x3& m, const qreal *values) +void tst_QMatrixNxN::setMatrix(QMatrix3x3& m, const qreal *values) { for (int row = 0; row < 3; ++row) for (int col = 0; col < 3; ++col) m(row, col) = values[row * 3 + col]; } -void tst_QMatrix::setMatrix(QMatrix4x4& m, const qreal *values) +void tst_QMatrixNxN::setMatrix(QMatrix4x4& m, const qreal *values) { for (int row = 0; row < 4; ++row) for (int col = 0; col < 4; ++col) m(row, col) = values[row * 4 + col]; } -void tst_QMatrix::setMatrix(QMatrix4x3& m, const qreal *values) +void tst_QMatrixNxN::setMatrix(QMatrix4x3& m, const qreal *values) { for (int row = 0; row < 3; ++row) for (int col = 0; col < 4; ++col) @@ -326,7 +326,7 @@ void tst_QMatrix::setMatrix(QMatrix4x3& m, const qreal *values) // Set a matrix to a specified array of values, which are assumed // to be in row-major order. This sets the values directly into // the internal data() array. -void tst_QMatrix::setMatrixDirect(QMatrix2x2& m, const qreal *values) +void tst_QMatrixNxN::setMatrixDirect(QMatrix2x2& m, const qreal *values) { float *data = m.data(); for (int row = 0; row < 2; ++row) { @@ -335,7 +335,7 @@ void tst_QMatrix::setMatrixDirect(QMatrix2x2& m, const qreal *values) } } } -void tst_QMatrix::setMatrixDirect(QMatrix3x3& m, const qreal *values) +void tst_QMatrixNxN::setMatrixDirect(QMatrix3x3& m, const qreal *values) { float *data = m.data(); for (int row = 0; row < 3; ++row) { @@ -344,7 +344,7 @@ void tst_QMatrix::setMatrixDirect(QMatrix3x3& m, const qreal *values) } } } -void tst_QMatrix::setMatrixDirect(QMatrix4x4& m, const qreal *values) +void tst_QMatrixNxN::setMatrixDirect(QMatrix4x4& m, const qreal *values) { float *data = m.data(); for (int row = 0; row < 4; ++row) { @@ -353,7 +353,7 @@ void tst_QMatrix::setMatrixDirect(QMatrix4x4& m, const qreal *values) } } } -void tst_QMatrix::setMatrixDirect(QMatrix4x3& m, const qreal *values) +void tst_QMatrixNxN::setMatrixDirect(QMatrix4x3& m, const qreal *values) { float *data = m.data(); for (int row = 0; row < 3; ++row) { @@ -398,7 +398,7 @@ static bool matrixFuzzyCompare(const QMatrix4x4 &m1, const QMatrix4x4 &m2) // Determine if a matrix is the same as a specified array of values. // The values are assumed to be specified in row-major order. -bool tst_QMatrix::isSame(const QMatrix2x2& m, const qreal *values) +bool tst_QMatrixNxN::isSame(const QMatrix2x2& m, const qreal *values) { const float *mv = m.constData(); for (int row = 0; row < 2; ++row) { @@ -419,7 +419,7 @@ bool tst_QMatrix::isSame(const QMatrix2x2& m, const qreal *values) } return true; } -bool tst_QMatrix::isSame(const QMatrix3x3& m, const qreal *values) +bool tst_QMatrixNxN::isSame(const QMatrix3x3& m, const qreal *values) { const float *mv = m.constData(); for (int row = 0; row < 3; ++row) { @@ -440,7 +440,7 @@ bool tst_QMatrix::isSame(const QMatrix3x3& m, const qreal *values) } return true; } -bool tst_QMatrix::isSame(const QMatrix4x4& m, const qreal *values) +bool tst_QMatrixNxN::isSame(const QMatrix4x4& m, const qreal *values) { const float *mv = m.constData(); for (int row = 0; row < 4; ++row) { @@ -461,7 +461,7 @@ bool tst_QMatrix::isSame(const QMatrix4x4& m, const qreal *values) } return true; } -bool tst_QMatrix::isSame(const QMatrix4x3& m, const qreal *values) +bool tst_QMatrixNxN::isSame(const QMatrix4x3& m, const qreal *values) { const float *mv = m.constData(); for (int row = 0; row < 3; ++row) { @@ -484,26 +484,26 @@ bool tst_QMatrix::isSame(const QMatrix4x3& m, const qreal *values) } // Determine if a matrix is the identity. -bool tst_QMatrix::isIdentity(const QMatrix2x2& m) +bool tst_QMatrixNxN::isIdentity(const QMatrix2x2& m) { return isSame(m, identityValues2); } -bool tst_QMatrix::isIdentity(const QMatrix3x3& m) +bool tst_QMatrixNxN::isIdentity(const QMatrix3x3& m) { return isSame(m, identityValues3); } -bool tst_QMatrix::isIdentity(const QMatrix4x4& m) +bool tst_QMatrixNxN::isIdentity(const QMatrix4x4& m) { return isSame(m, identityValues4); } -bool tst_QMatrix::isIdentity(const QMatrix4x3& m) +bool tst_QMatrixNxN::isIdentity(const QMatrix4x3& m) { return isSame(m, identityValues4x3); } // Test the creation of QMatrix2x2 objects in various ways: // construct, copy, and modify. -void tst_QMatrix::create2x2() +void tst_QMatrixNxN::create2x2() { QMatrix2x2 m1; QVERIFY(isIdentity(m1)); @@ -538,7 +538,7 @@ void tst_QMatrix::create2x2() // Test the creation of QMatrix3x3 objects in various ways: // construct, copy, and modify. -void tst_QMatrix::create3x3() +void tst_QMatrixNxN::create3x3() { QMatrix3x3 m1; QVERIFY(isIdentity(m1)); @@ -573,7 +573,7 @@ void tst_QMatrix::create3x3() // Test the creation of QMatrix4x4 objects in various ways: // construct, copy, and modify. -void tst_QMatrix::create4x4() +void tst_QMatrixNxN::create4x4() { QMatrix4x4 m1; QVERIFY(isIdentity(m1)); @@ -615,7 +615,7 @@ void tst_QMatrix::create4x4() // Test the creation of QMatrix4x3 objects in various ways: // construct, copy, and modify. -void tst_QMatrix::create4x3() +void tst_QMatrixNxN::create4x3() { QMatrix4x3 m1; QVERIFY(isIdentity(m1)); @@ -649,7 +649,7 @@ void tst_QMatrix::create4x3() } // Test isIdentity() for 2x2 matrices. -void tst_QMatrix::isIdentity2x2() +void tst_QMatrixNxN::isIdentity2x2() { for (int i = 0; i < 2 * 2; ++i) { QMatrix2x2 m; @@ -660,7 +660,7 @@ void tst_QMatrix::isIdentity2x2() } // Test isIdentity() for 3x3 matrices. -void tst_QMatrix::isIdentity3x3() +void tst_QMatrixNxN::isIdentity3x3() { for (int i = 0; i < 3 * 3; ++i) { QMatrix3x3 m; @@ -671,7 +671,7 @@ void tst_QMatrix::isIdentity3x3() } // Test isIdentity() for 4x4 matrices. -void tst_QMatrix::isIdentity4x4() +void tst_QMatrixNxN::isIdentity4x4() { for (int i = 0; i < 4 * 4; ++i) { QMatrix4x4 m; @@ -687,7 +687,7 @@ void tst_QMatrix::isIdentity4x4() } // Test isIdentity() for 4x3 matrices. -void tst_QMatrix::isIdentity4x3() +void tst_QMatrixNxN::isIdentity4x3() { for (int i = 0; i < 4 * 3; ++i) { QMatrix4x3 m; @@ -698,7 +698,7 @@ void tst_QMatrix::isIdentity4x3() } // Test 2x2 matrix comparisons. -void tst_QMatrix::compare2x2() +void tst_QMatrixNxN::compare2x2() { QMatrix2x2 m1(uniqueValues2); QMatrix2x2 m2(uniqueValues2); @@ -711,7 +711,7 @@ void tst_QMatrix::compare2x2() } // Test 3x3 matrix comparisons. -void tst_QMatrix::compare3x3() +void tst_QMatrixNxN::compare3x3() { QMatrix3x3 m1(uniqueValues3); QMatrix3x3 m2(uniqueValues3); @@ -724,7 +724,7 @@ void tst_QMatrix::compare3x3() } // Test 4x4 matrix comparisons. -void tst_QMatrix::compare4x4() +void tst_QMatrixNxN::compare4x4() { QMatrix4x4 m1(uniqueValues4); QMatrix4x4 m2(uniqueValues4); @@ -737,7 +737,7 @@ void tst_QMatrix::compare4x4() } // Test 4x3 matrix comparisons. -void tst_QMatrix::compare4x3() +void tst_QMatrixNxN::compare4x3() { QMatrix4x3 m1(uniqueValues4x3); QMatrix4x3 m2(uniqueValues4x3); @@ -750,7 +750,7 @@ void tst_QMatrix::compare4x3() } // Test matrix 2x2 transpose operations. -void tst_QMatrix::transposed2x2() +void tst_QMatrixNxN::transposed2x2() { // Transposing the identity should result in the identity. QMatrix2x2 m1; @@ -769,7 +769,7 @@ void tst_QMatrix::transposed2x2() } // Test matrix 3x3 transpose operations. -void tst_QMatrix::transposed3x3() +void tst_QMatrixNxN::transposed3x3() { // Transposing the identity should result in the identity. QMatrix3x3 m1; @@ -788,7 +788,7 @@ void tst_QMatrix::transposed3x3() } // Test matrix 4x4 transpose operations. -void tst_QMatrix::transposed4x4() +void tst_QMatrixNxN::transposed4x4() { // Transposing the identity should result in the identity. QMatrix4x4 m1; @@ -807,7 +807,7 @@ void tst_QMatrix::transposed4x4() } // Test matrix 4x3 transpose operations. -void tst_QMatrix::transposed4x3() +void tst_QMatrixNxN::transposed4x3() { QMatrix4x3 m3(uniqueValues4x3); QMatrix3x4 m4 = m3.transposed(); @@ -818,7 +818,7 @@ void tst_QMatrix::transposed4x3() } // Test matrix addition for 2x2 matrices. -void tst_QMatrix::add2x2_data() +void tst_QMatrixNxN::add2x2_data() { QTest::addColumn("m1Values"); QTest::addColumn("m2Values"); @@ -839,7 +839,7 @@ void tst_QMatrix::add2x2_data() QTest::newRow("unique") << (void *)uniqueValues2 << (void *)transposedValues2 << (void *)sumValues; } -void tst_QMatrix::add2x2() +void tst_QMatrixNxN::add2x2() { QFETCH(void *, m1Values); QFETCH(void *, m2Values); @@ -858,7 +858,7 @@ void tst_QMatrix::add2x2() } // Test matrix addition for 3x3 matrices. -void tst_QMatrix::add3x3_data() +void tst_QMatrixNxN::add3x3_data() { QTest::addColumn("m1Values"); QTest::addColumn("m2Values"); @@ -880,7 +880,7 @@ void tst_QMatrix::add3x3_data() QTest::newRow("unique") << (void *)uniqueValues3 << (void *)transposedValues3 << (void *)sumValues; } -void tst_QMatrix::add3x3() +void tst_QMatrixNxN::add3x3() { QFETCH(void *, m1Values); QFETCH(void *, m2Values); @@ -899,7 +899,7 @@ void tst_QMatrix::add3x3() } // Test matrix addition for 4x4 matrices. -void tst_QMatrix::add4x4_data() +void tst_QMatrixNxN::add4x4_data() { QTest::addColumn("m1Values"); QTest::addColumn("m2Values"); @@ -922,7 +922,7 @@ void tst_QMatrix::add4x4_data() QTest::newRow("unique") << (void *)uniqueValues4 << (void *)transposedValues4 << (void *)sumValues; } -void tst_QMatrix::add4x4() +void tst_QMatrixNxN::add4x4() { QFETCH(void *, m1Values); QFETCH(void *, m2Values); @@ -941,7 +941,7 @@ void tst_QMatrix::add4x4() } // Test matrix addition for 4x3 matrices. -void tst_QMatrix::add4x3_data() +void tst_QMatrixNxN::add4x3_data() { QTest::addColumn("m1Values"); QTest::addColumn("m2Values"); @@ -963,7 +963,7 @@ void tst_QMatrix::add4x3_data() QTest::newRow("unique") << (void *)uniqueValues4x3 << (void *)transposedValues3x4 << (void *)sumValues; } -void tst_QMatrix::add4x3() +void tst_QMatrixNxN::add4x3() { QFETCH(void *, m1Values); QFETCH(void *, m2Values); @@ -982,12 +982,12 @@ void tst_QMatrix::add4x3() } // Test matrix subtraction for 2x2 matrices. -void tst_QMatrix::subtract2x2_data() +void tst_QMatrixNxN::subtract2x2_data() { // Use the same test cases as the add test. add2x2_data(); } -void tst_QMatrix::subtract2x2() +void tst_QMatrixNxN::subtract2x2() { QFETCH(void *, m1Values); QFETCH(void *, m2Values); @@ -1015,12 +1015,12 @@ void tst_QMatrix::subtract2x2() } // Test matrix subtraction for 3x3 matrices. -void tst_QMatrix::subtract3x3_data() +void tst_QMatrixNxN::subtract3x3_data() { // Use the same test cases as the add test. add3x3_data(); } -void tst_QMatrix::subtract3x3() +void tst_QMatrixNxN::subtract3x3() { QFETCH(void *, m1Values); QFETCH(void *, m2Values); @@ -1048,12 +1048,12 @@ void tst_QMatrix::subtract3x3() } // Test matrix subtraction for 4x4 matrices. -void tst_QMatrix::subtract4x4_data() +void tst_QMatrixNxN::subtract4x4_data() { // Use the same test cases as the add test. add4x4_data(); } -void tst_QMatrix::subtract4x4() +void tst_QMatrixNxN::subtract4x4() { QFETCH(void *, m1Values); QFETCH(void *, m2Values); @@ -1081,12 +1081,12 @@ void tst_QMatrix::subtract4x4() } // Test matrix subtraction for 4x3 matrices. -void tst_QMatrix::subtract4x3_data() +void tst_QMatrixNxN::subtract4x3_data() { // Use the same test cases as the add test. add4x3_data(); } -void tst_QMatrix::subtract4x3() +void tst_QMatrixNxN::subtract4x3() { QFETCH(void *, m1Values); QFETCH(void *, m2Values); @@ -1114,7 +1114,7 @@ void tst_QMatrix::subtract4x3() } // Test matrix multiplication for 2x2 matrices. -void tst_QMatrix::multiply2x2_data() +void tst_QMatrixNxN::multiply2x2_data() { QTest::addColumn("m1Values"); QTest::addColumn("m2Values"); @@ -1148,7 +1148,7 @@ void tst_QMatrix::multiply2x2_data() QTest::newRow("unique/transposed") << (void *)uniqueValues2 << (void *)transposedValues2 << (void *)uniqueResult; } -void tst_QMatrix::multiply2x2() +void tst_QMatrixNxN::multiply2x2() { QFETCH(void *, m1Values); QFETCH(void *, m2Values); @@ -1163,7 +1163,7 @@ void tst_QMatrix::multiply2x2() } // Test matrix multiplication for 3x3 matrices. -void tst_QMatrix::multiply3x3_data() +void tst_QMatrixNxN::multiply3x3_data() { QTest::addColumn("m1Values"); QTest::addColumn("m2Values"); @@ -1197,7 +1197,7 @@ void tst_QMatrix::multiply3x3_data() QTest::newRow("unique/transposed") << (void *)uniqueValues3 << (void *)transposedValues3 << (void *)uniqueResult; } -void tst_QMatrix::multiply3x3() +void tst_QMatrixNxN::multiply3x3() { QFETCH(void *, m1Values); QFETCH(void *, m2Values); @@ -1212,7 +1212,7 @@ void tst_QMatrix::multiply3x3() } // Test matrix multiplication for 4x4 matrices. -void tst_QMatrix::multiply4x4_data() +void tst_QMatrixNxN::multiply4x4_data() { QTest::addColumn("m1Values"); QTest::addColumn("m2Values"); @@ -1246,7 +1246,7 @@ void tst_QMatrix::multiply4x4_data() QTest::newRow("unique/transposed") << (void *)uniqueValues4 << (void *)transposedValues4 << (void *)uniqueResult; } -void tst_QMatrix::multiply4x4() +void tst_QMatrixNxN::multiply4x4() { QFETCH(void *, m1Values); QFETCH(void *, m2Values); @@ -1266,7 +1266,7 @@ void tst_QMatrix::multiply4x4() } // Test matrix multiplication for 4x3 matrices. -void tst_QMatrix::multiply4x3_data() +void tst_QMatrixNxN::multiply4x3_data() { QTest::addColumn("m1Values"); QTest::addColumn("m2Values"); @@ -1294,7 +1294,7 @@ void tst_QMatrix::multiply4x3_data() QTest::newRow("unique/transposed") << (void *)uniqueValues4x3 << (void *)transposedValues3x4 << (void *)uniqueResult; } -void tst_QMatrix::multiply4x3() +void tst_QMatrixNxN::multiply4x3() { QFETCH(void *, m1Values); QFETCH(void *, m2Values); @@ -1312,7 +1312,7 @@ void tst_QMatrix::multiply4x3() } // Test matrix multiplication by a factor for 2x2 matrices. -void tst_QMatrix::multiplyFactor2x2_data() +void tst_QMatrixNxN::multiplyFactor2x2_data() { QTest::addColumn("m1Values"); QTest::addColumn("factor"); @@ -1343,7 +1343,7 @@ void tst_QMatrix::multiplyFactor2x2_data() QTest::newRow("zero") << (void *)values << (qreal)0.0f << (void *)nullValues4; } -void tst_QMatrix::multiplyFactor2x2() +void tst_QMatrixNxN::multiplyFactor2x2() { QFETCH(void *, m1Values); QFETCH(qreal, factor); @@ -1366,7 +1366,7 @@ void tst_QMatrix::multiplyFactor2x2() } // Test matrix multiplication by a factor for 3x3 matrices. -void tst_QMatrix::multiplyFactor3x3_data() +void tst_QMatrixNxN::multiplyFactor3x3_data() { QTest::addColumn("m1Values"); QTest::addColumn("factor"); @@ -1400,7 +1400,7 @@ void tst_QMatrix::multiplyFactor3x3_data() QTest::newRow("zero") << (void *)values << (qreal)0.0f << (void *)nullValues4; } -void tst_QMatrix::multiplyFactor3x3() +void tst_QMatrixNxN::multiplyFactor3x3() { QFETCH(void *, m1Values); QFETCH(qreal, factor); @@ -1423,7 +1423,7 @@ void tst_QMatrix::multiplyFactor3x3() } // Test matrix multiplication by a factor for 4x4 matrices. -void tst_QMatrix::multiplyFactor4x4_data() +void tst_QMatrixNxN::multiplyFactor4x4_data() { QTest::addColumn("m1Values"); QTest::addColumn("factor"); @@ -1460,7 +1460,7 @@ void tst_QMatrix::multiplyFactor4x4_data() QTest::newRow("zero") << (void *)values << (qreal)0.0f << (void *)nullValues4; } -void tst_QMatrix::multiplyFactor4x4() +void tst_QMatrixNxN::multiplyFactor4x4() { QFETCH(void *, m1Values); QFETCH(qreal, factor); @@ -1483,7 +1483,7 @@ void tst_QMatrix::multiplyFactor4x4() } // Test matrix multiplication by a factor for 4x3 matrices. -void tst_QMatrix::multiplyFactor4x3_data() +void tst_QMatrixNxN::multiplyFactor4x3_data() { QTest::addColumn("m1Values"); QTest::addColumn("factor"); @@ -1517,7 +1517,7 @@ void tst_QMatrix::multiplyFactor4x3_data() QTest::newRow("zero") << (void *)values << (qreal)0.0f << (void *)nullValues4x3; } -void tst_QMatrix::multiplyFactor4x3() +void tst_QMatrixNxN::multiplyFactor4x3() { QFETCH(void *, m1Values); QFETCH(qreal, factor); @@ -1540,12 +1540,12 @@ void tst_QMatrix::multiplyFactor4x3() } // Test matrix division by a factor for 2x2 matrices. -void tst_QMatrix::divideFactor2x2_data() +void tst_QMatrixNxN::divideFactor2x2_data() { // Use the same test cases as the multiplyFactor test. multiplyFactor2x2_data(); } -void tst_QMatrix::divideFactor2x2() +void tst_QMatrixNxN::divideFactor2x2() { QFETCH(void *, m1Values); QFETCH(qreal, factor); @@ -1567,12 +1567,12 @@ void tst_QMatrix::divideFactor2x2() } // Test matrix division by a factor for 3x3 matrices. -void tst_QMatrix::divideFactor3x3_data() +void tst_QMatrixNxN::divideFactor3x3_data() { // Use the same test cases as the multiplyFactor test. multiplyFactor3x3_data(); } -void tst_QMatrix::divideFactor3x3() +void tst_QMatrixNxN::divideFactor3x3() { QFETCH(void *, m1Values); QFETCH(qreal, factor); @@ -1594,12 +1594,12 @@ void tst_QMatrix::divideFactor3x3() } // Test matrix division by a factor for 4x4 matrices. -void tst_QMatrix::divideFactor4x4_data() +void tst_QMatrixNxN::divideFactor4x4_data() { // Use the same test cases as the multiplyFactor test. multiplyFactor4x4_data(); } -void tst_QMatrix::divideFactor4x4() +void tst_QMatrixNxN::divideFactor4x4() { QFETCH(void *, m1Values); QFETCH(qreal, factor); @@ -1621,12 +1621,12 @@ void tst_QMatrix::divideFactor4x4() } // Test matrix division by a factor for 4x3 matrices. -void tst_QMatrix::divideFactor4x3_data() +void tst_QMatrixNxN::divideFactor4x3_data() { // Use the same test cases as the multiplyFactor test. multiplyFactor4x3_data(); } -void tst_QMatrix::divideFactor4x3() +void tst_QMatrixNxN::divideFactor4x3() { QFETCH(void *, m1Values); QFETCH(qreal, factor); @@ -1648,12 +1648,12 @@ void tst_QMatrix::divideFactor4x3() } // Test matrix negation for 2x2 matrices. -void tst_QMatrix::negate2x2_data() +void tst_QMatrixNxN::negate2x2_data() { // Use the same test cases as the multiplyFactor test. multiplyFactor2x2_data(); } -void tst_QMatrix::negate2x2() +void tst_QMatrixNxN::negate2x2() { QFETCH(void *, m1Values); @@ -1671,12 +1671,12 @@ void tst_QMatrix::negate2x2() } // Test matrix negation for 3x3 matrices. -void tst_QMatrix::negate3x3_data() +void tst_QMatrixNxN::negate3x3_data() { // Use the same test cases as the multiplyFactor test. multiplyFactor3x3_data(); } -void tst_QMatrix::negate3x3() +void tst_QMatrixNxN::negate3x3() { QFETCH(void *, m1Values); @@ -1694,12 +1694,12 @@ void tst_QMatrix::negate3x3() } // Test matrix negation for 4x4 matrices. -void tst_QMatrix::negate4x4_data() +void tst_QMatrixNxN::negate4x4_data() { // Use the same test cases as the multiplyFactor test. multiplyFactor4x4_data(); } -void tst_QMatrix::negate4x4() +void tst_QMatrixNxN::negate4x4() { QFETCH(void *, m1Values); @@ -1717,12 +1717,12 @@ void tst_QMatrix::negate4x4() } // Test matrix negation for 4x3 matrices. -void tst_QMatrix::negate4x3_data() +void tst_QMatrixNxN::negate4x3_data() { // Use the same test cases as the multiplyFactor test. multiplyFactor4x3_data(); } -void tst_QMatrix::negate4x3() +void tst_QMatrixNxN::negate4x3() { QFETCH(void *, m1Values); @@ -1823,7 +1823,7 @@ static void m4Inverse(const Matrix4& min, Matrix4& mout) } // Test matrix inverted for 4x4 matrices. -void tst_QMatrix::inverted4x4_data() +void tst_QMatrixNxN::inverted4x4_data() { QTest::addColumn("m1Values"); QTest::addColumn("m2Values"); @@ -1866,7 +1866,7 @@ void tst_QMatrix::inverted4x4_data() QTest::newRow("translate") << (void *)translate.v << (void *)inverseTranslate.v << true; } -void tst_QMatrix::inverted4x4() +void tst_QMatrixNxN::inverted4x4() { QFETCH(void *, m1Values); QFETCH(void *, m2Values); @@ -1914,7 +1914,7 @@ void tst_QMatrix::inverted4x4() QCOMPARE(inv, invertible); } -void tst_QMatrix::orthonormalInverse4x4() +void tst_QMatrixNxN::orthonormalInverse4x4() { QMatrix4x4 m1; QVERIFY(matrixFuzzyCompare(m1.inverted(), m1)); @@ -1949,7 +1949,7 @@ void tst_QMatrix::orthonormalInverse4x4() } // Test the generation and use of 4x4 scale matrices. -void tst_QMatrix::scale4x4_data() +void tst_QMatrixNxN::scale4x4_data() { QTest::addColumn("x"); QTest::addColumn("y"); @@ -1991,7 +1991,7 @@ void tst_QMatrix::scale4x4_data() QTest::newRow("complex2D") << (qreal)2.0f << (qreal)-11.0f << (qreal)1.0f << (void *)complexScale2D; } -void tst_QMatrix::scale4x4() +void tst_QMatrixNxN::scale4x4() { QFETCH(qreal, x); QFETCH(qreal, y); @@ -2103,7 +2103,7 @@ void tst_QMatrix::scale4x4() } // Test the generation and use of 4x4 translation matrices. -void tst_QMatrix::translate4x4_data() +void tst_QMatrixNxN::translate4x4_data() { QTest::addColumn("x"); QTest::addColumn("y"); @@ -2137,7 +2137,7 @@ void tst_QMatrix::translate4x4_data() QTest::newRow("complex2D") << (qreal)2.0f << (qreal)-11.0f << (qreal)0.0f << (void *)complexTranslate2D; } -void tst_QMatrix::translate4x4() +void tst_QMatrixNxN::translate4x4() { QFETCH(qreal, x); QFETCH(qreal, y); @@ -2203,7 +2203,7 @@ void tst_QMatrix::translate4x4() } // Test the generation and use of 4x4 rotation matrices. -void tst_QMatrix::rotate4x4_data() +void tst_QMatrixNxN::rotate4x4_data() { QTest::addColumn("angle"); QTest::addColumn("x"); @@ -2326,7 +2326,7 @@ void tst_QMatrix::rotate4x4_data() << (qreal)x << (qreal)y << (qreal)z << (void *)complexRotate; } -void tst_QMatrix::rotate4x4() +void tst_QMatrixNxN::rotate4x4() { QFETCH(qreal, angle); QFETCH(qreal, x); @@ -2441,7 +2441,7 @@ static bool isSame(const QMatrix3x3& m1, const Matrix3& m2) } // Test the computation of normal matrices from 4x4 transformation matrices. -void tst_QMatrix::normalMatrix_data() +void tst_QMatrixNxN::normalMatrix_data() { QTest::addColumn("mValues"); @@ -2488,7 +2488,7 @@ void tst_QMatrix::normalMatrix_data() QTest::newRow("null scale 2") << (void *)nullScaleValues2; QTest::newRow("null scale 3") << (void *)nullScaleValues3; } -void tst_QMatrix::normalMatrix() +void tst_QMatrixNxN::normalMatrix() { QFETCH(void *, mValues); const qreal *values = (const qreal *)mValues; @@ -2529,7 +2529,7 @@ void tst_QMatrix::normalMatrix() } // Test optimized transformations on 4x4 matrices. -void tst_QMatrix::optimizedTransforms() +void tst_QMatrixNxN::optimizedTransforms() { static qreal const translateValues[16] = {1.0f, 0.0f, 0.0f, 4.0f, @@ -2640,7 +2640,7 @@ void tst_QMatrix::optimizedTransforms() } // Test orthographic projections. -void tst_QMatrix::ortho() +void tst_QMatrixNxN::ortho() { QMatrix4x4 m1; m1.ortho(QRect(0, 0, 300, 150)); @@ -2729,7 +2729,7 @@ void tst_QMatrix::ortho() } // Test perspective frustum projections. -void tst_QMatrix::frustum() +void tst_QMatrixNxN::frustum() { QMatrix4x4 m1; m1.frustum(-1.0f, 1.0f, -1.0f, 1.0f, -1.0f, 1.0f); @@ -2765,7 +2765,7 @@ void tst_QMatrix::frustum() } // Test perspective field-of-view projections. -void tst_QMatrix::perspective() +void tst_QMatrixNxN::perspective() { QMatrix4x4 m1; m1.perspective(45.0f, 1.0f, -1.0f, 1.0f); @@ -2801,7 +2801,7 @@ void tst_QMatrix::perspective() } // Test left-handed vs right-handed coordinate flipping. -void tst_QMatrix::flipCoordinates() +void tst_QMatrixNxN::flipCoordinates() { QMatrix4x4 m1; m1.flipCoordinates(); @@ -2828,7 +2828,7 @@ void tst_QMatrix::flipCoordinates() } // Test conversion of generic matrices to and from the non-generic types. -void tst_QMatrix::convertGeneric() +void tst_QMatrixNxN::convertGeneric() { QMatrix4x3 m1(uniqueValues4x3); @@ -2860,7 +2860,7 @@ void tst_QMatrix::convertGeneric() QVERIFY(isSame(m11, conv4x4)); } -void tst_QMatrix::extractAxisRotation_data() +void tst_QMatrixNxN::extractAxisRotation_data() { QTest::addColumn("x"); QTest::addColumn("y"); @@ -2893,7 +2893,7 @@ void tst_QMatrix::extractAxisRotation_data() QTest::newRow("1, 1, 1, 300 deg") << 1.0f << 1.0f << 1.0f << 300.0f; } -void tst_QMatrix::extractAxisRotation() +void tst_QMatrixNxN::extractAxisRotation() { QFETCH(float, x); QFETCH(float, y); @@ -2922,7 +2922,7 @@ void tst_QMatrix::extractAxisRotation() } } -void tst_QMatrix::extractTranslation_data() +void tst_QMatrixNxN::extractTranslation_data() { QTest::addColumn("rotation"); QTest::addColumn("x"); @@ -2948,7 +2948,7 @@ void tst_QMatrix::extractTranslation_data() QTest::newRow("rotZ 75, rotX 25, rotY 45, 100, 50, 25") << m1 << 100.0f << 50.0f << 25.0f; } -void tst_QMatrix::extractTranslation() +void tst_QMatrixNxN::extractTranslation() { QFETCH(QMatrix4x4, rotation); QFETCH(float, x); @@ -2995,7 +2995,7 @@ struct Matrix4x4 }; // Test the inferring of special matrix types. -void tst_QMatrix::inferSpecialType_data() +void tst_QMatrixNxN::inferSpecialType_data() { QTest::addColumn("mValues"); QTest::addColumn("flagBits"); @@ -3043,7 +3043,7 @@ void tst_QMatrix::inferSpecialType_data() QTest::newRow("below") << (void *)belowValues << (int)General; } -void tst_QMatrix::inferSpecialType() +void tst_QMatrixNxN::inferSpecialType() { QFETCH(void *, mValues); QFETCH(int, flagBits); @@ -3054,7 +3054,7 @@ void tst_QMatrix::inferSpecialType() QCOMPARE(reinterpret_cast(&m)->flagBits, flagBits); } -void tst_QMatrix::columnsAndRows() +void tst_QMatrixNxN::columnsAndRows() { QMatrix4x4 m1(uniqueValues4); @@ -3102,7 +3102,7 @@ void tst_QMatrix::columnsAndRows() // Test converting QMatrix objects into QMatrix4x4 and then // checking that transformations in the original perform the // equivalent transformations in the new matrix. -void tst_QMatrix::convertQMatrix() +void tst_QMatrixNxN::convertQMatrix() { QMatrix m1; m1.translate(-3.5, 2.0); @@ -3149,7 +3149,7 @@ void tst_QMatrix::convertQMatrix() // Test converting QTransform objects into QMatrix4x4 and then // checking that transformations in the original perform the // equivalent transformations in the new matrix. -void tst_QMatrix::convertQTransform() +void tst_QMatrixNxN::convertQTransform() { QTransform m1; m1.translate(-3.5, 2.0); @@ -3197,7 +3197,7 @@ void tst_QMatrix::convertQTransform() } // Test filling matrices with specific values. -void tst_QMatrix::fill() +void tst_QMatrixNxN::fill() { QMatrix4x4 m1; m1.fill(0.0f); @@ -3224,7 +3224,7 @@ void tst_QMatrix::fill() } // Test the mapRect() function for QRect and QRectF. -void tst_QMatrix::mapRect_data() +void tst_QMatrixNxN::mapRect_data() { QTest::addColumn("x"); QTest::addColumn("y"); @@ -3236,7 +3236,7 @@ void tst_QMatrix::mapRect_data() QTest::newRow("rect") << (qreal)1.0f << (qreal)-20.5f << (qreal)100.0f << (qreal)63.75f; } -void tst_QMatrix::mapRect() +void tst_QMatrixNxN::mapRect() { QFETCH(qreal, x); QFETCH(qreal, y); @@ -3334,12 +3334,12 @@ void tst_QMatrix::mapRect() QVERIFY(mri == tri); } -class tst_QMatrix4x4Properties : public QObject +class tst_QMatrixNxN4x4Properties : public QObject { Q_OBJECT Q_PROPERTY(QMatrix4x4 matrix READ matrix WRITE setMatrix) public: - tst_QMatrix4x4Properties(QObject *parent = 0) : QObject(parent) {} + tst_QMatrixNxN4x4Properties(QObject *parent = 0) : QObject(parent) {} QMatrix4x4 matrix() const { return m; } void setMatrix(const QMatrix4x4& value) { m = value; } @@ -3349,9 +3349,9 @@ private: }; // Test getting and setting matrix properties via the metaobject system. -void tst_QMatrix::properties() +void tst_QMatrixNxN::properties() { - tst_QMatrix4x4Properties obj; + tst_QMatrixNxN4x4Properties obj; QMatrix4x4 m1(uniqueValues4); obj.setMatrix(m1); @@ -3366,7 +3366,7 @@ void tst_QMatrix::properties() QVERIFY(isSame(m2, transposedValues4)); } -void tst_QMatrix::metaTypes() +void tst_QMatrixNxN::metaTypes() { QVERIFY(QMetaType::type("QMatrix4x4") == QMetaType::QMatrix4x4); @@ -3378,6 +3378,6 @@ void tst_QMatrix::metaTypes() QVERIFY(qMetaTypeId() == QMetaType::QMatrix4x4); } -QTEST_APPLESS_MAIN(tst_QMatrix) +QTEST_APPLESS_MAIN(tst_QMatrixNxN) #include "tst_qmatrixnxn.moc" -- cgit v1.2.3 From 1070d82e13c43accf10ef24d5bbb82d681c1cf4f Mon Sep 17 00:00:00 2001 From: Bill King Date: Thu, 13 Aug 2009 15:06:41 +1000 Subject: Fixes proper quoting under odbc. Query the database for the quoting charachter, don't assume you know what it is. Reviewed-by: Justin McPherson --- src/sql/drivers/odbc/qsql_odbc.cpp | 16 +++++----------- 1 file changed, 5 insertions(+), 11 deletions(-) diff --git a/src/sql/drivers/odbc/qsql_odbc.cpp b/src/sql/drivers/odbc/qsql_odbc.cpp index 8eb2e15cc..6a8609e2f 100644 --- a/src/sql/drivers/odbc/qsql_odbc.cpp +++ b/src/sql/drivers/odbc/qsql_odbc.cpp @@ -2400,18 +2400,12 @@ QVariant QODBCDriver::handle() const QString QODBCDriver::escapeIdentifier(const QString &identifier, IdentifierType) const { + QChar quote = d->quoteChar(); QString res = identifier; - if (d->isMySqlServer) { - if(!identifier.isEmpty() && !identifier.startsWith(QLatin1Char('`')) && !identifier.endsWith(QLatin1Char('`')) ) { - res.prepend(QLatin1Char('`')).append(QLatin1Char('`')); - res.replace(QLatin1Char('.'), QLatin1String("`.`")); - } - } else { - if(!identifier.isEmpty() && !identifier.startsWith(QLatin1Char('"')) && !identifier.endsWith(QLatin1Char('"')) ) { - res.replace(QLatin1Char('"'), QLatin1String("\"\"")); - res.prepend(QLatin1Char('"')).append(QLatin1Char('"')); - res.replace(QLatin1Char('.'), QLatin1String("\".\"")); - } + if(!identifier.isEmpty() && !identifier.startsWith(quote) && !identifier.endsWith(quote) ) { + res.replace(quote, QString(quote)+QString(quote)); + res.prepend(quote).append(quote); + res.replace(QLatin1Char('.'), QString(quote)+QLatin1Char('.')+QString(quote)); } return res; } -- cgit v1.2.3 From de088b5a7f7b57e568399334667b14bfc9e7b893 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Thu, 13 Aug 2009 07:54:40 +0200 Subject: Get the pinchzoom working again Touch events on scrollarea based classes should enable touch on the viewport and handle the events in a viewportEvent() reimplementation. --- examples/multitouch/pinchzoom/graphicsview.cpp | 6 +++--- examples/multitouch/pinchzoom/graphicsview.h | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/examples/multitouch/pinchzoom/graphicsview.cpp b/examples/multitouch/pinchzoom/graphicsview.cpp index 3d0e49f94..969f6045f 100644 --- a/examples/multitouch/pinchzoom/graphicsview.cpp +++ b/examples/multitouch/pinchzoom/graphicsview.cpp @@ -47,11 +47,11 @@ GraphicsView::GraphicsView(QGraphicsScene *scene, QWidget *parent) : QGraphicsView(scene, parent) { - setAttribute(Qt::WA_AcceptTouchEvents); + viewport()->setAttribute(Qt::WA_AcceptTouchEvents); setDragMode(ScrollHandDrag); } -bool GraphicsView::event(QEvent *event) +bool GraphicsView::viewportEvent(QEvent *event) { switch (event->type()) { case QEvent::TouchBegin: @@ -72,5 +72,5 @@ bool GraphicsView::event(QEvent *event) default: break; } - return QGraphicsView::event(event); + return QGraphicsView::viewportEvent(event); } diff --git a/examples/multitouch/pinchzoom/graphicsview.h b/examples/multitouch/pinchzoom/graphicsview.h index 928fd164c..e4ca65d73 100644 --- a/examples/multitouch/pinchzoom/graphicsview.h +++ b/examples/multitouch/pinchzoom/graphicsview.h @@ -49,5 +49,5 @@ class GraphicsView : public QGraphicsView public: GraphicsView(QGraphicsScene *scene = 0, QWidget *parent = 0); - bool event(QEvent *event); + bool viewportEvent(QEvent *event); }; -- cgit v1.2.3 From 82d0395ad1ef78eee67ebfe74e8976e620f82356 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Thu, 13 Aug 2009 17:37:04 +1000 Subject: Compile with QT_KEYPAD_NAVIGATION defined Also, try not to regress in functionality (which the last compile fix did just a little) Reviewed-by: Thomas Hartmann --- src/gui/widgets/qdatetimeedit.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/gui/widgets/qdatetimeedit.cpp b/src/gui/widgets/qdatetimeedit.cpp index ae3af31a7..2900d39b2 100644 --- a/src/gui/widgets/qdatetimeedit.cpp +++ b/src/gui/widgets/qdatetimeedit.cpp @@ -1086,6 +1086,7 @@ void QDateTimeEdit::keyPressEvent(QKeyEvent *event) //hide cursor d->edit->d_func()->setCursorVisible(false); + d->edit->d_func()->control->setCursorBlinkPeriod(0); d->setSelected(0); } } @@ -1106,9 +1107,7 @@ void QDateTimeEdit::keyPressEvent(QKeyEvent *event) //hide cursor d->edit->d_func()->setCursorVisible(false); - if (d->edit->d_func()->cursorTimer > 0) - killTimer(d->edit->d_func()->cursorTimer); - d->edit->d_func()->cursorTimer = 0; + d->edit->d_func()->control->setCursorBlinkPeriod(0); d->setSelected(0); oldCurrent = 0; -- cgit v1.2.3 From ff14068a565396789bf43d4fbc752a643ebcb357 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Thu, 13 Aug 2009 09:59:05 +0200 Subject: fix tab and hold for Windows CE and scrollbars Task-number: 258378 Reviewed-by: Maurice --- src/gui/widgets/qscrollbar.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/gui/widgets/qscrollbar.cpp b/src/gui/widgets/qscrollbar.cpp index 390d1b826..37525e2f1 100644 --- a/src/gui/widgets/qscrollbar.cpp +++ b/src/gui/widgets/qscrollbar.cpp @@ -431,6 +431,12 @@ void QScrollBarPrivate::init() q->setSizePolicy(sp); q->setAttribute(Qt::WA_WState_OwnSizePolicy, false); q->setAttribute(Qt::WA_OpaquePaintEvent); + +#if !defined(QT_NO_CONTEXTMENU) && defined(Q_WS_WINCE) + if (!q->style()->styleHint(QStyle::SH_ScrollBar_ContextMenu, 0, q)) { + q->setContextMenuPolicy(Qt::PreventContextMenu); + } +#endif } #ifndef QT_NO_CONTEXTMENU -- cgit v1.2.3 From b31ba48ffb7ee54949d7a5895de4e18a4e48ee5c Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Thu, 13 Aug 2009 10:34:30 +0200 Subject: QPropertyAnimation: refactor of the default-value code --- src/corelib/animation/qpropertyanimation.cpp | 5 +++ src/corelib/animation/qvariantanimation.cpp | 65 +++++++++++----------------- src/corelib/animation/qvariantanimation_p.h | 4 +- 3 files changed, 33 insertions(+), 41 deletions(-) diff --git a/src/corelib/animation/qpropertyanimation.cpp b/src/corelib/animation/qpropertyanimation.cpp index 598e994e8..51fd38739 100644 --- a/src/corelib/animation/qpropertyanimation.cpp +++ b/src/corelib/animation/qpropertyanimation.cpp @@ -294,6 +294,11 @@ void QPropertyAnimation::updateState(QAbstractAnimation::State oldState, // update the default start value if (oldState == Stopped) { d->setDefaultStartValue(d->target->property(d->propertyName.constData())); + //let's check if we have a start value and an end value + if (d->direction == Forward && !startValue().isValid() && !d->defaultStartEndValue.isValid()) + qWarning("QPropertyAnimation::updateState: starting an animation without start value"); + if (d->direction == Backward && !endValue().isValid() && !d->defaultStartEndValue.isValid()) + qWarning("QPropertyAnimation::updateState: starting an animation without end value"); } } else if (hash.value(key) == this) { hash.remove(key); diff --git a/src/corelib/animation/qvariantanimation.cpp b/src/corelib/animation/qvariantanimation.cpp index e64731819..fc11815a6 100644 --- a/src/corelib/animation/qvariantanimation.cpp +++ b/src/corelib/animation/qvariantanimation.cpp @@ -220,52 +220,39 @@ void QVariantAnimationPrivate::updateInterpolator() */ void QVariantAnimationPrivate::recalculateCurrentInterval(bool force/*=false*/) { - // can't interpolate if we have only 1 key value - if ((keyValues.count() + (defaultStartValue.isValid() ? 1 : 0)) <=1) + // can't interpolate if we don't have at least 2 values + if ((keyValues.count() + (defaultStartEndValue.isValid() ? 1 : 0)) < 2) return; const qreal progress = easing.valueForProgress(((duration == 0) ? qreal(1) : qreal(currentTime) / qreal(duration))); - if (force || progress < currentInterval.start.first || progress > currentInterval.end.first) { + //0 and 1 are still the boundaries + if (force || (currentInterval.start.first > 0 && progress < currentInterval.start.first) + || (currentInterval.end.first < 1 && progress > currentInterval.end.first)) { //let's update currentInterval QVariantAnimation::KeyValues::const_iterator it = qLowerBound(keyValues.constBegin(), - keyValues.constEnd(), - qMakePair(progress, QVariant()), - animationValueLessThan); - if (it == keyValues.constEnd()) { - if (direction == QVariantAnimation::Backward && defaultStartValue.isValid()) { - --it; - if (it->first == 1) { - //we have an end value (item with progress = 1) - currentInterval.start = *(it-1); - currentInterval.end = *it; - } else if (direction == QVariantAnimation::Backward && defaultStartValue.isValid()) { - //the default start value should be used as the default end value - currentInterval.start = *it; - currentInterval.end = qMakePair(qreal(1), defaultStartValue); - } else { - ///This should not happen - } - } - } else if (it == keyValues.constBegin()) { - if (it+1 != keyValues.constEnd() && (it->first == progress || it->first == 0)) { - //the item pointed to by it is the start element in the range - //we also test if the current element is for progress 0 (ie the real start) because - //some easing curves might get the progress below 0. + keyValues.constEnd(), + qMakePair(progress, QVariant()), + animationValueLessThan); + if (it == keyValues.constBegin()) { + //the item pointed to by it is the start element in the range + if (it->first == 0 && keyValues.count() > 1) { currentInterval.start = *it; currentInterval.end = *(it+1); - } else if (defaultStartValue.isValid()) { - if (direction == QVariantAnimation::Forward) { - //we should have an end value - currentInterval.start = qMakePair(qreal(0), defaultStartValue); - currentInterval.end = *it; - } else { - //we should have a start value - currentInterval.start = *it; - currentInterval.end = qMakePair(qreal(1), defaultStartValue); - } } else { - ///this should not happen + currentInterval.start = qMakePair(qreal(0), defaultStartEndValue); + currentInterval.end = *it; + } + } else if (it == keyValues.constEnd()) { + --it; //position the iterator on the last item + if (it->first == 1 && keyValues.count() > 1) { + //we have an end value (item with progress = 1) + currentInterval.start = *(it-1); + currentInterval.end = *it; + } else { + //we use the default end value here + currentInterval.start = *it; + currentInterval.end = qMakePair(qreal(1), defaultStartEndValue); } } else { currentInterval.start = *(it-1); @@ -329,9 +316,9 @@ void QVariantAnimationPrivate::setValueAt(qreal step, const QVariant &value) recalculateCurrentInterval(/*force=*/true); } -void QVariantAnimationPrivate::setDefaultStartValue(const QVariant &value) +void QVariantAnimationPrivate::setDefaultStartEndValue(const QVariant &value) { - defaultStartValue = value; + defaultStartEndValue = value; recalculateCurrentInterval(/*force=*/true); } diff --git a/src/corelib/animation/qvariantanimation_p.h b/src/corelib/animation/qvariantanimation_p.h index 9c9d25bde..ef57a4cab 100644 --- a/src/corelib/animation/qvariantanimation_p.h +++ b/src/corelib/animation/qvariantanimation_p.h @@ -76,14 +76,14 @@ public: return q->d_func(); } - void setDefaultStartValue(const QVariant &value); + void setDefaultStartEndValue(const QVariant &value); int duration; QEasingCurve easing; QVariantAnimation::KeyValues keyValues; QVariant currentValue; - QVariant defaultStartValue; + QVariant defaultStartEndValue; //this is used to keep track of the KeyValue interval in which we currently are struct -- cgit v1.2.3 From bd2cc45fefb024f91f9c0736c5abfe853e49b540 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Thu, 13 Aug 2009 10:47:32 +0200 Subject: Fix compile issue for animation framework --- src/corelib/animation/qpropertyanimation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/animation/qpropertyanimation.cpp b/src/corelib/animation/qpropertyanimation.cpp index 51fd38739..0c1feee99 100644 --- a/src/corelib/animation/qpropertyanimation.cpp +++ b/src/corelib/animation/qpropertyanimation.cpp @@ -293,7 +293,7 @@ void QPropertyAnimation::updateState(QAbstractAnimation::State oldState, hash.insert(key, this); // update the default start value if (oldState == Stopped) { - d->setDefaultStartValue(d->target->property(d->propertyName.constData())); + d->setDefaultStartEndValue(d->target->property(d->propertyName.constData())); //let's check if we have a start value and an end value if (d->direction == Forward && !startValue().isValid() && !d->defaultStartEndValue.isValid()) qWarning("QPropertyAnimation::updateState: starting an animation without start value"); -- cgit v1.2.3 From bf6cf7cd8723f05037c461106e4dc8da75889509 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Thu, 13 Aug 2009 10:55:49 +0200 Subject: Fix compiler warning We need to remove Zm200 from compiler flags before adding Zm1200 Reviewed-by: Marius Storm-Olsen --- demos/boxes/boxes.pro | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/demos/boxes/boxes.pro b/demos/boxes/boxes.pro index 33f1f1428..59c91322d 100644 --- a/demos/boxes/boxes.pro +++ b/demos/boxes/boxes.pro @@ -42,6 +42,8 @@ wince*: { } win32-msvc* { - QMAKE_CXXFLAGS += /Zm1200 - QMAKE_CFLAGS += /Zm1200 + QMAKE_CXXFLAGS -= -Zm200 + QMAKE_CFLAGS -= -Zm200 + QMAKE_CXXFLAGS += -Zm1200 + QMAKE_CFLAGS += -Zm1200 } -- cgit v1.2.3 From 7f1cba82a377d79ddb2fd2c40e1782ae9fc125f6 Mon Sep 17 00:00:00 2001 From: Morten Sorvig Date: Thu, 13 Aug 2009 12:37:39 +0200 Subject: Pick a suitable default architecture for qmake-based applications. If the Qt package contains one of x86 and x86_64, pick that one. If it contains both then use the compiler default. Make a similiar decision for PowerPC-based systems. Note that this logic assumes that Qt has been configured with an architecture that is usable on the system. Reviewed-by: Marius Storm-Olsen --- mkspecs/features/mac/default_post.prf | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/mkspecs/features/mac/default_post.prf b/mkspecs/features/mac/default_post.prf index ea9e9bd60..210a70446 100644 --- a/mkspecs/features/mac/default_post.prf +++ b/mkspecs/features/mac/default_post.prf @@ -1,2 +1,18 @@ load(default_post) !no_objective_c:CONFIG += objective_c + +# Pick a suitable default architecture for qmake-based applications. +# If the Qt package contains one of x86 and x86_64, pick that one. If it +# contains both then use the compiler default. Make a similiar decision for +# PowerPC-based systems. Note that this logic assumes that Qt has been +# configured with an architecture that is usable on the system. +message(hei $$QT_CONFIG ) +qt:!isEmpty(QT_CONFIG) { + contains(QMAKE_HOST.arch, ppc) { + !contains(QT_CONFIG, ppc64):contains(QT_CONFIG, ppc):CONFIG += ppc + contains(QT_CONFIG, ppc64):!contains(QT_CONFIG, ppc):CONFIG += ppc64 + } else { + !contains(QT_CONFIG, x86_64):contains(QT_CONFIG, x86):CONFIG += x86 + contains(QT_CONFIG, x86_64):!contains(QT_CONFIG, x86):CONFIG += x86_64 + } +} -- cgit v1.2.3 From c090e68c25f6c5ffeac33ba81e50147800200b59 Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Thu, 13 Aug 2009 13:06:03 +0200 Subject: Fix to autotest of QDockWidget Mac needs a bit more time to update the widgets when they are redocked --- tests/auto/qdockwidget/tst_qdockwidget.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/qdockwidget/tst_qdockwidget.cpp b/tests/auto/qdockwidget/tst_qdockwidget.cpp index e0548a788..686f62f28 100644 --- a/tests/auto/qdockwidget/tst_qdockwidget.cpp +++ b/tests/auto/qdockwidget/tst_qdockwidget.cpp @@ -598,7 +598,7 @@ void tst_QDockWidget::visibilityChanged() QCOMPARE(spy.count(), 0); mw.addDockWidget(Qt::RightDockWidgetArea, &dw2); - qApp->processEvents(); + QTest::qWait(200); QCOMPARE(spy.count(), 1); QCOMPARE(spy.at(0).at(0).toBool(), true); } -- cgit v1.2.3 From 200f20d1503b6739f05916b606168da67726ffa6 Mon Sep 17 00:00:00 2001 From: Morten Sorvig Date: Thu, 13 Aug 2009 13:08:46 +0200 Subject: Remove yet another forgotten debug message. --- mkspecs/features/mac/default_post.prf | 1 - 1 file changed, 1 deletion(-) diff --git a/mkspecs/features/mac/default_post.prf b/mkspecs/features/mac/default_post.prf index 210a70446..499976228 100644 --- a/mkspecs/features/mac/default_post.prf +++ b/mkspecs/features/mac/default_post.prf @@ -6,7 +6,6 @@ load(default_post) # contains both then use the compiler default. Make a similiar decision for # PowerPC-based systems. Note that this logic assumes that Qt has been # configured with an architecture that is usable on the system. -message(hei $$QT_CONFIG ) qt:!isEmpty(QT_CONFIG) { contains(QMAKE_HOST.arch, ppc) { !contains(QT_CONFIG, ppc64):contains(QT_CONFIG, ppc):CONFIG += ppc -- cgit v1.2.3 From f8d84ba4bfc71550879c117f96289ce80d74b7db Mon Sep 17 00:00:00 2001 From: Kavindra Devi Palaraja Date: Thu, 13 Aug 2009 15:05:18 +0200 Subject: Doc - Some cleanup on the documentation of QWebElement Reviewed-By: Simon Hausmann --- src/3rdparty/webkit/WebKit/qt/Api/qwebelement.cpp | 378 +++++++++++++--------- 1 file changed, 220 insertions(+), 158 deletions(-) diff --git a/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.cpp b/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.cpp index 1dfb4098a..dd90f3976 100644 --- a/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.cpp +++ b/src/3rdparty/webkit/WebKit/qt/Api/qwebelement.cpp @@ -53,45 +53,57 @@ public: /*! \class QWebElement \since 4.6 - \brief The QWebElement class provides convenient access to DOM elements in a QWebFrame. + \brief The QWebElement class provides convenient access to DOM elements in + a QWebFrame. - QWebElement is the main class to easily access to the document model. - The document model is represented by a tree-like structure of DOM elements. - The root of the tree is called the document element and can be accessed using QWebFrame::documentElement(). - You can reach specific elements using findAll() and findFirst(); the elements - are identified through CSS selectors. + A QWebElement object allows easy access to the document model, represented + by a tree-like structure of DOM elements. The root of the tree is called + the document element and can be accessed using + QWebFrame::documentElement(). + + Specific elements can be accessed using findAll() and findFirst(). These + elements are identified using CSS selectors. The code snippet below + demonstrates the use of findAll(). \snippet webkitsnippets/webelement/main.cpp FindAll - The first list contains all \c span elements in the document. The second list contains - \c span elements that are children of \c p, classified with \c intro. + The first list contains all \c span elements in the document. The second + list contains \c span elements that are children of \c p, classified with + \c intro. - Using findFirst() is more efficient than calling findAll() and extracting the first element - only in the returned list. + Using findFirst() is more efficient than calling findAll(), and extracting + the first element only in the list returned. - Alternatively you can manually traverse the document using firstChild() and nextSibling(): + Alternatively you can traverse the document manually using firstChild() and + nextSibling(): \snippet webkitsnippets/webelement/main.cpp Traversing with QWebElement - The underlying content of QWebElement is explicitly shared. Creating a copy of a QWebElement - does not create a copy of the content. Instead, both instances point to the same element. + The underlying content of QWebElement is explicitly shared. Creating a copy + of a QWebElement does not create a copy of the content. Instead, both + instances point to the same element. - The element's attributes can be read using attribute() and modified with setAttribute(). + The element's attributes can be read using attribute() and modified with + setAttribute(). - The contents of child elements can be converted to plain text with toPlainText() and to - XHTML using toInnerXml(). To also include the element's tag in the output, use toOuterXml(). + The contents of child elements can be converted to plain text with + toPlainText(); to XHTML using toInnerXml(). To include the element's tag in + the output, use toOuterXml(). - It is possible to replace the contents using setPlainText() and setInnerXml(). To replace - the element itself and its contents, use setOuterXml(). + It is possible to replace the contents of child elements using + setPlainText() and setInnerXml(). To replace the element itself and its + contents, use setOuterXml(). - In the JavaScript DOM interfaces, elements can have additional functions depending on their - type. For example an HTML form element can be triggered to submit the entire form to the - web server using the submit() function. A list of these special functions can be obtained - in QWebElement using functions(); they can be invoked using callFunction(). + In the JavaScript DOM interfaces, elements can have additional functions + depending on their type. For example, an HTML form element can be triggered + to submit the entire form to the web server using the submit() function. A + list of these special functions can be obtained in QWebElement using + functions(); they can be invoked using callFunction(). - Similarly element specific properties can be obtained using scriptableProperties() and - read/written using scriptableProperty()/setScriptableProperty(). + Similarly, element specific properties can be obtained using + scriptableProperties() and read or written using scriptableProperty() or + setScriptableProperty(). */ /*! @@ -156,7 +168,7 @@ QWebElement &QWebElement::operator=(const QWebElement &other) } /*! - Destroys the element. The underlying DOM element is not destroyed. + Destroys the element. However, the underlying DOM element is not destroyed. */ QWebElement::~QWebElement() { @@ -176,7 +188,7 @@ bool QWebElement::operator!=(const QWebElement& o) const } /*! - Returns true if the element is a null element; false otherwise. + Returns true if the element is a null element; otherwise returns false. */ bool QWebElement::isNull() const { @@ -184,13 +196,16 @@ bool QWebElement::isNull() const } /*! - Returns a new list of child elements matching the given CSS selector \a selectorQuery. - If there are no matching elements, an empty list is returned. + Returns a new list of child elements matching the given CSS selector + \a selectorQuery. If there are no matching elements, an empty list is + returned. - \l{http://www.w3.org/TR/REC-CSS2/selector.html#q1}{Standard CSS2 selector} syntax is - used for the query. + \l{http://www.w3.org/TR/REC-CSS2/selector.html#q1}{Standard CSS2 selector} + syntax is used for the query. \note This search is performed recursively. + + \sa findFirst() */ QList QWebElement::findAll(const QString &selectorQuery) const { @@ -212,12 +227,15 @@ QList QWebElement::findAll(const QString &selectorQuery) const } /*! - Returns the first child element that matches the given CSS selector \a selectorQuery. + Returns the first child element that matches the given CSS selector + \a selectorQuery. - \l{http://www.w3.org/TR/REC-CSS2/selector.html#q1}{Standard CSS2 selector} syntax is - used for the query. + \l{http://www.w3.org/TR/REC-CSS2/selector.html#q1}{Standard CSS2 selector} + syntax is used for the query. \note This search is performed recursively. + + \sa findAll() */ QWebElement QWebElement::findFirst(const QString &selectorQuery) const { @@ -231,6 +249,8 @@ QWebElement QWebElement::findFirst(const QString &selectorQuery) const Replaces the existing content of this element with \a text. This is equivalent to setting the HTML innerText property. + + \sa toPlainText() */ void QWebElement::setPlainText(const QString &text) { @@ -245,6 +265,8 @@ void QWebElement::setPlainText(const QString &text) element. This is equivalent to reading the HTML innerText property. + + \sa setPlainText() */ QString QWebElement::toPlainText() const { @@ -254,11 +276,13 @@ QString QWebElement::toPlainText() const } /*! - Replaces the contents of this element as well as its own tag with \a markup. - The string may contain HTML or XML tags, which is parsed and formatted - before insertion into the document. + Replaces the contents of this element as well as its own tag with + \a markup. The string may contain HTML or XML tags, which is parsed and + formatted before insertion into the document. \note This is currently only implemented for (X)HTML elements. + + \sa toOuterXml(), toInnerXml(), setInnerXml() */ void QWebElement::setOuterXml(const QString &markup) { @@ -272,9 +296,11 @@ void QWebElement::setOuterXml(const QString &markup) /*! Returns this element converted to XML, including the start and the end - tag of this element and its attributes. + tags as well as its attributes. - \note This is currently only implemented for (X)HTML elements. + \note This is currently implemented for (X)HTML elements only. + + \sa setOuterXml(), setInnerXml(), toInnerXml() */ QString QWebElement::toOuterXml() const { @@ -285,11 +311,13 @@ QString QWebElement::toOuterXml() const } /*! - Replaces the content of this element with \a markup. - The string may contain HTML or XML tags, which is parsed and formatted - before insertion into the document. + Replaces the contents of this element with \a markup. The string may + contain HTML or XML tags, which is parsed and formatted before insertion + into the document. - \note This is currently only implemented for (X)HTML elements. + \note This is currently implemented for (X)HTML elements only. + + \sa toInnerXml(), toOuterXml(), setOuterXml() */ void QWebElement::setInnerXml(const QString &markup) { @@ -302,10 +330,11 @@ void QWebElement::setInnerXml(const QString &markup) } /*! - Returns the XML between the start and the end tag of this - element. + Returns the XML content between the element's start and end tags. - \note This is currently only implemented for (X)HTML elements. + \note This is currently implemented for (X)HTML elements only. + + \sa setInnerXml(), setOuterXml(), toOuterXml() */ QString QWebElement::toInnerXml() const { @@ -316,8 +345,10 @@ QString QWebElement::toInnerXml() const } /*! - Adds an attribute called \a name with the value \a value. If an attribute - with the same name exists, its value is replaced by \a value. + Adds an attribute with the given \a name and \a value. If an attribute with + the same name exists, its value is replaced by \a value. + + \sa attribute(), attributeNS(), setAttributeNS() */ void QWebElement::setAttribute(const QString &name, const QString &value) { @@ -328,9 +359,11 @@ void QWebElement::setAttribute(const QString &name, const QString &value) } /*! - Adds an attribute called \a name in the namespace described with \a namespaceUri - with the value \a value. If an attribute with the same name exists, its value is - replaced by \a value. + Adds an attribute with the given \a name in \a namespaceUri with \a value. + If an attribute with the same name exists, its value is replaced by + \a value. + + \sa attributeNS(), attribute(), setAttribute() */ void QWebElement::setAttributeNS(const QString &namespaceUri, const QString &name, const QString &value) { @@ -341,8 +374,10 @@ void QWebElement::setAttributeNS(const QString &namespaceUri, const QString &nam } /*! - Returns the attributed called \a name. If the attribute does not exist \a defaultValue is - returned. + Returns the attribute with the given \a name. If the attribute does not + exist, \a defaultValue is returned. + + \sa setAttribute(), setAttributeNS(), attributeNS() */ QString QWebElement::attribute(const QString &name, const QString &defaultValue) const { @@ -355,8 +390,10 @@ QString QWebElement::attribute(const QString &name, const QString &defaultValue) } /*! - Returns the attributed called \a name in the namespace described with \a namespaceUri. - If the attribute does not exist \a defaultValue is returned. + Returns the attribute with the given \a name in \a namespaceUri. If the + attribute does not exist, \a defaultValue is returned. + + \sa setAtributeNS(), setAttribute(), attribute() */ QString QWebElement::attributeNS(const QString &namespaceUri, const QString &name, const QString &defaultValue) const { @@ -369,7 +406,10 @@ QString QWebElement::attributeNS(const QString &namespaceUri, const QString &nam } /*! - Returns true if this element has an attribute called \a name; otherwise returns false. + Returns true if this element has an attribute with the given \a name; + otherwise returns false. + + \sa attribute(), setAttribute() */ bool QWebElement::hasAttribute(const QString &name) const { @@ -379,8 +419,10 @@ bool QWebElement::hasAttribute(const QString &name) const } /*! - Returns true if this element has an attribute called \a name in the namespace described - with \a namespaceUri; otherwise returns false. + Returns true if this element has an attribute with the given \a name, in + \a namespaceUri; otherwise returns false. + + \sa attributeNS(), setAttributeNS() */ bool QWebElement::hasAttributeNS(const QString &namespaceUri, const QString &name) const { @@ -390,7 +432,9 @@ bool QWebElement::hasAttributeNS(const QString &namespaceUri, const QString &nam } /*! - Removes the attribute called \a name from this element. + Removes the attribute with the given \a name from this element. + + \sa attribute(), setAttribute(), hasAttribute() */ void QWebElement::removeAttribute(const QString &name) { @@ -401,8 +445,10 @@ void QWebElement::removeAttribute(const QString &name) } /*! - Removes the attribute called \a name in the namespace described with \a namespaceUri - from this element. + Removes the attribute with the given \a name, in \a namespaceUri, from this + element. + + \sa attributeNS(), setAttributeNS(), hasAttributeNS() */ void QWebElement::removeAttributeNS(const QString &namespaceUri, const QString &name) { @@ -413,7 +459,10 @@ void QWebElement::removeAttributeNS(const QString &namespaceUri, const QString & } /*! - Returns true if the element has any attributes defined; otherwise returns false; + Returns true if the element has any attributes defined; otherwise returns + false; + + \sa attribute(), setAttribute() */ bool QWebElement::hasAttributes() const { @@ -424,6 +473,8 @@ bool QWebElement::hasAttributes() const /*! Returns the geometry of this element, relative to its containing frame. + + \sa tagName() */ QRect QWebElement::geometry() const { @@ -434,6 +485,8 @@ QRect QWebElement::geometry() const /*! Returns the tag name of this element. + + \sa geometry() */ QString QWebElement::tagName() const { @@ -443,7 +496,8 @@ QString QWebElement::tagName() const } /*! - Returns the namespace prefix of the element or an empty string if the element has no namespace prefix. + Returns the namespace prefix of the element. If the element has no\ + namespace prefix, empty string is returned. */ QString QWebElement::prefix() const { @@ -453,8 +507,8 @@ QString QWebElement::prefix() const } /*! - If the element uses namespaces, this function returns the local name of the element; - otherwise it returns an empty string. + Returns the local name of the element. If the element does not use + namespaces, an empty string is returned. */ QString QWebElement::localName() const { @@ -464,7 +518,8 @@ QString QWebElement::localName() const } /*! - Returns the namespace URI of this element or an empty string if the element has no namespace URI. + Returns the namespace URI of this element. If the element has no namespace + URI, an empty string is returned. */ QString QWebElement::namespaceUri() const { @@ -474,8 +529,8 @@ QString QWebElement::namespaceUri() const } /*! - Returns the parent element of this element or a null element if this element - is the root document element. + Returns the parent element of this elemen. If this element is the root + document element, a null element is returned. */ QWebElement QWebElement::parent() const { @@ -485,9 +540,9 @@ QWebElement QWebElement::parent() const } /*! - Returns the first child element of this element. + Returns the element's first child. - \sa lastChild() previousSibling() nextSibling() + \sa lastChild(), previousSibling(), nextSibling() */ QWebElement QWebElement::firstChild() const { @@ -503,9 +558,9 @@ QWebElement QWebElement::firstChild() const } /*! - Returns the last child element of this element. + Returns the element's last child. - \sa firstChild() previousSibling() nextSibling() + \sa firstChild(), previousSibling(), nextSibling() */ QWebElement QWebElement::lastChild() const { @@ -521,9 +576,9 @@ QWebElement QWebElement::lastChild() const } /*! - Returns the next sibling element of this element. + Returns the element's next sibling. - \sa firstChild() previousSibling() lastChild() + \sa firstChild(), previousSibling(), lastChild() */ QWebElement QWebElement::nextSibling() const { @@ -539,9 +594,9 @@ QWebElement QWebElement::nextSibling() const } /*! - Returns the previous sibling element of this element. + Returns the element's previous sibling. - \sa firstChild() nextSibling() lastChild() + \sa firstChild(), nextSibling(), lastChild() */ QWebElement QWebElement::previousSibling() const { @@ -557,7 +612,7 @@ QWebElement QWebElement::previousSibling() const } /*! - Returns the document this element belongs to. + Returns the document which this element belongs to. */ QWebElement QWebElement::document() const { @@ -570,8 +625,8 @@ QWebElement QWebElement::document() const } /*! - Returns the web frame this elements is a part of. If the element is - a null element null is returned. + Returns the web frame which this element is a part of. If the element is a + null element, null is returned. */ QWebFrame *QWebElement::webFrame() const { @@ -647,7 +702,7 @@ static bool setupScriptObject(WebCore::Element* element, ScriptObject& object, S } /*! - Executes the \a scriptSource with this element as the `this' object. + Executes \a scriptSource with this element as \c this object. \sa callFunction() */ @@ -680,9 +735,10 @@ QVariant QWebElement::evaluateScript(const QString& scriptSource) /*! Calls the function with the given \a name and \a arguments. - The underlying DOM element that QWebElement wraps may have dedicated functions depending - on its type. For example a form element can have the "submit" function, that would submit - the form to the destination specified in the HTML. + The underlying DOM element that QWebElement wraps may have dedicated + functions, depending on its type. For example, a form element can have the + \c submit function, that would submit the form to the destination specified + in the HTML. \sa functions() */ @@ -713,7 +769,7 @@ QVariant QWebElement::callFunction(const QString &name, const QVariantList &argu /*! Returns a list of function names this element supports. - The function names returned are the same functions that are callable from the DOM + The function names returned are the same functions callable from the DOM element's JavaScript binding. \sa callFunction() @@ -763,14 +819,14 @@ QStringList QWebElement::functions() const } /*! - Returns the value of the element's \a name property. + Returns the value of the element's \a name property. If no such property + exists, an invalid QVariant is returned. - If no such property exists, the returned variant is invalid. + The return value's property has the same value as the corresponding + property in the element's JavaScript binding with the same name. - The return property has the same value as the corresponding property - in the element's JavaScript binding with the same name. - - Information about all available properties is provided through scriptProperties(). + Information about all available properties is provided through + scriptProperties(). \sa setScriptableProperty(), scriptableProperties() */ @@ -797,10 +853,11 @@ QVariant QWebElement::scriptableProperty(const QString &name) const /*! Sets the value of the element's \a name property to \a value. - Information about all available properties is provided through scriptProperties(). + Information about all available properties is provided through + scriptProperties(). - Setting the property will affect the corresponding property - in the element's JavaScript binding with the same name. + Setting the property will affect the corresponding property in the + element's JavaScript binding with the same name. \sa scriptableProperty(), scriptableProperties() */ @@ -827,8 +884,8 @@ void QWebElement::setScriptableProperty(const QString &name, const QVariant &val /*! Returns a list of property names this element supports. - The function names returned are the same properties that are accessible from the DOM - element's JavaScript binding. + The function names returned are the same properties that are accessible + from the DOM element's JavaScript binding. \sa setScriptableProperty(), scriptableProperty() */ @@ -894,10 +951,12 @@ QStringList QWebElement::scriptableProperties() const This enum describes how QWebElement's styleProperty resolves the given property name. - \value IgnoreCascadingStyles Return the property value as it is defined - in the element, without respecting style inheritance and other CSS rules. - \value RespectCascadingStyles The property's value is determined using - the inheritance and importance rules defined in the document's stylesheet. + \value IgnoreCascadingStyles Return the property value as it is defined in + the element, without respecting style inheritance and other CSS + rules. + \value RespectCascadingStyles The property's value is determined using the + inheritance and importance rules defined in the document's + stylesheet. */ /*! @@ -907,17 +966,17 @@ QStringList QWebElement::scriptableProperties() const This enum describes the priority newly set CSS properties should have when set using QWebElement::setStyleProperty(). - \value NormalStylePriority Define the property without important - priority even if "!important" is explicitly set in \a value. - \value DeclaredStylePriority Define the property respecting the - priority specified in \a value. - \value ImportantStylePriority Define the property to have - an important priority, this is equal to appending "!important" to the value. + \value NormalStylePriority Define the property without important priority + even if "!important" is explicitly set in \a value. + \value DeclaredStylePriority Define the property respecting the priority + specified in \a value. + \value ImportantStylePriority Define the property to have an important + priority. This is equal to appending "!important" to the value. */ /*! - Returns the value of the style named \a name or an empty string if such one - does not exist. + Returns the value of the style with the given \a name. If a style with + \name does not exist, an empty string is returned. If \a rule is IgnoreCascadingStyles, the value defined inside the element (inline in CSS terminology) is returned. @@ -925,14 +984,17 @@ QStringList QWebElement::scriptableProperties() const if \a rule is RespectCascadingStyles, the actual style applied to the element is returned. - In CSS, the cascading part has to do with which CSS rule has priority and - is thus applied. Generally speaking, the last defined rule has priority, - thus an inline style rule has priority over an embedded block style rule, - which in return has priority over an external style rule. + In CSS, the cascading part depends on which CSS rule has priority and is + thus applied. Generally, the last defined rule has priority. Thus, an + inline style rule has priority over an embedded block style rule, which + in return has priority over an external style rule. + + If the "!important" declaration is set on one of those, the declaration + receives highest priority, unless other declarations also use the + "!important" declaration. Then, the last "!important" declaration takes + predecence. - If the !important declaration is set on one of those, the declaration gets - highest priority, unless other declarations also use the !important - declaration, in which the last !important declaration takes predecence. + \sa setStyleProperty() */ QString QWebElement::styleProperty(const QString &name, ResolveRule rule) const { @@ -981,9 +1043,9 @@ QString QWebElement::styleProperty(const QString &name, ResolveRule rule) const } /*! - Sets the value of the style named \a name to \a value. + Sets the value of the style with the given \a name to \a value. - Setting a value, doesn't necessarily mean that it will become the applied + Setting a value, does not necessarily mean that it will become the applied value, due to the fact that the style property's value might have been set earlier with priority in external or embedded style declarations. @@ -998,7 +1060,8 @@ QString QWebElement::styleProperty(const QString &name, ResolveRule rule) const Using NormalStylePriority as \a priority, the property will have normal priority, and any "!important" declaration will be ignored. On the other hand, using ImportantStylePriority sets the important priority even when - not explicit passed in \a value. + it is not explicitly passed in \a value. + By using DeclaredStylePriority as \a priority the property will respect the priority specified in \a value. */ @@ -1035,7 +1098,8 @@ void QWebElement::setStyleProperty(const QString &name, const QString &value, St } /*! - Returns the computed value for style named \a name or an empty string if the style has no such name. + Returns the computed value for style with the given \a name. If a style + with \name does not exist, an empty string is returned. */ QString QWebElement::computedStyleProperty(const QString &name) const { @@ -1083,7 +1147,8 @@ QStringList QWebElement::classes() const } /*! - Returns true if this element has a class called \a name; otherwise returns false. + Returns true if this element has a class with the given \a name; otherwise + returns false. */ bool QWebElement::hasClass(const QString &name) const { @@ -1092,7 +1157,7 @@ bool QWebElement::hasClass(const QString &name) const } /*! - Adds the specified class \a name to the element. + Adds the specified class with the given \a name to the element. */ void QWebElement::addClass(const QString &name) { @@ -1105,7 +1170,7 @@ void QWebElement::addClass(const QString &name) } /*! - Removes the specified class \a name from the element. + Removes the specified class with the given \a name from the element. */ void QWebElement::removeClass(const QString &name) { @@ -1118,8 +1183,8 @@ void QWebElement::removeClass(const QString &name) } /*! - Adds the specified class \a name if it is not present, - removes it if it is already present. + Adds the specified class with the given \a name if it is not present. If + the class is already present, it will be removed. */ void QWebElement::toggleClass(const QString &name) { @@ -1134,11 +1199,11 @@ void QWebElement::toggleClass(const QString &name) } /*! - Appends \a element as the element's last child. + Appends the given \a element as the element's last child. - If \a element is the child of another element, it is re-parented - to this element. If \a element is a child of this element, then - its position in the list of children is changed. + If \a element is the child of another element, it is re-parented to this + element. If \a element is a child of this element, then its position in + the list of children is changed. Calling this function on a null element does nothing. @@ -1178,9 +1243,9 @@ void QWebElement::appendInside(const QString &markup) /*! Prepends \a element as the element's first child. - If \a element is the child of another element, it is re-parented - to this element. If \a element is a child of this element, then - its position in the list of children is changed. + If \a element is the child of another element, it is re-parented to this + element. If \a element is a child of this element, then its position in + the list of children is changed. Calling this function on a null element does nothing. @@ -1227,10 +1292,10 @@ void QWebElement::prependInside(const QString &markup) /*! - Inserts \a element before this element. + Inserts the given \a element before this element. - If \a element is the child of another element, it is re-parented - to the parent of this element. + If \a element is the child of another element, it is re-parented to the + parent of this element. Calling this function on a null element does nothing. @@ -1274,10 +1339,10 @@ void QWebElement::prependOutside(const QString &markup) } /*! - Inserts \a element after this element. + Inserts the given \a element after this element. - If \a element is the child of another element, it is re-parented - to the parent of this element. + If \a element is the child of another element, it is re-parented to the + parent of this element. Calling this function on a null element does nothing. @@ -1342,11 +1407,10 @@ QWebElement QWebElement::clone() const } /*! - Removes this element from the document and returns a reference - to this. + Removes this element from the document and returns a reference to it. - The element is still valid after removal, and can be inserted into - other parts of the document. + The element is still valid after removal, and can be inserted into other + parts of the document. \sa removeChildren(), removeFromDocument() */ @@ -1362,8 +1426,7 @@ QWebElement &QWebElement::takeFromDocument() } /*! - Removes this element from the document and makes this - a null element. + Removes this element from the document and makes it a null element. \sa removeChildren(), takeFromDocument() */ @@ -1414,9 +1477,10 @@ static RefPtr findInsertionPoint(PassRefPtr root) } /*! - Enclose the contents of this element in \a element as the child - of the deepest descendant element within the structure of the - first element provided. + Encloses the contents of this element with \a element. This element becomes + the child of the deepest descendant within \a element. + + ### illustration \sa encloseWith() */ @@ -1446,9 +1510,8 @@ void QWebElement::encloseContentsWith(const QWebElement &element) } /*! - Enclose the contents of this element in the result of parsing - \a markup as the child of the deepest descendant element within - the structure of the first element provided. + Encloses the contents of this element with the result of parsing \a markup. + This element becomes the child of the deepest descendant within \a markup. \sa encloseWith() */ @@ -1490,9 +1553,8 @@ void QWebElement::encloseContentsWith(const QString &markup) } /*! - Enclose this element in \a element as the child of the deepest - descendant element within the structure of the first element - provided. + Encloses this element with \a element. This element becomes the child of + the deepest descendant within \a element. \sa replace() */ @@ -1523,8 +1585,8 @@ void QWebElement::encloseWith(const QWebElement &element) } /*! - Enclose this element in the result of parsing \a markup, - as the last child. + Encloses this element with the result of parsing \a markup. This element + becomes the child of the deepest descendant within \a markup. \sa replace() */ @@ -1569,8 +1631,7 @@ void QWebElement::encloseWith(const QString &markup) /*! Replaces this element with \a element. - It is not possible to replace the , , or - elements using this method. + This method will not replace the , or elements. \sa encloseWith() */ @@ -1586,8 +1647,7 @@ void QWebElement::replace(const QWebElement &element) /*! Replaces this element with the result of parsing \a markup. - It is not possible to replace the , , or - elements using this method. + This method will not replace the , or elements. \sa encloseWith() */ @@ -1603,11 +1663,13 @@ void QWebElement::replace(const QString &markup) /*! \fn inline bool QWebElement::operator==(const QWebElement& o) const; - Returns true if this element points to the same underlying DOM object than \a o; otherwise returns false. + Returns true if this element points to the same underlying DOM object as + \a o; otherwise returns false. */ /*! \fn inline bool QWebElement::operator!=(const QWebElement& o) const; - Returns true if this element points to a different underlying DOM object than \a o; otherwise returns false. + Returns true if this element points to a different underlying DOM object + than \a o; otherwise returns false. */ -- cgit v1.2.3 From be4c288579314e2c11bd284d03a45007c2d3b300 Mon Sep 17 00:00:00 2001 From: Martin Smith Date: Thu, 13 Aug 2009 15:08:24 +0200 Subject: qdoc: Disabled reporting the NOTIFY signal until I know what it broke. Task-number: 259071 --- tools/qdoc3/cppcodeparser.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/tools/qdoc3/cppcodeparser.cpp b/tools/qdoc3/cppcodeparser.cpp index ca12e9292..ebe5ec90c 100644 --- a/tools/qdoc3/cppcodeparser.cpp +++ b/tools/qdoc3/cppcodeparser.cpp @@ -1724,9 +1724,6 @@ bool CppCodeParser::matchProperty(InnerNode *parent) value = "?"; } - /* - Task 259071 requires work here. See gui/widgets/qdatetime.h, for example. - */ if (key == "READ") tre->addPropertyFunction(property, value, PropertyNode::Getter); else if (key == "WRITE") @@ -1737,9 +1734,11 @@ bool CppCodeParser::matchProperty(InnerNode *parent) property->setDesignable(value.toLower() == "true"); else if (key == "RESET") tre->addPropertyFunction(property, value, PropertyNode::Resetter); +#if 0 else if (key == "NOTIFY") { tre->addPropertyFunction(property, value, PropertyNode::Notifier); } +#endif } match(Tok_RightParen); return true; -- cgit v1.2.3 From e9b6e85b43bd233f16668dcb91da36e6dc31d4ff Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Thu, 13 Aug 2009 15:27:41 +0200 Subject: Fix auto test xmlpatternsschemats by adjusting build dependencies. --- tests/auto/auto.pro | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/auto.pro b/tests/auto/auto.pro index d7f27bd1b..dd188cddb 100644 --- a/tests/auto/auto.pro +++ b/tests/auto/auto.pro @@ -444,6 +444,7 @@ SUBDIRS += checkxmlfiles \ xmlpatternsdiagnosticsts.depends = xmlpatternsxqts xmlpatternsview.depends = xmlpatternsxqts xmlpatternsxslts.depends = xmlpatternsxqts +xmlpatternsschemats.depends = xmlpatternsxqts } unix:!embedded:contains(QT_CONFIG, dbus):SUBDIRS += \ -- cgit v1.2.3 From 547af9bf8a2ec074a698f0b92ec9e2a1a935eb14 Mon Sep 17 00:00:00 2001 From: Prasanth Ullattil Date: Thu, 13 Aug 2009 15:30:59 +0200 Subject: Fix qmake warnings Removed the src/common.pri includes Reviewed-by: Trust Me --- tools/xmlpatterns/xmlpatterns.pro | 2 -- tools/xmlpatternsvalidator/xmlpatternsvalidator.pro | 2 -- 2 files changed, 4 deletions(-) diff --git a/tools/xmlpatterns/xmlpatterns.pro b/tools/xmlpatterns/xmlpatterns.pro index 9c1aac1d0..1c5ab2cdb 100644 --- a/tools/xmlpatterns/xmlpatterns.pro +++ b/tools/xmlpatterns/xmlpatterns.pro @@ -27,5 +27,3 @@ HEADERS = main.h \ qapplicationargumentparser.cpp \ qcoloringmessagehandler_p.h \ qcoloroutput_p.h - -include(../src/common.pri) diff --git a/tools/xmlpatternsvalidator/xmlpatternsvalidator.pro b/tools/xmlpatternsvalidator/xmlpatternsvalidator.pro index dd5bd3733..849112961 100644 --- a/tools/xmlpatternsvalidator/xmlpatternsvalidator.pro +++ b/tools/xmlpatternsvalidator/xmlpatternsvalidator.pro @@ -15,5 +15,3 @@ CONFIG -= app_bundle SOURCES = main.cpp HEADERS = main.h - -include(../src/common.pri) -- cgit v1.2.3 From ff01481900f1d19d392c8ed8fe0f3b5c85751b8e Mon Sep 17 00:00:00 2001 From: Andreas Aardal Hanssen Date: Thu, 13 Aug 2009 12:20:52 +0200 Subject: Fix focus proxy deletion bugs/crashes in QGraphicsItem. This change would have been much simpler if either QGraphicsItem inherited QObject, or if we had some similar QPointer-like class that supported QGraphicsItem. The issue is this: Each item can delegate another item to be its focus proxy. That item can be a parent or child, or something completely unrelated. Either of the two items can be deleted independently. The former solution was to store backpointers in a map in the scene. Problem is, the items may not be in a scene when this happens, they may be removed from the scene, and the items may be moved between two scenes. The bad part about this fix is that it adds another pointer to QGraphicsItemPrivate. Reviewed-by: Shane Kearns --- src/gui/graphicsview/qgraphicsitem.cpp | 29 +++++++++++++----- src/gui/graphicsview/qgraphicsitem_p.h | 2 ++ src/gui/graphicsview/qgraphicsscene.cpp | 6 +--- src/gui/graphicsview/qgraphicsscene_p.h | 1 - tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp | 42 ++++++++++++++++++++++++++ 5 files changed, 66 insertions(+), 14 deletions(-) diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index c3e550140..537dab7f5 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -1196,10 +1196,12 @@ QGraphicsItem::~QGraphicsItem() Q_ASSERT(d_ptr->children.isEmpty()); } - if (d_ptr->scene) + if (d_ptr->scene) { d_ptr->scene->d_func()->removeItemHelper(this); - else + } else { + d_ptr->resetFocusProxy(); d_ptr->setParentItemHelper(0); + } if (d_ptr->transformData) { for(int i = 0; i < d_ptr->transformData->graphicsTransforms.size(); ++i) { @@ -2613,13 +2615,11 @@ void QGraphicsItem::setFocusProxy(QGraphicsItem *item) } QGraphicsItem *lastFocusProxy = d_ptr->focusProxy; + if (lastFocusProxy) + lastFocusProxy->d_ptr->focusProxyRefs.removeOne(&d_ptr->focusProxy); d_ptr->focusProxy = item; - if (d_ptr->scene) { - if (lastFocusProxy) - d_ptr->scene->d_func()->focusProxyReverseMap.remove(lastFocusProxy, this); - if (item) - d_ptr->scene->d_func()->focusProxyReverseMap.insert(item, this); - } + if (item) + item->d_ptr->focusProxyRefs << &d_ptr->focusProxy; } /*! @@ -4623,6 +4623,19 @@ void QGraphicsItemPrivate::clearSubFocus() } while (!parent->isWindow() && (parent = parent->d_ptr->parent)); } +/*! + \internal + + Sets the focusProxy pointer to 0 for all items that have this item as their + focusProxy. ### Qt 5: Use QPointer instead. +*/ +void QGraphicsItemPrivate::resetFocusProxy() +{ + for (int i = 0; i < focusProxyRefs.size(); ++i) + *focusProxyRefs.at(i) = 0; + focusProxyRefs.clear(); +} + /*! \internal diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index 982cdfc0d..c654d4fed 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -398,6 +398,7 @@ public: void setSubFocus(); void clearSubFocus(); + void resetFocusProxy(); inline QTransform transformToParent() const; inline void ensureSortedChildren(); @@ -419,6 +420,7 @@ public: int siblingIndex; int depth; QGraphicsItem *focusProxy; + QList focusProxyRefs; QGraphicsItem *subFocusItem; Qt::InputMethodHints imHints; diff --git a/src/gui/graphicsview/qgraphicsscene.cpp b/src/gui/graphicsview/qgraphicsscene.cpp index bdd1ac616..21788505e 100644 --- a/src/gui/graphicsview/qgraphicsscene.cpp +++ b/src/gui/graphicsview/qgraphicsscene.cpp @@ -494,11 +494,7 @@ void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item) item->d_func()->scene = 0; // Unregister focus proxy. - QMultiHash::iterator it = focusProxyReverseMap.find(item); - while (it != focusProxyReverseMap.end() && it.key() == item) { - it.value()->d_ptr->focusProxy = 0; - it = focusProxyReverseMap.erase(it); - } + item->d_ptr->resetFocusProxy(); // Remove from parent, or unregister from toplevels. if (QGraphicsItem *parentItem = item->parentItem()) { diff --git a/src/gui/graphicsview/qgraphicsscene_p.h b/src/gui/graphicsview/qgraphicsscene_p.h index 8b5330663..836522d76 100644 --- a/src/gui/graphicsview/qgraphicsscene_p.h +++ b/src/gui/graphicsview/qgraphicsscene_p.h @@ -131,7 +131,6 @@ public: QGraphicsWidget *activeWindow; int activationRefCount; void setFocusItemHelper(QGraphicsItem *item, Qt::FocusReason focusReason); - QMultiHash focusProxyReverseMap; QList popupWidgets; void addPopup(QGraphicsWidget *widget); diff --git a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp index eadf8b77b..a623b5066 100644 --- a/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp +++ b/tests/auto/qgraphicsitem/tst_qgraphicsitem.cpp @@ -280,6 +280,7 @@ private slots: void autoDetectFocusProxy(); void subFocus(); void reverseCreateAutoFocusProxy(); + void focusProxyDeletion(); // task specific tests below me void task141694_textItemEnsureVisible(); @@ -7516,5 +7517,46 @@ void tst_QGraphicsItem::reverseCreateAutoFocusProxy() QVERIFY(text2->hasFocus()); } +void tst_QGraphicsItem::focusProxyDeletion() +{ + QGraphicsRectItem *rect = new QGraphicsRectItem; + QGraphicsRectItem *rect2 = new QGraphicsRectItem; + rect->setFocusProxy(rect2); + QCOMPARE(rect->focusProxy(), (QGraphicsItem *)rect2); + + delete rect2; + QCOMPARE(rect->focusProxy(), (QGraphicsItem *)0); + + rect2 = new QGraphicsRectItem; + rect->setFocusProxy(rect2); + delete rect; // don't crash + + rect = new QGraphicsRectItem; + rect->setFocusProxy(rect2); + QGraphicsScene *scene = new QGraphicsScene; + scene->addItem(rect); + scene->addItem(rect2); + delete rect2; + QCOMPARE(rect->focusProxy(), (QGraphicsItem *)0); + + rect2 = new QGraphicsRectItem; + QTest::ignoreMessage(QtWarningMsg, "QGraphicsItem::setFocusProxy: focus proxy must be in same scene"); + rect->setFocusProxy(rect2); + QCOMPARE(rect->focusProxy(), (QGraphicsItem *)0); + scene->addItem(rect2); + rect->setFocusProxy(rect2); + QCOMPARE(rect->focusProxy(), (QGraphicsItem *)rect2); + delete rect; // don't crash + + rect = new QGraphicsRectItem; + rect2 = new QGraphicsRectItem; + rect->setFocusProxy(rect2); + QCOMPARE(rect->focusProxy(), (QGraphicsItem *)rect2); + scene->addItem(rect); + scene->addItem(rect2); + rect->setFocusProxy(rect2); + delete scene; // don't crash +} + QTEST_MAIN(tst_QGraphicsItem) #include "tst_qgraphicsitem.moc" -- cgit v1.2.3 From a55a7e06727610683a61461adfd144046d669b46 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Thu, 13 Aug 2009 15:52:51 +0200 Subject: clucene compiles on Windows CE now reimplmenting some missing C functions Task-number: 214990 Reviewed-by: kh --- src/3rdparty/clucene/src/CLucene/StdHeader.cpp | 2 ++ src/3rdparty/clucene/src/CLucene/StdHeader.h | 10 ++++++++++ src/3rdparty/clucene/src/CLucene/config/define_std.h | 3 +++ src/3rdparty/clucene/src/CLucene/config/repl_tchar.h | 20 ++++++++++++++++++++ src/3rdparty/clucene/src/CLucene/util/Misc.cpp | 10 ++++++++++ .../clucene/src/CLucene/util/fileinputstream.cpp | 5 +++++ 6 files changed, 50 insertions(+) diff --git a/src/3rdparty/clucene/src/CLucene/StdHeader.cpp b/src/3rdparty/clucene/src/CLucene/StdHeader.cpp index 9813a58c9..d64c51f77 100644 --- a/src/3rdparty/clucene/src/CLucene/StdHeader.cpp +++ b/src/3rdparty/clucene/src/CLucene/StdHeader.cpp @@ -17,8 +17,10 @@ #if defined(_CLCOMPILER_MSVC) && defined(_DEBUG) # define CRTDBG_MAP_ALLOC # include +#ifndef UNDER_CE # include #endif +#endif CL_NS_USE(util) diff --git a/src/3rdparty/clucene/src/CLucene/StdHeader.h b/src/3rdparty/clucene/src/CLucene/StdHeader.h index d267d0342..fbb3fd949 100644 --- a/src/3rdparty/clucene/src/CLucene/StdHeader.h +++ b/src/3rdparty/clucene/src/CLucene/StdHeader.h @@ -58,8 +58,10 @@ extern int _lucene_counter_break; //can set a watch on this #if defined(_CL_HAVE_UNISTD_H) #include #elif defined(_CL_HAVE_IO_H) && defined(_CL_HAVE_DIRECT_H) +#ifndef UNDER_CE #include #include +#endif #else #error "Neither unistd.h or (io.h & direct.h) were available" #endif @@ -75,7 +77,11 @@ extern int _lucene_counter_break; //can set a watch on this #if defined(_CL_STAT_MACROS_BROKEN) #error "Haven't implemented STAT_MACROS_BROKEN fix yet" #elif defined(_CL_HAVE_SYS_STAT_H) +#ifdef UNDER_CE + #include +#else #include +#endif #else #error "Haven't implemented platforms with no sys/stat.h" #endif @@ -179,13 +185,17 @@ extern int _lucene_counter_break; //can set a watch on this #include "CLucene/config/repl_tchar.h" #if defined(_CL_HAVE_ERRNO_H) +#ifndef UNDER_CE #include +#endif #else #error "Haven't implemented platforms with no errno.h" #endif #if defined(_CL_HAVE_FCNTL_H) +#ifndef UNDER_CE #include +#endif #else #error "Haven't implemented platforms with no fcntl.h" #endif diff --git a/src/3rdparty/clucene/src/CLucene/config/define_std.h b/src/3rdparty/clucene/src/CLucene/config/define_std.h index 3f92117ee..22a079053 100644 --- a/src/3rdparty/clucene/src/CLucene/config/define_std.h +++ b/src/3rdparty/clucene/src/CLucene/config/define_std.h @@ -72,6 +72,9 @@ #else #define _CL_HAVE_UNISTD_H #endif +#ifdef UNDER_CE +#undef _CL_HAVE_SYS_TIMEB_H +#endif //////////////////////////////////////////////// //now for individual functions. some compilers diff --git a/src/3rdparty/clucene/src/CLucene/config/repl_tchar.h b/src/3rdparty/clucene/src/CLucene/config/repl_tchar.h index d562cc8d6..ba8aef5c6 100644 --- a/src/3rdparty/clucene/src/CLucene/config/repl_tchar.h +++ b/src/3rdparty/clucene/src/CLucene/config/repl_tchar.h @@ -93,6 +93,26 @@ #endif #else //HAVE_TCHAR_H #include + +#ifdef UNDER_CE +#include +#define _i64tot i64tot +inline TCHAR* i64tot(__int64 value, TCHAR* str, int radix) +{ + QT_USE_NAMESPACE + _tcscpy(str, (TCHAR *) QString::number(value, radix).utf16()); + return str; +} + +#define _tcstoi64 tcstoi64 +inline __int64 tcstoi64(const TCHAR *nptr, TCHAR **endptr, int base) +{ + QT_USE_NAMESPACE + bool ok; + return QString::fromUtf16((ushort*) nptr).toInt(&ok, base); +} + +#endif //some tchar headers miss these... #ifndef _tcstoi64 diff --git a/src/3rdparty/clucene/src/CLucene/util/Misc.cpp b/src/3rdparty/clucene/src/CLucene/util/Misc.cpp index cb2efe259..42e3fd0a8 100644 --- a/src/3rdparty/clucene/src/CLucene/util/Misc.cpp +++ b/src/3rdparty/clucene/src/CLucene/util/Misc.cpp @@ -24,10 +24,15 @@ # include #endif +#ifdef UNDER_CE +#include +#endif + CL_NS_DEF(util) uint64_t Misc::currentTimeMillis() { +#ifndef UNDER_CE #if defined(_CLCOMPILER_MSVC) || defined(__MINGW32__) || defined(__BORLANDC__) struct _timeb tstruct; _ftime(&tstruct); @@ -41,6 +46,11 @@ uint64_t Misc::currentTimeMillis() return (((uint64_t) tstruct.tv_sec) * 1000) + tstruct.tv_usec / 1000; #endif +#else //UNDER_CE + QT_USE_NAMESPACE + QTime t = QTime::currentTime(); + return t.second() * 1000 + t.msec(); +#endif //UNDER_CE } // #pragma mark -- char related utils diff --git a/src/3rdparty/clucene/src/CLucene/util/fileinputstream.cpp b/src/3rdparty/clucene/src/CLucene/util/fileinputstream.cpp index 3803dfd85..9125d8478 100644 --- a/src/3rdparty/clucene/src/CLucene/util/fileinputstream.cpp +++ b/src/3rdparty/clucene/src/CLucene/util/fileinputstream.cpp @@ -25,7 +25,10 @@ */ #include "jstreamsconfig.h" #include "fileinputstream.h" + +#ifndef UNDER_CE #include +#endif #include namespace jstreams { @@ -39,7 +42,9 @@ FileInputStream::FileInputStream(const char *filepath, int32_t buffersize) { error = "Could not read file '"; error += filepath; error += "': "; +#ifndef UNDER_CE error += strerror(errno); +#endif status = Error; return; } -- cgit v1.2.3 From b4db217bf195bda7ade32bda79be65b5d31e1c0e Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Thu, 13 Aug 2009 15:54:51 +0200 Subject: Assistant compiles on Windows CE no official support Task-number: 214990 Reviewed-by: kh --- tools/assistant/compat/mainwindow.cpp | 2 ++ tools/assistant/tools/assistant/remotecontrol.cpp | 6 ++++++ 2 files changed, 8 insertions(+) diff --git a/tools/assistant/compat/mainwindow.cpp b/tools/assistant/compat/mainwindow.cpp index 353efdb1a..13b555e5a 100644 --- a/tools/assistant/compat/mainwindow.cpp +++ b/tools/assistant/compat/mainwindow.cpp @@ -401,6 +401,7 @@ QString MainWindow::urlifyFileName(const QString &fileName) return name; } +#ifndef QT_NO_PRINTER class PrintThread : public QThread { QPrinter _printer; @@ -436,6 +437,7 @@ protected: _document = 0; } }; +#endif //QT_NO_PRINTER void MainWindow::on_actionFilePrint_triggered() { diff --git a/tools/assistant/tools/assistant/remotecontrol.cpp b/tools/assistant/tools/assistant/remotecontrol.cpp index b72d7e825..7867ba018 100644 --- a/tools/assistant/tools/assistant/remotecontrol.cpp +++ b/tools/assistant/tools/assistant/remotecontrol.cpp @@ -78,6 +78,8 @@ void StdInListenerWin::run() bool ok = true; char chBuf[4096]; DWORD dwRead; + +#ifndef Q_WS_WINCE HANDLE hStdin, hStdinDup; hStdin = GetStdHandle(STD_INPUT_HANDLE); @@ -89,6 +91,10 @@ void StdInListenerWin::run() 0, false, DUPLICATE_SAME_ACCESS); CloseHandle(hStdin); +#else + HANDLE hStdinDup; + hStdinDup = stdin; +#endif while (ok) { ok = ReadFile(hStdinDup, chBuf, 4096, &dwRead, NULL); -- cgit v1.2.3 From 1e6e479037670518630b3c234bd47ed39fa08dd2 Mon Sep 17 00:00:00 2001 From: Thomas Hartmann Date: Thu, 13 Aug 2009 15:55:57 +0200 Subject: fixing autotests for Windows CE (deployment - QHelp) Task-number: 214990 Reviewed-by: Joerg --- tests/auto/qhelpcontentmodel/tst_qhelpcontentmodel.pro | 16 +++++++++++++++- tests/auto/qhelpenginecore/tst_qhelpenginecore.cpp | 2 ++ tests/auto/qhelpenginecore/tst_qhelpenginecore.pro | 17 ++++++++++++++++- 3 files changed, 33 insertions(+), 2 deletions(-) diff --git a/tests/auto/qhelpcontentmodel/tst_qhelpcontentmodel.pro b/tests/auto/qhelpcontentmodel/tst_qhelpcontentmodel.pro index 7cd8d513f..889aac972 100644 --- a/tests/auto/qhelpcontentmodel/tst_qhelpcontentmodel.pro +++ b/tests/auto/qhelpcontentmodel/tst_qhelpcontentmodel.pro @@ -3,6 +3,20 @@ SOURCES += tst_qhelpcontentmodel.cpp CONFIG += help -DEFINES += SRCDIR=\\\"$$PWD\\\" DEFINES += QT_USE_USING_NAMESPACE !contains(QT_BUILD_PARTS, tools): DEFINES += QT_NO_BUILD_TOOLS + +wince*: { + DEFINES += SRCDIR=\\\"./\\\" + QT += network + addFiles.sources = $$PWD/data/*.* + addFiles.path = data + clucene.sources = $$QT_BUILD_TREE/lib/QtCLucene*.dll + + DEPLOYMENT += addFiles + DEPLOYMENT += clucene + + DEPLOYMENT_PLUGIN += qsqlite +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} \ No newline at end of file diff --git a/tests/auto/qhelpenginecore/tst_qhelpenginecore.cpp b/tests/auto/qhelpenginecore/tst_qhelpenginecore.cpp index 499c3670b..d765c258e 100644 --- a/tests/auto/qhelpenginecore/tst_qhelpenginecore.cpp +++ b/tests/auto/qhelpenginecore/tst_qhelpenginecore.cpp @@ -98,6 +98,8 @@ void tst_QHelpEngineCore::init() // defined in profile m_path = QLatin1String(SRCDIR); + m_path = QFileInfo(m_path).absoluteFilePath(); + m_colFile = m_path + QLatin1String("/data/col.qhc"); if (QFile::exists(m_colFile)) QDir::current().remove(m_colFile); diff --git a/tests/auto/qhelpenginecore/tst_qhelpenginecore.pro b/tests/auto/qhelpenginecore/tst_qhelpenginecore.pro index 11fca8e79..27ebd0fc4 100644 --- a/tests/auto/qhelpenginecore/tst_qhelpenginecore.pro +++ b/tests/auto/qhelpenginecore/tst_qhelpenginecore.pro @@ -3,6 +3,21 @@ SOURCES += tst_qhelpenginecore.cpp CONFIG += help QT += sql -DEFINES += SRCDIR=\\\"$$PWD\\\" + DEFINES += QT_USE_USING_NAMESPACE !contains(QT_BUILD_PARTS, tools): DEFINES += QT_NO_BUILD_TOOLS + +wince*: { + DEFINES += SRCDIR=\\\"./\\\" + QT += network + addFiles.sources = $$PWD/data/*.* + addFiles.path = data + clucene.sources = $$QT_BUILD_TREE/lib/QtCLucene*.dll + + DEPLOYMENT += addFiles + DEPLOYMENT += clucene + + DEPLOYMENT_PLUGIN += qsqlite +} else { + DEFINES += SRCDIR=\\\"$$PWD\\\" +} -- cgit v1.2.3 From 9f13cde554e1a56fade3b9b298b264c54b1ef4b9 Mon Sep 17 00:00:00 2001 From: Paul Olav Tvete Date: Thu, 13 Aug 2009 16:20:27 +0200 Subject: Use the correct font for QLineEdit We don't get a FontChange event initially, so the control ended up with the default font instead. Reviewed-by: Andreas --- src/gui/widgets/qlineedit_p.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/gui/widgets/qlineedit_p.cpp b/src/gui/widgets/qlineedit_p.cpp index 5950d856f..08fce9b2a 100644 --- a/src/gui/widgets/qlineedit_p.cpp +++ b/src/gui/widgets/qlineedit_p.cpp @@ -138,6 +138,7 @@ void QLineEditPrivate::init(const QString& txt) { Q_Q(QLineEdit); control = new QLineControl(txt); + control->setFont(q->font()); QObject::connect(control, SIGNAL(textChanged(const QString &)), q, SIGNAL(textChanged(const QString &))); QObject::connect(control, SIGNAL(textEdited(const QString &)), -- cgit v1.2.3 From e2bb75e66f7ef9dda6fae489ebbb30ffb5e9e37e Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Thu, 13 Aug 2009 16:57:51 +0200 Subject: Fix coverity warnings for unreachable code, break missing and uninitialized members in constructors --- src/corelib/kernel/qvariant.cpp | 1 + src/gui/kernel/qkde.cpp | 2 -- src/gui/styles/qcommonstyle.cpp | 3 +-- src/gui/widgets/qmainwindow.cpp | 4 +--- 4 files changed, 3 insertions(+), 7 deletions(-) diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp index dfed4db5d..b26cfdd0b 100644 --- a/src/corelib/kernel/qvariant.cpp +++ b/src/corelib/kernel/qvariant.cpp @@ -658,6 +658,7 @@ static bool convert(const QVariant::Private *d, QVariant::Type t, void *result, break; case QVariant::Url: *str = v_cast(d)->toString(); + break; default: return false; } diff --git a/src/gui/kernel/qkde.cpp b/src/gui/kernel/qkde.cpp index 23de83869..98bf0a085 100644 --- a/src/gui/kernel/qkde.cpp +++ b/src/gui/kernel/qkde.cpp @@ -139,8 +139,6 @@ QString QKde::kdeStyle() return QLatin1String("plastique"); else return QLatin1String("windows"); - - return QString(); } /*!\internal diff --git a/src/gui/styles/qcommonstyle.cpp b/src/gui/styles/qcommonstyle.cpp index d4940d683..cce35b732 100644 --- a/src/gui/styles/qcommonstyle.cpp +++ b/src/gui/styles/qcommonstyle.cpp @@ -5196,8 +5196,7 @@ int QCommonStyle::styleHint(StyleHint sh, const QStyleOption *opt, const QWidget ret = Qt::ToolButtonIconOnly; #ifdef Q_WS_X11 { - Q_D(const QCommonStyle); - static int buttonStyle = d->lookupToolButtonStyle(); + static int buttonStyle = d_func()->lookupToolButtonStyle(); return buttonStyle; } #endif diff --git a/src/gui/widgets/qmainwindow.cpp b/src/gui/widgets/qmainwindow.cpp index 9243217c6..88059a016 100644 --- a/src/gui/widgets/qmainwindow.cpp +++ b/src/gui/widgets/qmainwindow.cpp @@ -73,7 +73,7 @@ class QMainWindowPrivate : public QWidgetPrivate Q_DECLARE_PUBLIC(QMainWindow) public: inline QMainWindowPrivate() - : layout(0), toolButtonStyle(Qt::ToolButtonIconOnly) + : layout(0), explicitIconSize(false), toolButtonStyle(Qt::ToolButtonIconOnly) #ifdef Q_WS_MAC , useHIToolBar(false) #endif @@ -107,8 +107,6 @@ void QMainWindowPrivate::init() layout = new QMainWindowLayout(q); const int metric = q->style()->pixelMetric(QStyle::PM_ToolBarIconSize, 0, q); iconSize = QSize(metric, metric); - explicitIconSize = false; - q->setAttribute(Qt::WA_Hover); } -- cgit v1.2.3 From a2cc46c89e73d089f333423f8382eb7582699e39 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 12 Aug 2009 11:52:15 +0200 Subject: Internal doc: explain how QSharedPointer works --- src/corelib/tools/qsharedpointer.cpp | 266 ++++++++++++++++++++++++++++++++ src/corelib/tools/qsharedpointer_impl.h | 57 ++++--- 2 files changed, 305 insertions(+), 18 deletions(-) diff --git a/src/corelib/tools/qsharedpointer.cpp b/src/corelib/tools/qsharedpointer.cpp index e3e1db6cc..60c7db4a9 100644 --- a/src/corelib/tools/qsharedpointer.cpp +++ b/src/corelib/tools/qsharedpointer.cpp @@ -107,6 +107,249 @@ cases, since they have the same functionality. See \l{QWeakPointer#tracking-qobject} for more information. + \section1 Optional pointer tracking + + A feature of QSharedPointer that can be enabled at compile-time for + debugging purposes is a pointer tracking mechanism. When enabled, + QSharedPointer registers in a global set all the pointers that it tracks. + This allows one to catch mistakes like assigning the same pointer to two + QSharedPointer objects. + + This function is enabled by defining the \tt{QT_SHAREDPOINTER_TRACK_POINTERS} + macro before including the QSharedPointer header. + + It is safe to use this feature even with code compiled without the + feature. QSharedPointer will ensure that the pointer is removed from the + tracker even from code compiled without pointer tracking. + + Note, however, that the pointer tracking feature has limitations on + multiple- or virtual-inheritance (that is, in cases where two different + pointer addresses can refer to the same object). In that case, if a + pointer is cast to a different type and its value changes, + QSharedPointer's pointer tracking mechanism mail fail to detect that the + object being tracked is the same. + + \omit + \secton1 QSharedPointer internals + + QSharedPointer is in reality implemented by two ancestor classes: + QtSharedPointer::Basic and QtSharedPointer::ExternalRefCount. The reason + for having that split is now mostly legacy: in the beginning, + QSharedPointer was meant to support both internal reference counting and + external reference counting. + + QtSharedPointer::Basic implements the basic functionality that is shared + between internal- and external-reference counting. That is, it's mostly + the accessor functions into QSharedPointer. Those are all inherited by + QSharedPointer, which adds another level of shared functionality (the + constructors and assignment operators). The Basic class has one member + variable, which is the actual pointer being tracked. + + QtSharedPointer::ExternalRefCount implements the actual reference + counting and introduces the d-pointer for QSharedPointer. That d-pointer + itself is shared with with other QSharedPointer objects as well as + QWeakPointer. + + The reason for keeping the pointer value itself outside the d-pointer is + because of multiple inheritance needs. If you have two QSharedPointer + objects of different pointer types, but pointing to the same object in + memory, it could happen that the pointer values are different. The \tt + differentPointers autotest exemplifies this problem. The same thing could + happen in the case of virtual inheritance: a pointer of class matching + the virtual base has different address compared to the pointer of the + complete object. See the \tt virtualBaseDifferentPointers autotest for + this problem. + + The d pointer is of type QtSharedPointer::ExternalRefCountData for simple + QSharedPointer objects, but could be of a derived type in some cases. It + is basically a reference-counted reference-counter. + + \section2 d-pointer + \section3 QtSharedPointer::ExternalRefCountData + + This class is basically a reference-counted reference-counter. It has two + members: \tt strongref and \tt weakref. The strong reference counter is + controlling the lifetime of the object tracked by QSharedPointer. a + positive value indicates that the object is alive. It's also the number + of QSharedObject instances that are attached to this Data. + + When the strong reference count decreases to zero, the object is deleted + (see below for information on custom deleters). The strong reference + count can also exceptionally be -1, indicating that there are no + QSharedPointers attached to an object, which is tracked too. The only + case where this is possible is that of + \l{QWeakPointer#tracking-qobject}{QWeakPointers tracking a QObject}. + + The weak reference count controls the lifetime of the d-pointer itself. + It can be thought of as an internal/intrusive reference count for + ExternalRefCountData itself. This count is equal to the number of + QSharedPointers and QWeakPointers that are tracking this object. (In case + the object tracked derives from QObject, this number is increased by 1, + since QObjectPrivate tracks it too). + + ExternalRefCountData is a virtual class: it has a virtual destructor and + a virtual destroy() function. The destroy() function is supposed to + delete the object being tracked and return true if it does so. Otherwise, + it returns false to indicate that the caller must simply call delete. + This allows the normal use-case of QSharedPointer without custom deleters + to use only one 12- or 16-byte (depending on whether it's a 32- or 64-bit + architecture) external descriptor structure, without paying the price for + the custom deleter that it isn't using. + + \section3 QtSharedPointer::ExternalRefCountDataWithDestroyFn + + This class is not used directly, per se. It only exists to enable the two + classes that derive from it. It adds one member variable, which is a + pointer to a function (which returns void and takes an + ExternalRefCountData* as a parameter). It also overrides the destroy() + function: it calls that function pointer with \tt this as parameter, and + returns true. + + That means when ExternalRefCountDataWithDestroyFn is used, the \tt + destroyer field must be set to a valid function that \b will delete the + object tracked. + + This class also adds an operator delete function to ensure that simply + calls the global operator delete. That should be the behaviour in all + compilers already, but to be on the safe side, this class ensures that no + funny business happens. + + On a 32-bit architecture, this class is 16 bytes in size, whereas it's 24 + bytes on 64-bit. (On Itanium where function pointers contain the global + pointer, it can be 32 bytes). + + \section3 QtSharedPointer::ExternalRefCountWithCustomDeleter + + This class derives from ExternalRefCountDataWithDestroyFn and is a + template class. As template parameters, it has the type of the pointer + being tracked (\tt T) and a \tt Deleter, which is anything. It adds two + fields to its parent class, matching those template parameters: a member + of type \tt Deleter and a member of type \tt T*. + + The purpose of this class is to store the pointer to be deleted and the + deleter code along with the d-pointer. This allows the last strong + reference to call any arbitrary function that disposes of the object. For + example, this allows calling QObject::deleteLater() on a given object. + The pointer to the object is kept here to avoid the extra cost of keeping + the deleter in the generic case. + + This class is never instantiated directly: the constructors and + destructor are private. Only the create() function may be called to + return an object of this type. See below for construction details. + + The size of this class depends on the size of \tt Deleter. If it's an + empty functor (i.e., no members), ABIs generally assign it the size of 1. + But given that it's followed by a pointer, up to 3 or 7 padding bytes may + be inserted: in that case, the size of this class is 16+4+4 = 24 bytes on + 32-bit architectures, or 24+8+8 = 40 bytes on 64-bit architectures (48 + bytes on Itanium with global pointers stored). If \tt Deleter is a + function pointer, the size should be the same as the empty structure + case, except for Itanium where it may be 56 bytes due to another global + pointer. If \tt Deleter is a pointer to a member function (PMF), the size + will be even bigger and will depend on the ABI. For architectures using + the Itanium C++ ABI, a PMF is twice the size of a normal pointer, or 24 + bytes on Itanium itself. In that case, the size of this structure will be + 16+8+4 = 28 bytes on 32-bit architectures, 24+16+8 = 48 bytes on 64-bit, + and 32+24+8 = 64 bytes on Itanium. + + (Values for Itanium consider an LP64 architecture; for ILP32, pointers + are 32-bit in length, function pointers are 64-bit and PMF are 96-bit, so + the sizes are slightly less) + + \section3 QtSharedPointer::ExternalRefCountWithContiguousData + + This class also derives from ExternalRefCountDataWithDestroyFn and it is + also a template class. The template parameter is the type \tt T of the + class which QSharedPointer tracks. It adds only one member to its parent, + which is of type \tt T (the actual type, not a pointer to it). + + The purpose of this class is to lay the \tt T object out next to the + reference counts, saving one memory allocation per shared pointer. This + is particularly interesting for small \tt T or for the cases when there + are few if any QWeakPointer tracking the object. This class exists to + implement the QSharedPointer::create() call. + + Like ExternalRefCountWithCustomDeleter, this class is never instantiated + directly. This class also provides a create() member that returns the + pointer, and hides its constructors and destructor. (With C++0x, we'd + delete them). + + The size of this class depends on the size of \tt T. + + \section3 Instantiating ExternalRefCountWithCustomDeleter and ExternalRefCountWithContiguousData + + Like explained above, these classes have private constructors. Moreover, + they are not defined anywhere, so trying to call \tt{new ClassType} would + result in a compilation or linker error. Instead, these classes must be + constructed via their create() methods. + + Instead of instantiating the class by the normal way, the create() method + calls \tt{operator new} directly with the size of the class, then calls + the parent class's constructor only (ExternalRefCountDataWithDestroyFn). + This ensures that the inherited members are initialised properly, as well + as the virtual table pointer, which must point to + ExternalRefCountDataWithDestroyFn's virtual table. That way, we also + ensure that the virtual destructor being called is + ExternalRefCountDataWithDestroyFn's. + + After initialising the base class, the + ExternalRefCountWithCustomDeleter::create() function initialises the new + members directly, by using the placement \tt{operator new}. In the case + of the ExternalRefCountWithContiguousData::create() function, the address + to the still-uninitialised \tt T member is saved for the callee to use. + The member is only initialised in QSharedPointer::create(), so that we + avoid having many variants of the internal functions according to the + arguments in use for calling the constructor. + + When initialising the parent class, the create() functions pass the + address of the static deleter() member function. That is, when the + virtual destroy() is called by QSharedPointer, the deleter() functions + are called instead. These functiosn static_cast the ExternalRefCountData* + parameter to their own type and execute their deletion: for the + ExternalRefCountWithCustomDeleter::deleter() case, it runs the user's + custom deleter, then destroys the deleter; for + ExternalRefCountWithContiguousData::deleter, it simply calls the \tt T + destructor directly. + + By not calling the constructor of the derived classes, we avoid + instantiating their virtual tables. Since these classes are + template-based, there would be one virtual table per \tt T and \tt + Deleter type. (This is what Qt 4.5 did) + + Instead, only one non-inline function is required per template, which is + the deleter() static member. All the other functions can be inlined. + What's more, the address of deleter() is calculated only in code, which + can be resolved at link-time if the linker can determine that the + function lies in the current application or library module (since these + classes are not exported, that is the case for Windows or for builds with + \tt{-fvisibility=hidden}). + + In contrast, a virtual table would require at least 3 relocations to be + resolved at module load-time, per module where these classes are used. + (In the Itanium C++ ABI, there would be more relocations, due to the + RTTI) + + \section3 Modifications due to pointer-tracking + + To ensure that pointers created with pointer-tracking enabled get + un-tracked when destroyed, even if destroyed by code compiled without the + feature, QSharedPointer modifies slightly the instructions of the + previous sections. + + When ExternalRefCountWithCustomDeleter or + ExternalRefCountWithContiguousData are used, their create() functions + will set the ExternalRefCountDataWithDestroyFn::destroyer function + pointer to safetyCheckDeleter() instead. These static member functions + simply call internalSafetyCheckRemove2() before passing control to the + normal deleter() function. + + If neither custom deleter nor QSharedPointer::create() are used, then + QSharedPointer uses a custom deleter of its own: the normalDeleter() + function, which simply calls \tt delete. By using a custom deleter, the + safetyCheckDeleter() procedure described above kicks in. + + \endomit + \sa QSharedDataPointer, QWeakPointer */ @@ -182,6 +425,29 @@ QWeakPointers created from QObject should never be passed to code that hasn't been recompiled. + \omit + \secton1 QWeakPointer internals + + QWeakPointer shares most of its internal functionality with + \l{QSharedPointer#qsharedpointer-internals}{QSharedPointer}, so see that + class's internal documentation for more information. + + QWeakPointer requires an external reference counter in order to operate. + Therefore, it is incompatible by design with \l QSharedData-derived + classes. + + It has a special QObject constructor, which works by calling + QtSharedPointer::ExternalRefCountData::getAndRef, which retrieves the + d-pointer from QObjectPrivate. If one isn't set yet, that function + creates the d-pointer and atomically sets it. + + If getAndRef needs to create a d-pointer, it sets the strongref to -1, + indicating that the QObject is not shared: QWeakPointer is used only to + determine whether the QObject has been deleted. In that case, it cannot + be upgraded to QSharedPointer (see the previous section). + + \endomit + \sa QSharedPointer */ diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index ba479f9cc..cbeb79ff3 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -115,6 +115,9 @@ namespace QtSharedPointer { template struct RemovePointer > { typedef T Type; }; template struct RemovePointer > { typedef T Type; }; + // This class provides the basic functionality of a pointer wrapper. + // Its existence is mostly legacy, since originally QSharedPointer + // could also be used for internally-refcounted objects. template class Basic { @@ -155,6 +158,12 @@ namespace QtSharedPointer { Type *value; }; + // This class is the d-pointer of QSharedPointer and QWeakPointer. + // + // It is a reference-counted reference counter. "strongref" is the inner + // reference counter, and it tracks the lifetime of the pointer itself. + // "weakref" is the outer reference counter and it tracks the lifetime of + // the ExternalRefCountData object. struct ExternalRefCountData { QBasicAtomicInt weakref; @@ -168,6 +177,9 @@ namespace QtSharedPointer { inline ExternalRefCountData(Qt::Initialization) { } virtual inline ~ExternalRefCountData() { Q_ASSERT(!weakref); Q_ASSERT(strongref <= 0); } + // overridden by derived classes + // returns false to indicate caller should delete the pointer + // returns true in case it has already done so virtual inline bool destroy() { return false; } #ifndef QT_NO_QOBJECT @@ -178,18 +190,8 @@ namespace QtSharedPointer { }; // sizeof(ExternalRefCount) = 12 (32-bit) / 16 (64-bit) - template - struct CustomDeleter - { - Deleter deleter; - T *ptr; - - inline CustomDeleter(T *p, Deleter d) : deleter(d), ptr(p) {} - }; - // sizeof(CustomDeleter) = sizeof(Deleter) + sizeof(void*) - // for Deleter = function pointer: 8 (32-bit) / 16 (64-bit) - // for Deleter = PMF: 12 (32-bit) / 24 (64-bit) (GCC) - + // This class extends ExternalRefCountData with a pointer + // to a function, which is called by the destroy() function. struct ExternalRefCountWithDestroyFn: public ExternalRefCountData { typedef void (*DestroyerFn)(ExternalRefCountData *); @@ -204,13 +206,26 @@ namespace QtSharedPointer { }; // sizeof(ExternalRefCountWithDestroyFn) = 16 (32-bit) / 24 (64-bit) + // This class extends ExternalRefCountWithDestroyFn and implements + // the static function that deletes the object. The pointer and the + // custom deleter are kept in the "extra" member. template struct ExternalRefCountWithCustomDeleter: public ExternalRefCountWithDestroyFn { typedef ExternalRefCountWithCustomDeleter Self; - typedef ExternalRefCountWithDestroyFn Parent; - typedef CustomDeleter Next; - Next extra; + typedef ExternalRefCountWithDestroyFn BaseClass; + + struct CustomDeleter + { + Deleter deleter; + T *ptr; + + inline CustomDeleter(T *p, Deleter d) : deleter(d), ptr(p) {} + }; + CustomDeleter extra; + // sizeof(CustomDeleter) = sizeof(Deleter) + sizeof(void*) + // for Deleter = function pointer: 8 (32-bit) / 16 (64-bit) + // for Deleter = PMF: 12 (32-bit) / 24 (64-bit) (GCC) static inline void deleter(ExternalRefCountData *self) { @@ -218,7 +233,7 @@ namespace QtSharedPointer { executeDeleter(realself->extra.ptr, realself->extra.deleter); // delete the deleter too - realself->extra.~Next(); + realself->extra.~CustomDeleter(); } static void safetyCheckDeleter(ExternalRefCountData *self) { @@ -236,8 +251,8 @@ namespace QtSharedPointer { Self *d = static_cast(::operator new(sizeof(Self))); // initialize the two sub-objects - new (&d->extra) Next(ptr, userDeleter); - new (d) Parent(destroy); // can't throw + new (&d->extra) CustomDeleter(ptr, userDeleter); + new (d) BaseClass(destroy); // can't throw return d; } @@ -247,6 +262,10 @@ namespace QtSharedPointer { ~ExternalRefCountWithCustomDeleter(); }; + // This class extends ExternalRefCountWithDestroyFn and adds a "T" + // member. That way, when the create() function is called, we allocate + // memory for both QSharedPointer's d-pointer and the actual object being + // tracked. template struct ExternalRefCountWithContiguousData: public ExternalRefCountWithDestroyFn { @@ -289,6 +308,8 @@ namespace QtSharedPointer { ~ExternalRefCountWithContiguousData(); }; + // This is the main body of QSharedPointer. It implements the + // external reference counting functionality. template class ExternalRefCount: public Basic { -- cgit v1.2.3 From 07fcb3b032526e76086d7f75dad01b867233b5d5 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 13 Aug 2009 14:59:40 +0200 Subject: Add QIntegerForSize<1> and QIntegerForSize<2>. Undocumented, but maybe they're useful somewhere. It doesn't hurt to add them. --- src/corelib/global/qglobal.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 7076a1e17..5a2c329c6 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -848,6 +848,8 @@ typedef quint64 qulonglong; && sizeof(void *) == sizeof(qptrdiff) */ template struct QIntegerForSize; +template <> struct QIntegerForSize<1> { typedef quint8 Unsigned; typedef qint8 Signed; }; +template <> struct QIntegerForSize<2> { typedef quint16 Unsigned; typedef qint16 Signed; }; template <> struct QIntegerForSize<4> { typedef quint32 Unsigned; typedef qint32 Signed; }; template <> struct QIntegerForSize<8> { typedef quint64 Unsigned; typedef qint64 Signed; }; template struct QIntegerForSizeof: QIntegerForSize { }; -- cgit v1.2.3 From 942abf1a3ba60a60207a213dbeb383904f97e47d Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Thu, 13 Aug 2009 17:30:02 +0200 Subject: fixing return values _wchmod on Windows CE _wchmod returns 0 on success and -1 on error. Our Windows CE implementation did it wrong. Thanks to Konstantin Ritt for spotting this! Reviewed-by: mauricek --- src/corelib/io/qfsfileengine_win.cpp | 2 +- src/corelib/kernel/qfunctions_wince.cpp | 7 ++++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index 3394a0030..ba93a9441 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -1706,7 +1706,7 @@ bool QFSFileEngine::setPermissions(uint perms) #if !defined(Q_OS_WINCE) ret = ::_wchmod((wchar_t*)d->filePath.utf16(), mode) == 0; #else - ret = ::_wchmod((wchar_t*)d->longFileName(d->filePath).utf16(), mode); + ret = ::_wchmod((wchar_t*)d->longFileName(d->filePath).utf16(), mode) == 0; #endif return ret; } diff --git a/src/corelib/kernel/qfunctions_wince.cpp b/src/corelib/kernel/qfunctions_wince.cpp index 2b5d4fee0..77f680ac8 100644 --- a/src/corelib/kernel/qfunctions_wince.cpp +++ b/src/corelib/kernel/qfunctions_wince.cpp @@ -292,13 +292,14 @@ bool qt_wince__chmod(const char *file, int mode) bool qt_wince__wchmod(const wchar_t *file, int mode) { + BOOL success = FALSE; // ### Does not work properly, what about just adding one property? if(mode&_S_IWRITE) { - return SetFileAttributes(file, FILE_ATTRIBUTE_NORMAL); + success = SetFileAttributes(file, FILE_ATTRIBUTE_NORMAL); } else if((mode&_S_IREAD) && !(mode&_S_IWRITE)) { - return SetFileAttributes(file, FILE_ATTRIBUTE_READONLY); + success = SetFileAttributes(file, FILE_ATTRIBUTE_READONLY); } - return false; + return success ? 0 : -1; } HANDLE qt_wince_CreateFileA(LPCSTR filename, DWORD access, DWORD share, LPSECURITY_ATTRIBUTES attr, DWORD dispo, DWORD flags, HANDLE tempFile) -- cgit v1.2.3 From f82a226607b079b360c88afbe0423d990071b0ba Mon Sep 17 00:00:00 2001 From: Thierry Bastian Date: Thu, 13 Aug 2009 17:37:05 +0200 Subject: Fix coverity warnings --- src/gui/itemviews/qabstractitemview.cpp | 1 + src/gui/itemviews/qlistview.cpp | 3 ++- src/gui/itemviews/qtreeview.cpp | 9 ++++----- src/gui/itemviews/qtreeview_p.h | 2 +- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/gui/itemviews/qabstractitemview.cpp b/src/gui/itemviews/qabstractitemview.cpp index 769ccef20..4f32ecc49 100644 --- a/src/gui/itemviews/qabstractitemview.cpp +++ b/src/gui/itemviews/qabstractitemview.cpp @@ -73,6 +73,7 @@ QAbstractItemViewPrivate::QAbstractItemViewPrivate() currentlyCommittingEditor(0), pressedModifiers(Qt::NoModifier), pressedPosition(QPoint(-1, -1)), + pressedAlreadySelected(false), viewportEnteredNeeded(false), state(QAbstractItemView::NoState), editTriggers(QAbstractItemView::DoubleClicked|QAbstractItemView::EditKeyPressed), diff --git a/src/gui/itemviews/qlistview.cpp b/src/gui/itemviews/qlistview.cpp index 945d5e78e..1870a3be8 100644 --- a/src/gui/itemviews/qlistview.cpp +++ b/src/gui/itemviews/qlistview.cpp @@ -1968,7 +1968,8 @@ QListViewPrivate::QListViewPrivate() modeProperties(0), column(0), uniformItemSizes(false), - batchSize(100) + batchSize(100), + showElasticBand(false) { } diff --git a/src/gui/itemviews/qtreeview.cpp b/src/gui/itemviews/qtreeview.cpp index cbe1d2a5d..539a642ac 100644 --- a/src/gui/itemviews/qtreeview.cpp +++ b/src/gui/itemviews/qtreeview.cpp @@ -2797,15 +2797,14 @@ int QTreeView::indexRowSizeHint(const QModelIndex &index) const if (isRightToLeft()) { start = (start == -1 ? count - 1 : start); - end = (end == -1 ? 0 : end); + end = 0; } else { start = (start == -1 ? 0 : start); - end = (end == -1 ? count - 1 : end); + end = count - 1; } - int tmp = start; - start = qMin(start, end); - end = qMax(tmp, end); + if (end < start) + qSwap(end, start); int height = -1; QStyleOptionViewItemV4 option = d->viewOptionsV4(); diff --git a/src/gui/itemviews/qtreeview_p.h b/src/gui/itemviews/qtreeview_p.h index d17016f44..1bbba8904 100644 --- a/src/gui/itemviews/qtreeview_p.h +++ b/src/gui/itemviews/qtreeview_p.h @@ -82,7 +82,7 @@ public: uniformRowHeights(false), rootDecoration(true), itemsExpandable(true), sortingEnabled(false), expandsOnDoubleClick(true), - allColumnsShowFocus(false), current(0), + allColumnsShowFocus(false), current(0), spanning(false), animationsEnabled(false), columnResizeTimerID(0), autoExpandDelay(-1), hoverBranch(-1), geometryRecursionBlock(false) {} -- cgit v1.2.3 From e2eaf3cd9ce752fe88d2705111f28a5ad4a336ab Mon Sep 17 00:00:00 2001 From: Frans Englich Date: Thu, 13 Aug 2009 18:10:20 +0200 Subject: Fix build, by adjusting according to how test QProcess is. --- tests/auto/qtextcodec/test/test.pro | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/tests/auto/qtextcodec/test/test.pro b/tests/auto/qtextcodec/test/test.pro index 9c07e7676..99f94d48c 100644 --- a/tests/auto/qtextcodec/test/test.pro +++ b/tests/auto/qtextcodec/test/test.pro @@ -1,6 +1,21 @@ load(qttest_p4) -TARGET = ../tst_qtextcodec + SOURCES += ../tst_qtextcodec.cpp + +!wince*: { +TARGET = ../tst_qtextcodec + +win32: { + CONFIG(debug, debug|release) { + TARGET = ../../debug/tst_qtextcodec +} else { + TARGET = ../../release/tst_qtextcodec + } +} +} else { + TARGET = tst_qtextcodec +} + wince*: { addFiles.sources = ../*.txt addFiles.path = . -- cgit v1.2.3 From 8de0b23ad3a49569d25f2fba803c622689581c19 Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Thu, 13 Aug 2009 18:44:33 +0200 Subject: remove needless resolvings in qfsfileengine_win.cpp OpenProcessToken and SetFilePointerEx are present in all versions since NT4.0; use them if Q_OS_WINCE is not defined Merge-request: 1167 Reviewed-by: Joerg Bornemann --- src/corelib/io/qfsfileengine_win.cpp | 84 +++++++++++++----------------------- 1 file changed, 31 insertions(+), 53 deletions(-) diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index ba93a9441..d7d168400 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -119,12 +119,8 @@ typedef PVOID (WINAPI *PtrFreeSid)(PSID); static PtrFreeSid ptrFreeSid = 0; static TRUSTEE_W currentUserTrusteeW; -typedef BOOL (WINAPI *PtrOpenProcessToken)(HANDLE, DWORD, PHANDLE ); -static PtrOpenProcessToken ptrOpenProcessToken = 0; typedef BOOL (WINAPI *PtrGetUserProfileDirectoryW)(HANDLE, LPWSTR, LPDWORD); static PtrGetUserProfileDirectoryW ptrGetUserProfileDirectoryW = 0; -typedef BOOL (WINAPI *PtrSetFilePointerEx)(HANDLE, LARGE_INTEGER, PLARGE_INTEGER, DWORD); -static PtrSetFilePointerEx ptrSetFilePointerEx = 0; QT_END_INCLUDE_NAMESPACE @@ -204,14 +200,10 @@ void QFSFileEnginePrivate::resolveLibs() } FreeLibrary(versionHnd); } - ptrOpenProcessToken = (PtrOpenProcessToken)GetProcAddress(advapiHnd, "OpenProcessToken"); - HINSTANCE userenvHnd = LoadLibraryW(L"userenv"); + HINSTANCE userenvHnd = LoadLibraryW(L"userenv"); if (userenvHnd) { ptrGetUserProfileDirectoryW = (PtrGetUserProfileDirectoryW)GetProcAddress(userenvHnd, "GetUserProfileDirectoryW"); } - HINSTANCE kernelHnd = LoadLibraryW(L"kernel32"); - if (kernelHnd) - ptrSetFilePointerEx = (PtrSetFilePointerEx)GetProcAddress(kernelHnd, "SetFilePointerEx"); } #endif } @@ -596,34 +588,27 @@ qint64 QFSFileEnginePrivate::nativePos() const if (fileHandle == INVALID_HANDLE_VALUE) return 0; -#if !defined(QT_NO_LIBRARY) && !defined(Q_OS_WINCE) - QFSFileEnginePrivate::resolveLibs(); - if (!ptrSetFilePointerEx) { -#endif - LARGE_INTEGER filepos; - filepos.HighPart = 0; - DWORD newFilePointer = SetFilePointer(fileHandle, 0, &filepos.HighPart, FILE_CURRENT); - if (newFilePointer == 0xFFFFFFFF && GetLastError() != NO_ERROR) { - thatQ->setError(QFile::UnspecifiedError, qt_error_string()); - return 0; - } - - // Note: This is the case for MOC, UIC, qmake and other - // bootstrapped tools, and for Windows CE. - filepos.LowPart = newFilePointer; - return filepos.QuadPart; -#if !defined(QT_NO_LIBRARY) && !defined(Q_OS_WINCE) - } - +#if !defined(Q_OS_WINCE) LARGE_INTEGER currentFilePos; LARGE_INTEGER offset; offset.QuadPart = 0; - if (!ptrSetFilePointerEx(fileHandle, offset, ¤tFilePos, FILE_CURRENT)) { + if (!::SetFilePointerEx(fileHandle, offset, ¤tFilePos, FILE_CURRENT)) { thatQ->setError(QFile::UnspecifiedError, qt_error_string()); return 0; } return qint64(currentFilePos.QuadPart); +#else + LARGE_INTEGER filepos; + filepos.HighPart = 0; + DWORD newFilePointer = SetFilePointer(fileHandle, 0, &filepos.HighPart, FILE_CURRENT); + if (newFilePointer == 0xFFFFFFFF && GetLastError() != NO_ERROR) { + thatQ->setError(QFile::UnspecifiedError, qt_error_string()); + return 0; + } + + filepos.LowPart = newFilePointer; + return filepos.QuadPart; #endif } @@ -632,39 +617,32 @@ qint64 QFSFileEnginePrivate::nativePos() const */ bool QFSFileEnginePrivate::nativeSeek(qint64 pos) { - Q_Q(const QFSFileEngine); - QFSFileEngine *thatQ = const_cast(q); + Q_Q(QFSFileEngine); if (fh || fd != -1) { // stdlib / stdio mode. return seekFdFh(pos); } -#if !defined(QT_NO_LIBRARY) && !defined(Q_OS_WINCE) - QFSFileEnginePrivate::resolveLibs(); - if (!ptrSetFilePointerEx) { -#endif - DWORD newFilePointer; - LARGE_INTEGER *li = reinterpret_cast(&pos); - newFilePointer = SetFilePointer(fileHandle, li->LowPart, &li->HighPart, FILE_BEGIN); - if (newFilePointer == 0xFFFFFFFF && GetLastError() != NO_ERROR) { - thatQ->setError(QFile::PositionError, qt_error_string()); - return false; - } - - // Note: This is the case for MOC, UIC, qmake and other - // bootstrapped tools, and for Windows CE. - return true; -#if !defined(QT_NO_LIBRARY) && !defined(Q_OS_WINCE) - } - +#if !defined(Q_OS_WINCE) LARGE_INTEGER currentFilePos; LARGE_INTEGER offset; offset.QuadPart = pos; - if (ptrSetFilePointerEx(fileHandle, offset, ¤tFilePos, FILE_BEGIN) == 0) { - thatQ->setError(QFile::UnspecifiedError, qt_error_string()); + if (!::SetFilePointerEx(fileHandle, offset, ¤tFilePos, FILE_BEGIN)) { + q->setError(QFile::UnspecifiedError, qt_error_string()); + return false; + } + + return true; +#else + DWORD newFilePointer; + LARGE_INTEGER *li = reinterpret_cast(&pos); + newFilePointer = SetFilePointer(fileHandle, li->LowPart, &li->HighPart, FILE_BEGIN); + if (newFilePointer == 0xFFFFFFFF && GetLastError() != NO_ERROR) { + q->setError(QFile::PositionError, qt_error_string()); return false; } + return true; #endif } @@ -1044,10 +1022,10 @@ QString QFSFileEngine::homePath() QString ret; #if !defined(QT_NO_LIBRARY) QFSFileEnginePrivate::resolveLibs(); - if (ptrOpenProcessToken && ptrGetUserProfileDirectoryW) { + if (ptrGetUserProfileDirectoryW) { HANDLE hnd = ::GetCurrentProcess(); HANDLE token = 0; - BOOL ok = ::ptrOpenProcessToken(hnd, TOKEN_QUERY, &token); + BOOL ok = ::OpenProcessToken(hnd, TOKEN_QUERY, &token); if (ok) { DWORD dwBufferSize = 0; // First call, to determine size of the strings (with '\0'). -- cgit v1.2.3 From a208436c0370dd92401647c15d48b22965f531ee Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Thu, 13 Aug 2009 18:44:35 +0200 Subject: use BuildTrusteeWithSid instead of BuildTrusteeWithName Get current user SID from the token of the current process and use it to fill UserTrustee with BuildTrusteeWithSid; Remove workaround for buggy secur32.dll version. Merge-request: 1167 Reviewed-by: Joerg Bornemann --- src/corelib/io/qfsfileengine_win.cpp | 65 ++++++++---------------------------- 1 file changed, 13 insertions(+), 52 deletions(-) diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index d7d168400..0619fa6c9 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -111,8 +111,6 @@ typedef BOOL (WINAPI *PtrAllocateAndInitializeSid)(PSID_IDENTIFIER_AUTHORITY, BY static PtrAllocateAndInitializeSid ptrAllocateAndInitializeSid = 0; typedef VOID (WINAPI *PtrBuildTrusteeWithSidW)(PTRUSTEE_W, PSID); static PtrBuildTrusteeWithSidW ptrBuildTrusteeWithSidW = 0; -typedef VOID (WINAPI *PtrBuildTrusteeWithNameW)(PTRUSTEE_W, unsigned short*); -static PtrBuildTrusteeWithNameW ptrBuildTrusteeWithNameW = 0; typedef DWORD (WINAPI *PtrGetEffectiveRightsFromAclW)(PACL, PTRUSTEE_W, OUT PACCESS_MASK); static PtrGetEffectiveRightsFromAclW ptrGetEffectiveRightsFromAclW = 0; typedef PVOID (WINAPI *PtrFreeSid)(PSID); @@ -150,61 +148,24 @@ void QFSFileEnginePrivate::resolveLibs() ptrLookupAccountSidW = (PtrLookupAccountSidW)GetProcAddress(advapiHnd, "LookupAccountSidW"); ptrAllocateAndInitializeSid = (PtrAllocateAndInitializeSid)GetProcAddress(advapiHnd, "AllocateAndInitializeSid"); ptrBuildTrusteeWithSidW = (PtrBuildTrusteeWithSidW)GetProcAddress(advapiHnd, "BuildTrusteeWithSidW"); - ptrBuildTrusteeWithNameW = (PtrBuildTrusteeWithNameW)GetProcAddress(advapiHnd, "BuildTrusteeWithNameW"); ptrGetEffectiveRightsFromAclW = (PtrGetEffectiveRightsFromAclW)GetProcAddress(advapiHnd, "GetEffectiveRightsFromAclW"); ptrFreeSid = (PtrFreeSid)GetProcAddress(advapiHnd, "FreeSid"); } - if (ptrBuildTrusteeWithNameW) { - HINSTANCE versionHnd = LoadLibraryW(L"version"); - if (versionHnd) { - typedef DWORD (WINAPI *PtrGetFileVersionInfoSizeW)(LPCWSTR lptstrFilename,LPDWORD lpdwHandle); - PtrGetFileVersionInfoSizeW ptrGetFileVersionInfoSizeW = (PtrGetFileVersionInfoSizeW)GetProcAddress(versionHnd, "GetFileVersionInfoSizeW"); - typedef BOOL (WINAPI *PtrGetFileVersionInfoW)(LPCWSTR lptstrFilename,DWORD dwHandle,DWORD dwLen,LPVOID lpData); - PtrGetFileVersionInfoW ptrGetFileVersionInfoW = (PtrGetFileVersionInfoW)GetProcAddress(versionHnd, "GetFileVersionInfoW"); - typedef BOOL (WINAPI *PtrVerQueryValueW)(const LPVOID pBlock,LPCWSTR lpSubBlock,LPVOID *lplpBuffer,PUINT puLen); - PtrVerQueryValueW ptrVerQueryValueW = (PtrVerQueryValueW)GetProcAddress(versionHnd, "VerQueryValueW"); - if(ptrGetFileVersionInfoSizeW && ptrGetFileVersionInfoW && ptrVerQueryValueW) { - DWORD fakeHandle; - DWORD versionSize = ptrGetFileVersionInfoSizeW(L"secur32.dll", &fakeHandle); - if(versionSize) { - LPVOID versionData; - versionData = malloc(versionSize); - if(ptrGetFileVersionInfoW(L"secur32.dll", 0, versionSize, versionData)) { - UINT puLen; - VS_FIXEDFILEINFO *pLocalInfo; - if(ptrVerQueryValueW(versionData, L"\\", (void**)&pLocalInfo, &puLen)) { - WORD wVer1, wVer2, wVer3, wVer4; - wVer1 = HIWORD(pLocalInfo->dwFileVersionMS); - wVer2 = LOWORD(pLocalInfo->dwFileVersionMS); - wVer3 = HIWORD(pLocalInfo->dwFileVersionLS); - wVer4 = LOWORD(pLocalInfo->dwFileVersionLS); - // It will not work with secur32.dll version 5.0.2195.2862 - if(!(wVer1 == 5 && wVer2 == 0 && wVer3 == 2195 && (wVer4 == 2862 || wVer4 == 4587))) { - HINSTANCE userHnd = LoadLibraryW(L"secur32"); - if (userHnd) { - typedef BOOL (WINAPI *PtrGetUserNameExW)(EXTENDED_NAME_FORMAT nameFormat, ushort* lpBuffer, LPDWORD nSize); - PtrGetUserNameExW ptrGetUserNameExW = (PtrGetUserNameExW)GetProcAddress(userHnd, "GetUserNameExW"); - if(ptrGetUserNameExW) { - static wchar_t buffer[258]; - DWORD bufferSize = 257; - ptrGetUserNameExW(NameSamCompatible, (ushort*)buffer, &bufferSize); - ptrBuildTrusteeWithNameW(¤tUserTrusteeW, (ushort*)buffer); - } - FreeLibrary(userHnd); - } - } - } - } - free(versionData); - } - } - FreeLibrary(versionHnd); - } - HINSTANCE userenvHnd = LoadLibraryW(L"userenv"); - if (userenvHnd) { - ptrGetUserProfileDirectoryW = (PtrGetUserProfileDirectoryW)GetProcAddress(userenvHnd, "GetUserProfileDirectoryW"); + if (ptrBuildTrusteeWithSidW) { + // Create TRUSTEE for current user + HANDLE hnd = ::GetCurrentProcess(); + HANDLE token = 0; + if (::OpenProcessToken(hnd, TOKEN_QUERY, &token)) { + TOKEN_USER tu; + DWORD retsize; + if (::GetTokenInformation(token, TokenUser, &tu, sizeof(tu), &retsize)) + ptrBuildTrusteeWithSidW(¤tUserTrusteeW, tu.User.Sid); + ::CloseHandle(token); } } + HINSTANCE userenvHnd = LoadLibraryW(L"userenv"); + if (userenvHnd) + ptrGetUserProfileDirectoryW = (PtrGetUserProfileDirectoryW)GetProcAddress(userenvHnd, "GetUserProfileDirectoryW"); #endif } } -- cgit v1.2.3 From 0d36864727007671b0ee01ab501fec0988c71011 Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Thu, 13 Aug 2009 18:44:37 +0200 Subject: create world TRUSTEE only once in QFSFileEngine (Win) Don't re-create world TRUSTEE everytime in getPermissions() Merge-request: 1167 Reviewed-by: Joerg Bornemann --- src/corelib/io/qfsfileengine_win.cpp | 45 ++++++++++++++++++------------------ 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index 0619fa6c9..e500d6762 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -107,15 +107,12 @@ typedef DWORD (WINAPI *PtrGetNamedSecurityInfoW)(LPWSTR, SE_OBJECT_TYPE, SECURIT static PtrGetNamedSecurityInfoW ptrGetNamedSecurityInfoW = 0; typedef BOOL (WINAPI *PtrLookupAccountSidW)(LPCWSTR, PSID, LPWSTR, LPDWORD, LPWSTR, LPDWORD, PSID_NAME_USE); static PtrLookupAccountSidW ptrLookupAccountSidW = 0; -typedef BOOL (WINAPI *PtrAllocateAndInitializeSid)(PSID_IDENTIFIER_AUTHORITY, BYTE, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, PSID*); -static PtrAllocateAndInitializeSid ptrAllocateAndInitializeSid = 0; typedef VOID (WINAPI *PtrBuildTrusteeWithSidW)(PTRUSTEE_W, PSID); static PtrBuildTrusteeWithSidW ptrBuildTrusteeWithSidW = 0; typedef DWORD (WINAPI *PtrGetEffectiveRightsFromAclW)(PACL, PTRUSTEE_W, OUT PACCESS_MASK); static PtrGetEffectiveRightsFromAclW ptrGetEffectiveRightsFromAclW = 0; -typedef PVOID (WINAPI *PtrFreeSid)(PSID); -static PtrFreeSid ptrFreeSid = 0; static TRUSTEE_W currentUserTrusteeW; +static TRUSTEE_W worldTrusteeW; typedef BOOL (WINAPI *PtrGetUserProfileDirectoryW)(HANDLE, LPWSTR, LPDWORD); static PtrGetUserProfileDirectoryW ptrGetUserProfileDirectoryW = 0; @@ -146,10 +143,8 @@ void QFSFileEnginePrivate::resolveLibs() if (advapiHnd) { ptrGetNamedSecurityInfoW = (PtrGetNamedSecurityInfoW)GetProcAddress(advapiHnd, "GetNamedSecurityInfoW"); ptrLookupAccountSidW = (PtrLookupAccountSidW)GetProcAddress(advapiHnd, "LookupAccountSidW"); - ptrAllocateAndInitializeSid = (PtrAllocateAndInitializeSid)GetProcAddress(advapiHnd, "AllocateAndInitializeSid"); ptrBuildTrusteeWithSidW = (PtrBuildTrusteeWithSidW)GetProcAddress(advapiHnd, "BuildTrusteeWithSidW"); ptrGetEffectiveRightsFromAclW = (PtrGetEffectiveRightsFromAclW)GetProcAddress(advapiHnd, "GetEffectiveRightsFromAclW"); - ptrFreeSid = (PtrFreeSid)GetProcAddress(advapiHnd, "FreeSid"); } if (ptrBuildTrusteeWithSidW) { // Create TRUSTEE for current user @@ -162,6 +157,19 @@ void QFSFileEnginePrivate::resolveLibs() ptrBuildTrusteeWithSidW(¤tUserTrusteeW, tu.User.Sid); ::CloseHandle(token); } + + typedef BOOL (WINAPI *PtrAllocateAndInitializeSid)(PSID_IDENTIFIER_AUTHORITY, BYTE, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, DWORD, PSID*); + PtrAllocateAndInitializeSid ptrAllocateAndInitializeSid = (PtrAllocateAndInitializeSid)GetProcAddress(advapiHnd, "AllocateAndInitializeSid"); + typedef PVOID (WINAPI *PtrFreeSid)(PSID); + PtrFreeSid ptrFreeSid = (PtrFreeSid)GetProcAddress(advapiHnd, "FreeSid"); + if (ptrAllocateAndInitializeSid && ptrFreeSid) { + // Create TRUSTEE for Everyone (World) + SID_IDENTIFIER_AUTHORITY worldAuth = { SECURITY_WORLD_SID_AUTHORITY }; + PSID pWorld = 0; + if (ptrAllocateAndInitializeSid(&worldAuth, 1, SECURITY_WORLD_RID, 0, 0, 0, 0, 0, 0, 0, &pWorld)) + ptrBuildTrusteeWithSidW(&worldTrusteeW, pWorld); + ptrFreeSid(pWorld); + } } HINSTANCE userenvHnd = LoadLibraryW(L"userenv"); if (userenvHnd) @@ -1332,7 +1340,7 @@ QAbstractFileEngine::FileFlags QFSFileEnginePrivate::getPermissions() const enum { ReadMask = 0x00000001, WriteMask = 0x00000002, ExecMask = 0x00000020 }; resolveLibs(); - if(ptrGetNamedSecurityInfoW && ptrAllocateAndInitializeSid && ptrBuildTrusteeWithSidW && ptrGetEffectiveRightsFromAclW && ptrFreeSid) { + if(ptrGetNamedSecurityInfoW && ptrBuildTrusteeWithSidW && ptrGetEffectiveRightsFromAclW) { QString fname = filePath.endsWith(QLatin1String(".lnk")) ? readLink(filePath) : filePath; DWORD res = ptrGetNamedSecurityInfoW((wchar_t*)fname.utf16(), SE_FILE_OBJECT, @@ -1374,21 +1382,14 @@ QAbstractFileEngine::FileFlags QFSFileEnginePrivate::getPermissions() const ret |= QAbstractFileEngine::ExeGroupPerm; } { //other (world) - // Create SID for Everyone (World) - SID_IDENTIFIER_AUTHORITY worldAuth = { SECURITY_WORLD_SID_AUTHORITY }; - PSID pWorld = 0; - if(ptrAllocateAndInitializeSid(&worldAuth, 1, SECURITY_WORLD_RID, 0,0,0,0,0,0,0, &pWorld)) { - ptrBuildTrusteeWithSidW(&trustee, pWorld); - if(ptrGetEffectiveRightsFromAclW(pDacl, &trustee, &access_mask) != ERROR_SUCCESS) - access_mask = (ACCESS_MASK)-1; // ### - if(access_mask & ReadMask) - ret |= QAbstractFileEngine::ReadOtherPerm; - if(access_mask & WriteMask) - ret |= QAbstractFileEngine::WriteOtherPerm; - if(access_mask & ExecMask) - ret |= QAbstractFileEngine::ExeOtherPerm; - } - ptrFreeSid(pWorld); + if(ptrGetEffectiveRightsFromAclW(pDacl, &worldTrusteeW, &access_mask) != ERROR_SUCCESS) + access_mask = (ACCESS_MASK)-1; // ### + if(access_mask & ReadMask) + ret |= QAbstractFileEngine::ReadOtherPerm; + if(access_mask & WriteMask) + ret |= QAbstractFileEngine::WriteOtherPerm; + if(access_mask & ExecMask) + ret |= QAbstractFileEngine::ExeOtherPerm; } LocalFree(pSD); } -- cgit v1.2.3 From 98fb13e3ef2627664642c21f34d11c10537379f7 Mon Sep 17 00:00:00 2001 From: Ritt Konstantin Date: Thu, 13 Aug 2009 18:44:39 +0200 Subject: remove unneeded distinction between Windows and Windows CE Merge-request: 1167 Reviewed-by: Joerg Bornemann --- src/corelib/io/qfsfileengine_win.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp index e500d6762..4bae9f467 100644 --- a/src/corelib/io/qfsfileengine_win.cpp +++ b/src/corelib/io/qfsfileengine_win.cpp @@ -1643,12 +1643,8 @@ bool QFSFileEngine::setPermissions(uint perms) if (mode == 0) // not supported return false; -#if !defined(Q_OS_WINCE) - ret = ::_wchmod((wchar_t*)d->filePath.utf16(), mode) == 0; -#else ret = ::_wchmod((wchar_t*)d->longFileName(d->filePath).utf16(), mode) == 0; -#endif - return ret; + return ret; } bool QFSFileEngine::setSize(qint64 size) -- cgit v1.2.3