From 83625c5cf59584609e5b0c44db7e01e32a26bd54 Mon Sep 17 00:00:00 2001 From: Ivailo Monev Date: Tue, 1 Nov 2016 17:38:09 +0000 Subject: [PATCH] mostly manual d pointer management Signed-off-by: Ivailo Monev --- src/core/concurrent/qthreadpool.cpp | 1 + src/core/io/qabstractfileengine.cpp | 2 + src/core/io/qabstractfileengine.h | 4 +- src/core/io/qdatastream.cpp | 11 ++++-- src/core/io/qdatastream.h | 2 +- src/core/io/qdir.cpp | 37 ++++++++++++------- src/core/io/qdir_p.h | 3 +- src/core/io/qdiriterator.cpp | 4 +- src/core/io/qdiriterator.h | 2 +- src/core/io/qfileinfo_p.h | 7 +++- src/core/io/qfsfileengine_iterator.cpp | 9 +++-- src/core/io/qfsfileengine_iterator_p.h | 2 +- src/core/io/qiodevice.cpp | 3 ++ src/core/io/qiodevice.h | 3 +- src/core/io/qresource.h | 2 +- src/core/io/qsettings.cpp | 1 + src/core/io/qsettings.h | 2 +- src/core/io/qtextstream.cpp | 1 + src/core/io/qtextstream.h | 2 +- src/core/kernel/qcoreapplication.cpp | 1 + src/core/kernel/qobject.cpp | 6 ++- src/core/kernel/qobject.h | 7 +--- src/core/kernel/qsystemsemaphore.cpp | 1 + src/core/kernel/qsystemsemaphore.h | 3 +- src/core/thread/qthread.cpp | 5 ++- src/core/tools/qregexp.cpp | 1 + src/core/xml/qxmlstream.cpp | 2 + src/core/xml/qxmlstream.h | 4 +- src/dbus/qdbusabstractadaptor.cpp | 2 +- src/gui/graphicsview/qgraphicsitem.cpp | 2 +- src/gui/itemviews/qabstractitemview_p.h | 2 +- src/gui/itemviews/qtreewidget.cpp | 2 +- src/gui/kernel/qwidget.cpp | 2 +- src/gui/text/qzip.cpp | 1 + src/network/access/qhttp.cpp | 1 + src/network/access/qhttp.h | 3 +- src/network/kernel/qhostaddress.cpp | 5 ++- src/network/kernel/qhostaddress.h | 3 +- src/network/kernel/qhostinfo.cpp | 5 ++- src/network/kernel/qhostinfo.h | 3 +- src/network/kernel/qnetworkinterface.cpp | 5 ++- src/network/kernel/qnetworkinterface.h | 3 +- src/network/socket/qsocks5socketengine.cpp | 1 + src/network/ssl/qsslcipher.cpp | 5 ++- src/network/ssl/qsslcipher.h | 3 +- src/network/ssl/qsslerror.cpp | 35 +++--------------- src/network/ssl/qsslerror.h | 10 ++--- .../qtgradienteditor/qtgradientstopsmodel.cpp | 2 + .../qtgradienteditor/qtgradientstopsmodel.h | 6 ++- src/test/qtestcase.cpp | 1 + 50 files changed, 122 insertions(+), 108 deletions(-) diff --git a/src/core/concurrent/qthreadpool.cpp b/src/core/concurrent/qthreadpool.cpp index 5d30b0fc3..c140863ce 100644 --- a/src/core/concurrent/qthreadpool.cpp +++ b/src/core/concurrent/qthreadpool.cpp @@ -42,6 +42,7 @@ #include "qthreadpool.h" #include "qthreadpool_p.h" #include "qelapsedtimer.h" +#include "qscopedpointer.h" #ifndef QT_NO_THREAD diff --git a/src/core/io/qabstractfileengine.cpp b/src/core/io/qabstractfileengine.cpp index 6c036c1a2..553853da4 100644 --- a/src/core/io/qabstractfileengine.cpp +++ b/src/core/io/qabstractfileengine.cpp @@ -362,6 +362,7 @@ QAbstractFileEngine::QAbstractFileEngine(QAbstractFileEnginePrivate &dd) : d_ptr */ QAbstractFileEngine::~QAbstractFileEngine() { + delete d_ptr; } /*! @@ -889,6 +890,7 @@ QAbstractFileEngineIterator::QAbstractFileEngineIterator(QDir::Filters filters, */ QAbstractFileEngineIterator::~QAbstractFileEngineIterator() { + delete d; } /*! diff --git a/src/core/io/qabstractfileengine.h b/src/core/io/qabstractfileengine.h index 7c4dbac01..199d502d0 100644 --- a/src/core/io/qabstractfileengine.h +++ b/src/core/io/qabstractfileengine.h @@ -190,7 +190,7 @@ protected: QAbstractFileEngine(); QAbstractFileEngine(QAbstractFileEnginePrivate &); - QScopedPointer d_ptr; + QAbstractFileEnginePrivate* d_ptr; private: Q_DECLARE_PRIVATE(QAbstractFileEngine) Q_DISABLE_COPY(QAbstractFileEngine) @@ -234,7 +234,7 @@ private: friend class QDirIterator; friend class QDirIteratorPrivate; void setPath(const QString &path); - QScopedPointer d; + QAbstractFileEngineIteratorPrivate* d; }; QT_END_NAMESPACE diff --git a/src/core/io/qdatastream.cpp b/src/core/io/qdatastream.cpp index 216a16e36..f3df27c18 100644 --- a/src/core/io/qdatastream.cpp +++ b/src/core/io/qdatastream.cpp @@ -260,6 +260,7 @@ QT_BEGIN_NAMESPACE QDataStream::QDataStream() { + d = Q_NULLPTR; dev = 0; owndev = false; byteorder = BigEndian; @@ -280,9 +281,10 @@ QDataStream::QDataStream() \sa setDevice(), device() */ -QDataStream::QDataStream(QIODevice *d) +QDataStream::QDataStream(QIODevice *device) { - dev = d; // set device + d = Q_NULLPTR; + dev = device; // set device owndev = false; byteorder = BigEndian; // default byte order ver = QDataStream::Qt_Default; @@ -306,6 +308,7 @@ QDataStream::QDataStream(QIODevice *d) QDataStream::QDataStream(QByteArray *a, QIODevice::OpenMode flags) { + d = Q_NULLPTR; QBuffer *buf = new QBuffer(a); #ifndef QT_NO_QOBJECT buf->blockSignals(true); @@ -329,6 +332,7 @@ QDataStream::QDataStream(QByteArray *a, QIODevice::OpenMode flags) */ QDataStream::QDataStream(const QByteArray &a) { + d = Q_NULLPTR; QBuffer *buf = new QBuffer; #ifndef QT_NO_QOBJECT buf->blockSignals(true); @@ -356,6 +360,7 @@ QDataStream::~QDataStream() { if (owndev) delete dev; + delete d; } @@ -433,7 +438,7 @@ QDataStream::FloatingPointPrecision QDataStream::floatingPointPrecision() const void QDataStream::setFloatingPointPrecision(QDataStream::FloatingPointPrecision precision) { if (d == 0) - d.reset(new QDataStreamPrivate()); + d = new QDataStreamPrivate(); d->floatingPointPrecision = precision; } diff --git a/src/core/io/qdatastream.h b/src/core/io/qdatastream.h index c95910f78..389d80cd4 100644 --- a/src/core/io/qdatastream.h +++ b/src/core/io/qdatastream.h @@ -161,7 +161,7 @@ public: private: Q_DISABLE_COPY(QDataStream) - QScopedPointer d; + QDataStreamPrivate* d; QIODevice *dev; bool owndev; diff --git a/src/core/io/qdir.cpp b/src/core/io/qdir.cpp index a359a7ced..f2fd9799c 100644 --- a/src/core/io/qdir.cpp +++ b/src/core/io/qdir.cpp @@ -57,6 +57,7 @@ #include "qfilesystementry_p.h" #include "qfilesystemmetadata_p.h" #include "qfilesystemengine_p.h" +#include "qscopedpointer.h" #ifdef QT_BUILD_CORE_LIB # include "qresource.h" @@ -82,6 +83,7 @@ QDirPrivate::QDirPrivate(const QString &path, const QStringList &nameFilters_, Q , nameFilters(nameFilters_) , sort(sort_) , filters(filters_) + , fileEngine(Q_NULLPTR) , fileListsInitialized(false) { setPath(path.isEmpty() ? QString::fromLatin1(".") : path); @@ -105,15 +107,21 @@ QDirPrivate::QDirPrivate(const QDirPrivate ©) , nameFilters(copy.nameFilters) , sort(copy.sort) , filters(copy.filters) + , fileEngine(0) , fileListsInitialized(false) , dirEntry(copy.dirEntry) , metaData(copy.metaData) { } +QDirPrivate::~QDirPrivate() +{ + delete fileEngine; +} + bool QDirPrivate::exists() const { - if (fileEngine.isNull()) { + if (!fileEngine) { QFileSystemEngine::fillMetaData(dirEntry, metaData, QFileSystemMetaData::ExistsAttribute | QFileSystemMetaData::DirectoryType); // always stat return metaData.exists() && metaData.isDirectory(); @@ -175,7 +183,7 @@ inline void QDirPrivate::resolveAbsoluteEntry() const return; QString absoluteName; - if (fileEngine.isNull()) { + if (!fileEngine) { if (!dirEntry.isRelative() && dirEntry.isClean()) { absoluteDirEntry = dirEntry; return; @@ -315,7 +323,8 @@ inline void QDirPrivate::initFileLists(const QDir &dir) const inline void QDirPrivate::initFileEngine() { - fileEngine.reset(QFileSystemEngine::resolveEntryAndCreateLegacyEngine(dirEntry, metaData)); + delete fileEngine; + fileEngine = QFileSystemEngine::resolveEntryAndCreateLegacyEngine(dirEntry, metaData); } /*! @@ -611,7 +620,7 @@ QString QDir::absolutePath() const QString QDir::canonicalPath() const { const QDirPrivate* d = d_ptr.constData(); - if (d->fileEngine.isNull()) { + if (!d->fileEngine) { QFileSystemEntry answer = QFileSystemEngine::canonicalName(d->dirEntry, d->metaData); return answer.filePath(); } @@ -1261,7 +1270,7 @@ bool QDir::mkdir(const QString &dirName) const const QDirPrivate* d = d_ptr.constData(); QString fn = filePath(dirName); - if (d->fileEngine.isNull()) + if (!d->fileEngine) return QFileSystemEngine::createDirectory(QFileSystemEntry(fn), false); return d->fileEngine->mkdir(fn, false); } @@ -1285,7 +1294,7 @@ bool QDir::rmdir(const QString &dirName) const const QDirPrivate* d = d_ptr.constData(); QString fn = filePath(dirName); - if (d->fileEngine.isNull()) + if (!d->fileEngine) return QFileSystemEngine::removeDirectory(QFileSystemEntry(fn), false); return d->fileEngine->rmdir(fn, false); @@ -1314,7 +1323,7 @@ bool QDir::mkpath(const QString &dirPath) const const QDirPrivate* d = d_ptr.constData(); QString fn = filePath(dirPath); - if (d->fileEngine.isNull()) + if (!d->fileEngine) return QFileSystemEngine::createDirectory(QFileSystemEntry(fn), true); return d->fileEngine->mkdir(fn, true); } @@ -1340,7 +1349,7 @@ bool QDir::rmpath(const QString &dirPath) const const QDirPrivate* d = d_ptr.constData(); QString fn = filePath(dirPath); - if (d->fileEngine.isNull()) + if (!d->fileEngine) return QFileSystemEngine::removeDirectory(QFileSystemEntry(fn), true); return d->fileEngine->rmdir(fn, true); } @@ -1358,7 +1367,7 @@ bool QDir::isReadable() const { const QDirPrivate* d = d_ptr.constData(); - if (d->fileEngine.isNull()) { + if (!d->fileEngine) { if (!d->metaData.hasFlags(QFileSystemMetaData::UserReadPermission)) QFileSystemEngine::fillMetaData(d->dirEntry, d->metaData, QFileSystemMetaData::UserReadPermission); @@ -1403,7 +1412,7 @@ bool QDir::exists() const */ bool QDir::isRoot() const { - if (d_ptr->fileEngine.isNull()) + if (!d_ptr->fileEngine) return d_ptr->dirEntry.isRoot(); return d_ptr->fileEngine->fileFlags(QAbstractFileEngine::FlagsMask) & QAbstractFileEngine::RootFlag; } @@ -1435,7 +1444,7 @@ bool QDir::isRoot() const */ bool QDir::isRelative() const { - if (d_ptr->fileEngine.isNull()) + if (!d_ptr->fileEngine) return d_ptr->dirEntry.isRelative(); return d_ptr->fileEngine->isRelativePath(); } @@ -1452,7 +1461,7 @@ bool QDir::makeAbsolute() { const QDirPrivate *d = d_ptr.constData(); QScopedPointer dir; - if (!d->fileEngine.isNull()) { + if (d->fileEngine) { QString absolutePath = d->fileEngine->fileName(QAbstractFileEngine::AbsoluteName); if (QDir::isRelativePath(absolutePath)) return false; @@ -1485,8 +1494,8 @@ bool QDir::operator==(const QDir &dir) const if (d == other) return true; Qt::CaseSensitivity sensitive; - if (d->fileEngine.isNull() || other->fileEngine.isNull()) { - if (d->fileEngine.data() != other->fileEngine.data()) // one is native, the other is a custom file-engine + if (!d->fileEngine || !other->fileEngine) { + if (d->fileEngine != other->fileEngine) // one is native, the other is a custom file-engine return false; sensitive = QFileSystemEngine::isCaseSensitive() ? Qt::CaseSensitive : Qt::CaseInsensitive; diff --git a/src/core/io/qdir_p.h b/src/core/io/qdir_p.h index 8e4c5bad5..50864e758 100644 --- a/src/core/io/qdir_p.h +++ b/src/core/io/qdir_p.h @@ -55,6 +55,7 @@ public: QDir::Filters filters_ = QDir::AllEntries); QDirPrivate(const QDirPrivate ©); + ~QDirPrivate(); bool exists() const; @@ -78,7 +79,7 @@ public: QDir::Filters filters; - QScopedPointer fileEngine; + QAbstractFileEngine* fileEngine; mutable bool fileListsInitialized; mutable QStringList files; diff --git a/src/core/io/qdiriterator.cpp b/src/core/io/qdiriterator.cpp index 9f99cd6fc..02c9d3be1 100644 --- a/src/core/io/qdiriterator.cpp +++ b/src/core/io/qdiriterator.cpp @@ -406,11 +406,12 @@ bool QDirIteratorPrivate::matchesFilters(const QString &fileName, const QFileInf \sa hasNext(), next(), IteratorFlags */ QDirIterator::QDirIterator(const QDir &dir, IteratorFlags flags) + : d(Q_NULLPTR) { // little trick to get hold of the QDirPrivate while there is no API on QDir to give it to us class MyQDir : public QDir { public: const QDirPrivate *priv() const { return d_ptr.constData(); } }; const QDirPrivate *other = static_cast(&dir)->priv(); - d.reset(new QDirIteratorPrivate(other->dirEntry, other->nameFilters, other->filters, flags, !other->fileEngine.isNull())); + d = new QDirIteratorPrivate(other->dirEntry, other->nameFilters, other->filters, flags, other->fileEngine); } /*! @@ -472,6 +473,7 @@ QDirIterator::QDirIterator(const QString &path, const QStringList &nameFilters, */ QDirIterator::~QDirIterator() { + delete d; } /*! diff --git a/src/core/io/qdiriterator.h b/src/core/io/qdiriterator.h index 1d1b0cc9c..fa955b823 100644 --- a/src/core/io/qdiriterator.h +++ b/src/core/io/qdiriterator.h @@ -83,7 +83,7 @@ public: private: Q_DISABLE_COPY(QDirIterator) - QScopedPointer d; + QDirIteratorPrivate* d; friend class QDir; }; diff --git a/src/core/io/qfileinfo_p.h b/src/core/io/qfileinfo_p.h index e612699df..ab8f0636d 100644 --- a/src/core/io/qfileinfo_p.h +++ b/src/core/io/qfileinfo_p.h @@ -111,6 +111,11 @@ public: metaData = QFileSystemMetaData(); } + inline ~QFileInfoPrivate() + { + delete fileEngine; + } + inline void clearFlags() const { fileFlags = 0; cachedFlags = 0; @@ -134,7 +139,7 @@ public: QFileSystemEntry fileEntry; mutable QFileSystemMetaData metaData; - QScopedPointer const fileEngine; + QAbstractFileEngine* const fileEngine; mutable QString fileNames[QAbstractFileEngine::NFileNames]; mutable QString fileOwners[2]; diff --git a/src/core/io/qfsfileengine_iterator.cpp b/src/core/io/qfsfileengine_iterator.cpp index 6b835eab3..6c0c6025d 100644 --- a/src/core/io/qfsfileengine_iterator.cpp +++ b/src/core/io/qfsfileengine_iterator.cpp @@ -50,19 +50,21 @@ QT_BEGIN_NAMESPACE QFSFileEngineIterator::QFSFileEngineIterator(QDir::Filters filters, const QStringList &filterNames) : QAbstractFileEngineIterator(filters, filterNames) + , nativeIterator(Q_NULLPTR) , done(false) { } QFSFileEngineIterator::~QFSFileEngineIterator() { + delete nativeIterator; } bool QFSFileEngineIterator::hasNext() const { if (!done && !nativeIterator) { - nativeIterator.reset(new QFileSystemIterator(QFileSystemEntry(path()), - filters(), nameFilters())); + nativeIterator = new QFileSystemIterator(QFileSystemEntry(path()), + filters(), nameFilters()); advance(); } @@ -88,7 +90,8 @@ void QFSFileEngineIterator::advance() const nextInfo = QFileInfo(new QFileInfoPrivate(entry, data)); } else { done = true; - nativeIterator.reset(); + delete nativeIterator; + nativeIterator = Q_NULLPTR; } } diff --git a/src/core/io/qfsfileengine_iterator_p.h b/src/core/io/qfsfileengine_iterator_p.h index 4196fd0cd..ca95d5e1d 100644 --- a/src/core/io/qfsfileengine_iterator_p.h +++ b/src/core/io/qfsfileengine_iterator_p.h @@ -79,7 +79,7 @@ public: private: void advance() const; - mutable QScopedPointer nativeIterator; + mutable QFileSystemIterator* nativeIterator; mutable QFileInfo currentInfo; mutable QFileInfo nextInfo; mutable bool done; diff --git a/src/core/io/qiodevice.cpp b/src/core/io/qiodevice.cpp index 154b7564d..70313b270 100644 --- a/src/core/io/qiodevice.cpp +++ b/src/core/io/qiodevice.cpp @@ -405,6 +405,9 @@ QIODevice::~QIODevice() #if defined QIODEVICE_DEBUG printf("%p QIODevice::~QIODevice()\n", this); #endif +#ifdef QT_NO_QOBJECT + delete d_ptr; +#endif } /*! diff --git a/src/core/io/qiodevice.h b/src/core/io/qiodevice.h index 470e2a01f..e6d05dd15 100644 --- a/src/core/io/qiodevice.h +++ b/src/core/io/qiodevice.h @@ -46,7 +46,6 @@ #include #else #include -#include #endif #include @@ -160,7 +159,7 @@ protected: void setErrorString(const QString &errorString); #ifdef QT_NO_QOBJECT - QScopedPointer d_ptr; + QIODevicePrivate* d_ptr; #endif private: diff --git a/src/core/io/qresource.h b/src/core/io/qresource.h index 5d0a4977b..44d4bc3eb 100644 --- a/src/core/io/qresource.h +++ b/src/core/io/qresource.h @@ -88,7 +88,7 @@ protected: QStringList children() const; protected: - QScopedPointer d_ptr; + QResourcePrivate* d_ptr; private: Q_DECLARE_PRIVATE(QResource) diff --git a/src/core/io/qsettings.cpp b/src/core/io/qsettings.cpp index f0c5b2028..e47838d60 100644 --- a/src/core/io/qsettings.cpp +++ b/src/core/io/qsettings.cpp @@ -2472,6 +2472,7 @@ QSettings::~QSettings() ; // ok. then don't flush but at least don't throw in the destructor } } + delete d_ptr; } /*! diff --git a/src/core/io/qsettings.h b/src/core/io/qsettings.h index 1a92580ac..d7f9b0897 100644 --- a/src/core/io/qsettings.h +++ b/src/core/io/qsettings.h @@ -72,7 +72,7 @@ class Q_CORE_EXPORT QSettings #ifndef QT_NO_QOBJECT Q_OBJECT #else - QScopedPointer d_ptr; + QSettingsPrivate* d_ptr; #endif Q_DECLARE_PRIVATE(QSettings) diff --git a/src/core/io/qtextstream.cpp b/src/core/io/qtextstream.cpp index e0330bfaa..565b28ec5 100644 --- a/src/core/io/qtextstream.cpp +++ b/src/core/io/qtextstream.cpp @@ -1109,6 +1109,7 @@ QTextStream::~QTextStream() #endif if (!d->writeBuffer.isEmpty()) d->flushWriteBuffer(); + delete d_ptr; } /*! diff --git a/src/core/io/qtextstream.h b/src/core/io/qtextstream.h index 3de283565..f3c74051a 100644 --- a/src/core/io/qtextstream.h +++ b/src/core/io/qtextstream.h @@ -191,7 +191,7 @@ private: Q_DISABLE_COPY(QTextStream) - QScopedPointer d_ptr; + QTextStreamPrivate* d_ptr; }; Q_DECLARE_OPERATORS_FOR_FLAGS(QTextStream::NumberFlags) diff --git a/src/core/kernel/qcoreapplication.cpp b/src/core/kernel/qcoreapplication.cpp index 38b4dd92f..8db1410f9 100644 --- a/src/core/kernel/qcoreapplication.cpp +++ b/src/core/kernel/qcoreapplication.cpp @@ -65,6 +65,7 @@ #include #include #include +#include #if !defined(QT_NO_GLIB) # include "qeventdispatcher_glib_p.h" diff --git a/src/core/kernel/qobject.cpp b/src/core/kernel/qobject.cpp index 196e3b2fb..f58dccdf8 100644 --- a/src/core/kernel/qobject.cpp +++ b/src/core/kernel/qobject.cpp @@ -560,7 +560,7 @@ QObject::QObject(QObject *parent) : d_ptr(new QObjectPrivate) { Q_D(QObject); - d_ptr->q_ptr = this; + d->q_ptr = this; d->threadData = (parent && !parent->thread()) ? parent->d_func()->threadData : QThreadData::current(); d->threadData->ref(); if (parent) { @@ -583,7 +583,7 @@ QObject::QObject(QObjectPrivate &dd, QObject *parent) : d_ptr(&dd) { Q_D(QObject); - d_ptr->q_ptr = this; + d->q_ptr = this; d->threadData = (parent && !parent->thread()) ? parent->d_func()->threadData : QThreadData::current(); d->threadData->ref(); if (parent) { @@ -744,6 +744,8 @@ QObject::~QObject() if (d->parent) // remove it from parent object d->setParent_helper(0); + + delete d_ptr; } QObjectPrivate::Connection::~Connection() diff --git a/src/core/kernel/qobject.h b/src/core/kernel/qobject.h index 5674a17df..4a597075c 100644 --- a/src/core/kernel/qobject.h +++ b/src/core/kernel/qobject.h @@ -47,9 +47,9 @@ #include #include #include -#include #ifdef QT_INCLUDE_COMPAT +#include #include #endif @@ -233,12 +233,9 @@ protected: virtual void connectNotify(const char *signal); virtual void disconnectNotify(const char *signal); - -protected: QObject(QObjectPrivate &dd, QObject *parent = 0); -protected: - QScopedPointer d_ptr; + QObjectData* d_ptr; static const QMetaObject staticQtMetaObject; diff --git a/src/core/kernel/qsystemsemaphore.cpp b/src/core/kernel/qsystemsemaphore.cpp index 3617d5a06..1f3f2dd32 100644 --- a/src/core/kernel/qsystemsemaphore.cpp +++ b/src/core/kernel/qsystemsemaphore.cpp @@ -181,6 +181,7 @@ QSystemSemaphore::QSystemSemaphore(const QString &key, int initialValue, AccessM QSystemSemaphore::~QSystemSemaphore() { d->cleanHandle(); + delete d; } /*! diff --git a/src/core/kernel/qsystemsemaphore.h b/src/core/kernel/qsystemsemaphore.h index ea1149c18..174d975ef 100644 --- a/src/core/kernel/qsystemsemaphore.h +++ b/src/core/kernel/qsystemsemaphore.h @@ -43,7 +43,6 @@ #define QSYSTEMSEMAPHORE_H #include -#include QT_BEGIN_HEADER @@ -89,7 +88,7 @@ public: private: Q_DISABLE_COPY(QSystemSemaphore) - QScopedPointer d; + QSystemSemaphorePrivate* d; }; #endif // QT_NO_SYSTEMSEMAPHORE diff --git a/src/core/thread/qthread.cpp b/src/core/thread/qthread.cpp index 73cf30e85..4c2c278b2 100644 --- a/src/core/thread/qthread.cpp +++ b/src/core/thread/qthread.cpp @@ -45,10 +45,11 @@ #include "qmutexpool_p.h" #include "qreadwritelock.h" #include "qabstracteventdispatcher.h" -#include -#include +#include "qeventloop.h" +#include "qhash.h" #include "qthread_p.h" #include "qcoreapplication_p.h" +#include "qscopedpointer.h" QT_BEGIN_NAMESPACE diff --git a/src/core/tools/qregexp.cpp b/src/core/tools/qregexp.cpp index 38a7a5f77..e2e1aa223 100644 --- a/src/core/tools/qregexp.cpp +++ b/src/core/tools/qregexp.cpp @@ -53,6 +53,7 @@ #include "qstringmatcher.h" #include "qvector.h" #include "qfunctions_p.h" +#include "qscopedpointer.h" #include diff --git a/src/core/xml/qxmlstream.cpp b/src/core/xml/qxmlstream.cpp index fd0776831..a6c4baaf7 100644 --- a/src/core/xml/qxmlstream.cpp +++ b/src/core/xml/qxmlstream.cpp @@ -426,6 +426,7 @@ QXmlStreamReader::~QXmlStreamReader() Q_D(QXmlStreamReader); if (d->deleteDevice) delete d->device; + delete d_ptr; } /*! \fn bool QXmlStreamReader::hasError() const @@ -3225,6 +3226,7 @@ QXmlStreamWriter::QXmlStreamWriter(QString *string) */ QXmlStreamWriter::~QXmlStreamWriter() { + delete d_ptr; } diff --git a/src/core/xml/qxmlstream.h b/src/core/xml/qxmlstream.h index e132da73a..c739ef633 100644 --- a/src/core/xml/qxmlstream.h +++ b/src/core/xml/qxmlstream.h @@ -339,7 +339,7 @@ public: private: Q_DISABLE_COPY(QXmlStreamReader) Q_DECLARE_PRIVATE(QXmlStreamReader) - QScopedPointer d_ptr; + QXmlStreamReaderPrivate* d_ptr; }; #endif // QT_NO_XMLSTREAMREADER @@ -414,7 +414,7 @@ public: private: Q_DISABLE_COPY(QXmlStreamWriter) Q_DECLARE_PRIVATE(QXmlStreamWriter) - QScopedPointer d_ptr; + QXmlStreamWriterPrivate* d_ptr; }; #endif // QT_NO_XMLSTREAMWRITER diff --git a/src/dbus/qdbusabstractadaptor.cpp b/src/dbus/qdbusabstractadaptor.cpp index 55637d293..2b9a1208d 100644 --- a/src/dbus/qdbusabstractadaptor.cpp +++ b/src/dbus/qdbusabstractadaptor.cpp @@ -277,7 +277,7 @@ void QDBusAdaptorConnector::polish() void QDBusAdaptorConnector::relaySlot(void **argv) { - QObjectPrivate *d = static_cast(d_ptr.data()); + QObjectPrivate *d = static_cast(d_ptr); if (Q_LIKELY(d->currentSender)) { relay(d->currentSender->sender, d->currentSender->signal, argv); } else { diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 23df28276..87b681a51 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -1488,7 +1488,7 @@ QGraphicsItem::~QGraphicsItem() if (d_ptr->transformData) { for(int i = 0; i < d_ptr->transformData->graphicsTransforms.size(); ++i) { QGraphicsTransform *t = d_ptr->transformData->graphicsTransforms.at(i); - static_cast(t->d_ptr.data())->item = 0; + static_cast(t->d_ptr)->item = 0; delete t; } } diff --git a/src/gui/itemviews/qabstractitemview_p.h b/src/gui/itemviews/qabstractitemview_p.h index 7b9ab3354..6dbc8957d 100644 --- a/src/gui/itemviews/qabstractitemview_p.h +++ b/src/gui/itemviews/qabstractitemview_p.h @@ -332,7 +332,7 @@ public: */ inline bool isPersistent(const QModelIndex &index) const { - return static_cast(model->d_ptr.data())->persistent.indexes.contains(index); + return static_cast(model->d_ptr)->persistent.indexes.contains(index); } QModelIndexList selectedDraggableIndexes() const; diff --git a/src/gui/itemviews/qtreewidget.cpp b/src/gui/itemviews/qtreewidget.cpp index e23a6cbbe..b6d62f847 100644 --- a/src/gui/itemviews/qtreewidget.cpp +++ b/src/gui/itemviews/qtreewidget.cpp @@ -857,7 +857,7 @@ void QTreeModel::sortItems(QList *items, int column, Qt::SortO items->replace(r, item); for (int c = 0; c < colCount; ++c) { QModelIndex from = createIndex(oldRow, c, item); - if (static_cast(d_ptr.data())->persistent.indexes.contains(from)) { + if (static_cast(d_ptr)->persistent.indexes.contains(from)) { QModelIndex to = createIndex(r, c, item); fromList << from; toList << to; diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 8040dfbf2..e807e4deb 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -2119,7 +2119,7 @@ void QWidgetPrivate::paintBackground(QPainter *painter, const QRegion &rgn, int //If we are painting the viewport of a scrollarea, we must apply an offset to the brush in case we are drawing a texture QAbstractScrollArea *scrollArea = qobject_cast(parent); if (scrollArea && scrollArea->viewport() == q) { - QObjectData *scrollPrivate = static_cast(scrollArea)->d_ptr.data(); + QObjectData *scrollPrivate = static_cast(scrollArea)->d_ptr; QAbstractScrollAreaPrivate *priv = static_cast(scrollPrivate); oldBrushOrigin = painter->brushOrigin(); resetBrushOrigin = true; diff --git a/src/gui/text/qzip.cpp b/src/gui/text/qzip.cpp index 2f5793cc9..8430ff85a 100644 --- a/src/gui/text/qzip.cpp +++ b/src/gui/text/qzip.cpp @@ -50,6 +50,7 @@ #include #include #include +#include #if 0 #define ZDEBUG qDebug diff --git a/src/network/access/qhttp.cpp b/src/network/access/qhttp.cpp index 8b7de1e9c..f4459081b 100644 --- a/src/network/access/qhttp.cpp +++ b/src/network/access/qhttp.cpp @@ -619,6 +619,7 @@ QHttpHeader::QHttpHeader(QHttpHeaderPrivate &dd, const QHttpHeader &header) */ QHttpHeader::~QHttpHeader() { + delete d_ptr; } /*! diff --git a/src/network/access/qhttp.h b/src/network/access/qhttp.h index 694e98233..f88363240 100644 --- a/src/network/access/qhttp.h +++ b/src/network/access/qhttp.h @@ -46,7 +46,6 @@ #include #include #include -#include QT_BEGIN_HEADER @@ -108,7 +107,7 @@ protected: QHttpHeader(QHttpHeaderPrivate &dd, const QString &str = QString()); QHttpHeader(QHttpHeaderPrivate &dd, const QHttpHeader &header); - QScopedPointer d_ptr; + QHttpHeaderPrivate* d_ptr; private: Q_DECLARE_PRIVATE(QHttpHeader) diff --git a/src/network/kernel/qhostaddress.cpp b/src/network/kernel/qhostaddress.cpp index 657a45f4d..18ed7081a 100644 --- a/src/network/kernel/qhostaddress.cpp +++ b/src/network/kernel/qhostaddress.cpp @@ -486,7 +486,7 @@ QHostAddress::QHostAddress(const struct sockaddr *sockaddr) Constructs a copy of the given \a address. */ QHostAddress::QHostAddress(const QHostAddress &address) - : d(new QHostAddressPrivate(*address.d.data())) + : d(new QHostAddressPrivate(*address.d)) { } @@ -522,6 +522,7 @@ QHostAddress::QHostAddress(SpecialAddress address) */ QHostAddress::~QHostAddress() { + delete d; } /*! @@ -530,7 +531,7 @@ QHostAddress::~QHostAddress() */ QHostAddress &QHostAddress::operator=(const QHostAddress &address) { - *d.data() = *address.d.data(); + d = address.d; return *this; } diff --git a/src/network/kernel/qhostaddress.h b/src/network/kernel/qhostaddress.h index a3303c0e1..e929933ef 100644 --- a/src/network/kernel/qhostaddress.h +++ b/src/network/kernel/qhostaddress.h @@ -44,7 +44,6 @@ #include #include -#include #include struct sockaddr; @@ -122,7 +121,7 @@ public: static QPair parseSubnet(const QString &subnet); protected: - QScopedPointer d; + QHostAddressPrivate* d; }; inline bool operator ==(QHostAddress::SpecialAddress address1, const QHostAddress &address2) diff --git a/src/network/kernel/qhostinfo.cpp b/src/network/kernel/qhostinfo.cpp index 420c83b38..4cda5990b 100644 --- a/src/network/kernel/qhostinfo.cpp +++ b/src/network/kernel/qhostinfo.cpp @@ -293,7 +293,7 @@ QHostInfo::QHostInfo(int id) Constructs a copy of \a other. */ QHostInfo::QHostInfo(const QHostInfo &other) - : d(new QHostInfoPrivate(*other.d.data())) + : d(new QHostInfoPrivate(*other.d)) { } @@ -303,7 +303,7 @@ QHostInfo::QHostInfo(const QHostInfo &other) */ QHostInfo &QHostInfo::operator=(const QHostInfo &other) { - *d.data() = *other.d.data(); + d = other.d; return *this; } @@ -312,6 +312,7 @@ QHostInfo &QHostInfo::operator=(const QHostInfo &other) */ QHostInfo::~QHostInfo() { + delete d; } /*! diff --git a/src/network/kernel/qhostinfo.h b/src/network/kernel/qhostinfo.h index f3d80ab56..a72b167d0 100644 --- a/src/network/kernel/qhostinfo.h +++ b/src/network/kernel/qhostinfo.h @@ -43,7 +43,6 @@ #define QHOSTINFO_H #include -#include #include QT_BEGIN_HEADER @@ -91,7 +90,7 @@ public: static QString localDomainName(); private: - QScopedPointer d; + QHostInfoPrivate* d; }; QT_END_NAMESPACE diff --git a/src/network/kernel/qnetworkinterface.cpp b/src/network/kernel/qnetworkinterface.cpp index 8efdbfcf7..a0241d15d 100644 --- a/src/network/kernel/qnetworkinterface.cpp +++ b/src/network/kernel/qnetworkinterface.cpp @@ -165,7 +165,7 @@ QNetworkAddressEntry::QNetworkAddressEntry() object \a other. */ QNetworkAddressEntry::QNetworkAddressEntry(const QNetworkAddressEntry &other) - : d(new QNetworkAddressEntryPrivate(*other.d.data())) + : d(new QNetworkAddressEntryPrivate(*other.d)) { } @@ -174,7 +174,7 @@ QNetworkAddressEntry::QNetworkAddressEntry(const QNetworkAddressEntry &other) */ QNetworkAddressEntry &QNetworkAddressEntry::operator=(const QNetworkAddressEntry &other) { - *d.data() = *other.d.data(); + d = other.d; return *this; } @@ -183,6 +183,7 @@ QNetworkAddressEntry &QNetworkAddressEntry::operator=(const QNetworkAddressEntry */ QNetworkAddressEntry::~QNetworkAddressEntry() { + delete d; } /*! diff --git a/src/network/kernel/qnetworkinterface.h b/src/network/kernel/qnetworkinterface.h index 89ef35066..71045b3b9 100644 --- a/src/network/kernel/qnetworkinterface.h +++ b/src/network/kernel/qnetworkinterface.h @@ -43,7 +43,6 @@ #define QNETWORKINTERFACE_H #include -#include #include #ifndef QT_NO_NETWORKINTERFACE @@ -79,7 +78,7 @@ public: void setBroadcast(const QHostAddress &newBroadcast); private: - QScopedPointer d; + QNetworkAddressEntryPrivate* d; }; class QNetworkInterfacePrivate; diff --git a/src/network/socket/qsocks5socketengine.cpp b/src/network/socket/qsocks5socketengine.cpp index 9bad5b3bf..15bbba3cd 100644 --- a/src/network/socket/qsocks5socketengine.cpp +++ b/src/network/socket/qsocks5socketengine.cpp @@ -58,6 +58,7 @@ #include "qendian.h" #include "qnetworkinterface.h" #include "qnetworkcommon_p.h" +#include "qscopedpointer.h" QT_BEGIN_NAMESPACE diff --git a/src/network/ssl/qsslcipher.cpp b/src/network/ssl/qsslcipher.cpp index 34ada721d..d53a4033d 100644 --- a/src/network/ssl/qsslcipher.cpp +++ b/src/network/ssl/qsslcipher.cpp @@ -103,7 +103,7 @@ QSslCipher::QSslCipher(const QString &name, QSsl::SslProtocol protocol) QSslCipher::QSslCipher(const QSslCipher &other) : d(new QSslCipherPrivate) { - *d.data() = *other.d.data(); + d = other.d; } /*! @@ -111,6 +111,7 @@ QSslCipher::QSslCipher(const QSslCipher &other) */ QSslCipher::~QSslCipher() { + delete d; } /*! @@ -119,7 +120,7 @@ QSslCipher::~QSslCipher() */ QSslCipher &QSslCipher::operator=(const QSslCipher &other) { - *d.data() = *other.d.data(); + d = other.d; return *this; } diff --git a/src/network/ssl/qsslcipher.h b/src/network/ssl/qsslcipher.h index 37e61cbac..c28b75f50 100644 --- a/src/network/ssl/qsslcipher.h +++ b/src/network/ssl/qsslcipher.h @@ -44,7 +44,6 @@ #define QSSLCIPHER_H #include -#include #include QT_BEGIN_HEADER @@ -75,7 +74,7 @@ public: QSsl::SslProtocol protocol() const; private: - QScopedPointer d; + QSslCipherPrivate* d; friend class QSslSocketBackendPrivate; }; diff --git a/src/network/ssl/qsslerror.cpp b/src/network/ssl/qsslerror.cpp index 234916864..6e21cd0c3 100644 --- a/src/network/ssl/qsslerror.cpp +++ b/src/network/ssl/qsslerror.cpp @@ -107,34 +107,8 @@ public: }; /*! - Constructs a QSslError object with no error and default certificate. - -*/ - -// RVCT compiler in debug build does not like about default values in const- -// So as an workaround we define all constructor overloads here explicitly -QSslError::QSslError() - : d(new QSslErrorPrivate) -{ - d->error = QSslError::NoError; - d->certificate = QSslCertificate(); -} - -/*! - Constructs a QSslError object. The argument specifies the \a - error that occurred. - -*/ -QSslError::QSslError(SslError error) - : d(new QSslErrorPrivate) -{ - d->error = error; - d->certificate = QSslCertificate(); -} - -/*! - Constructs a QSslError object. The two arguments specify the \a - error that occurred, and which \a certificate the error relates to. + Constructs a QSslError object. The two arguments specify the + \a error that occurred, and which \a certificate the error relates to. \sa QSslCertificate */ @@ -151,7 +125,7 @@ QSslError::QSslError(SslError error, const QSslCertificate &certificate) QSslError::QSslError(const QSslError &other) : d(new QSslErrorPrivate) { - *d.data() = *other.d.data(); + d = other.d; } /*! @@ -159,6 +133,7 @@ QSslError::QSslError(const QSslError &other) */ QSslError::~QSslError() { + delete d; } /*! @@ -168,7 +143,7 @@ QSslError::~QSslError() */ QSslError &QSslError::operator=(const QSslError &other) { - *d.data() = *other.d.data(); + d = other.d; return *this; } diff --git a/src/network/ssl/qsslerror.h b/src/network/ssl/qsslerror.h index 4b3f7aacf..d92f69829 100644 --- a/src/network/ssl/qsslerror.h +++ b/src/network/ssl/qsslerror.h @@ -83,11 +83,7 @@ public: UnspecifiedError = -1 }; - // RVCT compiler in debug build does not like about default values in const- - // So as an workaround we define all constructor overloads here explicitly - QSslError(); - QSslError(SslError error); - QSslError(SslError error, const QSslCertificate &certificate); + QSslError(SslError error = QSslError::NoError, const QSslCertificate &certificate = QSslCertificate()); QSslError(const QSslError &other); @@ -100,9 +96,9 @@ public: SslError error() const; QString errorString() const; QSslCertificate certificate() const; - + private: - QScopedPointer d; + QSslErrorPrivate* d; }; #ifndef QT_NO_DEBUG_STREAM diff --git a/src/shared/qtgradienteditor/qtgradientstopsmodel.cpp b/src/shared/qtgradienteditor/qtgradientstopsmodel.cpp index 62c913f14..70d588adc 100644 --- a/src/shared/qtgradienteditor/qtgradientstopsmodel.cpp +++ b/src/shared/qtgradienteditor/qtgradientstopsmodel.cpp @@ -87,6 +87,7 @@ QtGradientStop::QtGradientStop(QtGradientStopsModel *model) QtGradientStop::~QtGradientStop() { + delete d_ptr; } class QtGradientStopsModelPrivate @@ -112,6 +113,7 @@ QtGradientStopsModel::QtGradientStopsModel(QObject *parent) QtGradientStopsModel::~QtGradientStopsModel() { clear(); + delete d_ptr; } QtGradientStopsModel::PositionStopMap QtGradientStopsModel::stops() const diff --git a/src/shared/qtgradienteditor/qtgradientstopsmodel.h b/src/shared/qtgradienteditor/qtgradientstopsmodel.h index 5cb33af4e..cfe75cdd7 100644 --- a/src/shared/qtgradienteditor/qtgradientstopsmodel.h +++ b/src/shared/qtgradienteditor/qtgradientstopsmodel.h @@ -50,6 +50,8 @@ QT_BEGIN_NAMESPACE class QColor; class QtGradientStopsModel; +class QtGradientStopPrivate; +class QtGradientStopsModelPrivate; class QtGradientStop { @@ -64,7 +66,7 @@ private: friend class QtGradientStopsModel; QtGradientStop(QtGradientStopsModel *model = 0); ~QtGradientStop(); - QScopedPointer d_ptr; + QtGradientStopPrivate* d_ptr; }; class QtGradientStopsModel : public QObject @@ -111,7 +113,7 @@ signals: void currentStopChanged(QtGradientStop *stop); private: - QScopedPointer d_ptr; + QtGradientStopsModelPrivate* d_ptr; Q_DECLARE_PRIVATE(QtGradientStopsModel) Q_DISABLE_COPY(QtGradientStopsModel) }; diff --git a/src/test/qtestcase.cpp b/src/test/qtestcase.cpp index db779994d..1f014f53a 100644 --- a/src/test/qtestcase.cpp +++ b/src/test/qtestcase.cpp @@ -54,6 +54,7 @@ #include #include #include +#include #include "QtTest/qtestlog_p.h" #include "QtTest/qtesttable_p.h"