diff options
author | Bradley T. Hughes <bradley.hughes@nokia.com> | 2011-09-09 11:07:48 +0200 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2011-09-26 16:05:36 +0200 |
commit | 54255f7c5e7cecc58076c412183ce2d877a34c18 (patch) | |
tree | 29cddf2af89a144f794c86cb24cb1d5eb0db1de1 /src/corelib/tools/qvector.h | |
parent | 67fec4a5f5f164a24481921eab57955ce0d607f0 (diff) |
Make QVectorData::shared_null const
Similar to QByteArray and QString, keep the shared_null in shareable
memory and never modify it.
Since QRegion uses the internals of QVector, we need to make sure that
QRegion also never modifies the shared_null.
Change-Id: I809e5873fe414138f97d501e05458b73c04b18fb
Reviewed-on: http://codereview.qt-project.org/4529
Reviewed-by: Qt Sanity Bot <qt_sanity_bot@ovi.com>
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
Diffstat (limited to 'src/corelib/tools/qvector.h')
-rw-r--r-- | src/corelib/tools/qvector.h | 10 |
1 files changed, 5 insertions, 5 deletions
diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index 5c25266ede..34d1ed3717 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -42,10 +42,10 @@ #ifndef QVECTOR_H #define QVECTOR_H -#include <QtCore/qiterator.h> -#include <QtCore/qatomic.h> #include <QtCore/qalgorithms.h> +#include <QtCore/qiterator.h> #include <QtCore/qlist.h> +#include <QtCore/qrefcount.h> #ifndef QT_NO_STL #include <iterator> @@ -65,7 +65,7 @@ QT_MODULE(Core) struct Q_CORE_EXPORT QVectorData { - QBasicAtomicInt ref; + QtPrivate::RefCount ref; int alloc; int size; #if defined(QT_ARCH_SPARC) && defined(Q_CC_GNU) && defined(__LP64__) && defined(QT_BOOTSTRAPPED) @@ -79,7 +79,7 @@ struct Q_CORE_EXPORT QVectorData uint reserved : 30; #endif - static QVectorData shared_null; + static const QVectorData shared_null; // ### Qt 5: rename to 'allocate()'. The current name causes problems for // some debugges when the QVector is member of a class within an unnamed namespace. // ### Qt 5: can be removed completely. (Ralf) @@ -117,7 +117,7 @@ class QVector public: // ### Qt 5: Consider making QVector non-shared to get at least one // "really fast" container. See tests/benchmarks/corelib/tools/qvector/ - inline QVector() : d(&QVectorData::shared_null) { d->ref.ref(); } + inline QVector() : d(const_cast<QVectorData *>(&QVectorData::shared_null)) { } explicit QVector(int size); QVector(int size, const T &t); inline QVector(const QVector<T> &v) : d(v.d) { d->ref.ref(); if (!d->sharable) detach_helper(); } |