diff options
author | Bradley T. Hughes <bradley.hughes@nokia.com> | 2009-11-10 09:15:35 (GMT) |
---|---|---|
committer | Bradley T. Hughes <bradley.hughes@nokia.com> | 2009-11-10 09:15:35 (GMT) |
commit | 6d33c770d9537f0ff331e60bd36fadf6911d34c4 (patch) | |
tree | 3fdc291984d1afcdebfc833abc03a6049d5d034a | |
parent | d70bae38a55f5cb61a6af0969b38b53697c492fd (diff) | |
parent | 7bfdec392df263b15fb5661ab7d4f66f1cd8fbae (diff) | |
download | Qt-6d33c770d9537f0ff331e60bd36fadf6911d34c4.zip Qt-6d33c770d9537f0ff331e60bd36fadf6911d34c4.tar.gz Qt-6d33c770d9537f0ff331e60bd36fadf6911d34c4.tar.bz2 |
Merge commit 'upstream/4.6' into 4.6
-rw-r--r-- | dist/changes-4.6.0 | 10 | ||||
-rw-r--r-- | src/corelib/tools/qscopedpointer.h | 52 | ||||
-rw-r--r-- | src/network/access/qhttpnetworkconnection.cpp | 4 | ||||
-rw-r--r-- | tests/auto/qscopedpointer/tst_qscopedpointer.cpp | 156 |
4 files changed, 163 insertions, 59 deletions
diff --git a/dist/changes-4.6.0 b/dist/changes-4.6.0 index 4635813..895421d 100644 --- a/dist/changes-4.6.0 +++ b/dist/changes-4.6.0 @@ -512,6 +512,16 @@ Qt for Embedded Linux - Remove obsolete OpenGL/ES screen drivers: hybrid, ahigl. +- Send enter/leave events also to child widgets + +- Fix crash when instantiating multiple QApplications + +- Optimize software cursor by using native image format instead of 8-bit + +- [255828] Avoid window decoration flicker on show + +- [255495] Fix blend function crash on AVR32 + Qt for Windows CE ----------------- - On Windows CE the link time code generation has been disabled by default to diff --git a/src/corelib/tools/qscopedpointer.h b/src/corelib/tools/qscopedpointer.h index 7cbdb6c..b433723 100644 --- a/src/corelib/tools/qscopedpointer.h +++ b/src/corelib/tools/qscopedpointer.h @@ -113,16 +113,6 @@ public: return d; } - inline bool operator==(const QScopedPointer<T, Cleanup> &other) const - { - return d == other.d; - } - - inline bool operator!=(const QScopedPointer<T, Cleanup> &other) const - { - return d != other.d; - } - inline bool operator!() const { return !d; @@ -181,6 +171,18 @@ private: }; template <class T, class Cleanup> +inline bool operator==(const QScopedPointer<T, Cleanup> &lhs, const QScopedPointer<T, Cleanup> &rhs) +{ + return lhs.data() == rhs.data(); +} + +template <class T, class Cleanup> +inline bool operator!=(const QScopedPointer<T, Cleanup> &lhs, const QScopedPointer<T, Cleanup> &rhs) +{ + return lhs.data() != rhs.data(); +} + +template <class T, class Cleanup> Q_INLINE_TEMPLATE void qSwap(QScopedPointer<T, Cleanup> &p1, QScopedPointer<T, Cleanup> &p2) { p1.swap(p2); } @@ -203,16 +205,6 @@ public: return this->d[i]; } - inline bool operator==(const QScopedArrayPointer<T, Cleanup> &other) const - { - return this->d == other.d; - } - - inline bool operator!=(const QScopedArrayPointer<T, Cleanup> &other) const - { - return this->d != other.d; - } - private: Q_DISABLE_COPY(QScopedArrayPointer) }; @@ -233,16 +225,6 @@ public: return this->d; } - inline bool operator==(const QCustomScopedPointer<T, Cleanup> &other) const - { - return this->d == other.d; - } - - inline bool operator!=(const QCustomScopedPointer<T, Cleanup> &other) const - { - return this->d != other.d; - } - private: Q_DISABLE_COPY(QCustomScopedPointer) }; @@ -287,16 +269,6 @@ public: QScopedPointerSharedDeleter<T>::cleanup(oldD); } - inline bool operator==(const QScopedSharedPointer<T> &other) const - { - return this->d == other.d; - } - - inline bool operator!=(const QScopedSharedPointer<T> &other) const - { - return this->d != other.d; - } - private: Q_DISABLE_COPY(QScopedSharedPointer) }; diff --git a/src/network/access/qhttpnetworkconnection.cpp b/src/network/access/qhttpnetworkconnection.cpp index 1124337..8dd7a00 100644 --- a/src/network/access/qhttpnetworkconnection.cpp +++ b/src/network/access/qhttpnetworkconnection.cpp @@ -372,7 +372,7 @@ void QHttpNetworkConnectionPrivate::createAuthorization(QAbstractSocket *socket, QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(channels[i].authenticator); if (priv && priv->method != QAuthenticatorPrivate::None) { QByteArray response = priv->calculateResponse(request.d->methodName(), request.d->uri(false)); - request.setHeaderField("authorization", response); + request.setHeaderField("Authorization", response); } } } @@ -381,7 +381,7 @@ void QHttpNetworkConnectionPrivate::createAuthorization(QAbstractSocket *socket, QAuthenticatorPrivate *priv = QAuthenticatorPrivate::getPrivate(channels[i].proxyAuthenticator); if (priv && priv->method != QAuthenticatorPrivate::None) { QByteArray response = priv->calculateResponse(request.d->methodName(), request.d->uri(false)); - request.setHeaderField("proxy-authorization", response); + request.setHeaderField("Proxy-Authorization", response); } } } diff --git a/tests/auto/qscopedpointer/tst_qscopedpointer.cpp b/tests/auto/qscopedpointer/tst_qscopedpointer.cpp index aeead15..f319891 100644 --- a/tests/auto/qscopedpointer/tst_qscopedpointer.cpp +++ b/tests/auto/qscopedpointer/tst_qscopedpointer.cpp @@ -313,30 +313,152 @@ void tst_QScopedPointer::objectSize() QCOMPARE(sizeof(QScopedPointer<int>), sizeof(void *)); } -void tst_QScopedPointer::comparison() +struct RefCounted { - int *a = new int(42); - int *b = new int(43); + RefCounted() + : ref(0) + { + instanceCount.ref(); + } + + RefCounted(RefCounted const &other) + : ref(0) + { + instanceCount.ref(); + } + + ~RefCounted() + { + QVERIFY( ref == 0 ); + instanceCount.deref(); + } + + RefCounted &operator=(RefCounted const &) + { + } + + QAtomicInt ref; + + static QAtomicInt instanceCount; +}; - QScopedPointer<int> pa(a); - QScopedPointer<int> pa2(a); - QScopedPointer<int> pb(b); +QAtomicInt RefCounted::instanceCount = 0; +template <class A1, class A2, class B> +void scopedPointerComparisonTest(const A1 &a1, const A2 &a2, const B &b) +{ // test equality on equal pointers - QVERIFY(pa == pa2); - QVERIFY(pa2 == pa); + QVERIFY(a1 == a2); + QVERIFY(a2 == a1); + + // test inequality on equal pointers + QVERIFY(!(a1 != a2)); + QVERIFY(!(a2 != a1)); + + // test equality on unequal pointers + QVERIFY(!(a1 == b)); + QVERIFY(!(a2 == b)); + QVERIFY(!(b == a1)); + QVERIFY(!(b == a2)); + + // test inequality on unequal pointers + QVERIFY(b != a1); + QVERIFY(b != a2); + QVERIFY(a1 != b); + QVERIFY(a2 != b); +} + +void tst_QScopedPointer::comparison() +{ + QCOMPARE( int(RefCounted::instanceCount), 0 ); + + { + RefCounted *a = new RefCounted; + RefCounted *b = new RefCounted; + + QCOMPARE( int(RefCounted::instanceCount), 2 ); + + QScopedPointer<RefCounted> pa1(a); + QScopedPointer<RefCounted> pa2(a); + QScopedPointer<RefCounted> pb(b); + + scopedPointerComparisonTest(pa1, pa1, pb); + scopedPointerComparisonTest(pa2, pa2, pb); + scopedPointerComparisonTest(pa1, pa2, pb); + + pa2.take(); + + QCOMPARE( int(RefCounted::instanceCount), 2 ); + } - // test unequality on equal pointers - QVERIFY(!(pa != pa2)); - QVERIFY(!(pa2 != pa)); + QCOMPARE( int(RefCounted::instanceCount), 0 ); - // test on unequal pointers - QVERIFY(!(pa == pb)); - QVERIFY(!(pb == pa)); - QVERIFY(pb != pa); - QVERIFY(pa != pb); + { + RefCounted *a = new RefCounted[42]; + RefCounted *b = new RefCounted[43]; + + QCOMPARE( int(RefCounted::instanceCount), 85 ); + + QScopedArrayPointer<RefCounted> pa1(a); + QScopedArrayPointer<RefCounted> pa2(a); + QScopedArrayPointer<RefCounted> pb(b); + + scopedPointerComparisonTest(pa1, pa2, pb); + + pa2.take(); + + QCOMPARE( int(RefCounted::instanceCount), 85 ); + } + + QCOMPARE( int(RefCounted::instanceCount), 0 ); + + { + // QCustomScopedPointer is an internal helper class -- it is unsupported! + + RefCounted *a = new RefCounted; + RefCounted *b = new RefCounted; + + QCOMPARE( int(RefCounted::instanceCount), 2 ); + + QCustomScopedPointer<RefCounted> pa1(a); + QCustomScopedPointer<RefCounted> pa2(a); + QCustomScopedPointer<RefCounted> pb(b); + + scopedPointerComparisonTest(pa1, pa2, pb); + + pa2.take(); + + QCOMPARE( int(RefCounted::instanceCount), 2 ); + } + + QCOMPARE( int(RefCounted::instanceCount), 0 ); + + { + // QScopedSharedPointer is an internal helper class -- it is unsupported! + + RefCounted *a = new RefCounted; + RefCounted *b = new RefCounted; + + QCOMPARE( int(RefCounted::instanceCount), 2 ); + + a->ref.ref(); + QScopedSharedPointer<RefCounted> pa1(a); + a->ref.ref(); + QScopedSharedPointer<RefCounted> pa2(a); + b->ref.ref(); + QScopedSharedPointer<RefCounted> pb(b); + + + QCOMPARE( int(a->ref), 2 ); + QCOMPARE( int(b->ref), 1 ); + QCOMPARE( int(RefCounted::instanceCount), 2 ); + + scopedPointerComparisonTest(pa1, pa2, pb); + + QCOMPARE( int(RefCounted::instanceCount), 2 ); + } - pa2.take(); + QCOMPARE( int(RefCounted::instanceCount), 0 ); } QTEST_MAIN(tst_QScopedPointer) |