From f8f501ec9853231805097a5dbaf0ea99196e8014 Mon Sep 17 00:00:00 2001 From: "Bradley T. Hughes" Date: Fri, 9 Sep 2011 11:10:48 +0200 Subject: Make QLinkedListData::shared_null const Similar to QList, QMap, QVector, QByteArray and QString, keep the shared_null in shareable memory and never modify it. Change-Id: I70b484d528c397a9d205b1418b6dc920c69dc725 Reviewed-on: http://codereview.qt-project.org/4532 Reviewed-by: Qt Sanity Bot Reviewed-by: Oswald Buddenhagen --- src/corelib/tools/qlinkedlist.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'src/corelib/tools/qlinkedlist.h') diff --git a/src/corelib/tools/qlinkedlist.h b/src/corelib/tools/qlinkedlist.h index 9f2834a7d7..bcad210d30 100644 --- a/src/corelib/tools/qlinkedlist.h +++ b/src/corelib/tools/qlinkedlist.h @@ -43,7 +43,7 @@ #define QLINKEDLIST_H #include -#include +#include #ifndef QT_NO_STL #include @@ -59,11 +59,11 @@ QT_MODULE(Core) struct Q_CORE_EXPORT QLinkedListData { QLinkedListData *n, *p; - QBasicAtomicInt ref; + QtPrivate::RefCount ref; int size; uint sharable : 1; - static QLinkedListData shared_null; + static const QLinkedListData shared_null; }; template @@ -81,7 +81,7 @@ class QLinkedList union { QLinkedListData *d; QLinkedListNode *e; }; public: - inline QLinkedList() : d(&QLinkedListData::shared_null) { d->ref.ref(); } + inline QLinkedList() : d(const_cast(&QLinkedListData::shared_null)) { } inline QLinkedList(const QLinkedList &l) : d(l.d) { d->ref.ref(); if (!d->sharable) detach(); } ~QLinkedList(); QLinkedList &operator=(const QLinkedList &); -- cgit v1.2.3