mostly manual d pointer management

Signed-off-by: Ivailo Monev <xakepa10@laimg.moc>
This commit is contained in:
Ivailo Monev 2016-11-01 17:38:09 +00:00
parent c5b8c07f7e
commit 83625c5cf5
50 changed files with 122 additions and 108 deletions

View file

@ -42,6 +42,7 @@
#include "qthreadpool.h" #include "qthreadpool.h"
#include "qthreadpool_p.h" #include "qthreadpool_p.h"
#include "qelapsedtimer.h" #include "qelapsedtimer.h"
#include "qscopedpointer.h"
#ifndef QT_NO_THREAD #ifndef QT_NO_THREAD

View file

@ -362,6 +362,7 @@ QAbstractFileEngine::QAbstractFileEngine(QAbstractFileEnginePrivate &dd) : d_ptr
*/ */
QAbstractFileEngine::~QAbstractFileEngine() QAbstractFileEngine::~QAbstractFileEngine()
{ {
delete d_ptr;
} }
/*! /*!
@ -889,6 +890,7 @@ QAbstractFileEngineIterator::QAbstractFileEngineIterator(QDir::Filters filters,
*/ */
QAbstractFileEngineIterator::~QAbstractFileEngineIterator() QAbstractFileEngineIterator::~QAbstractFileEngineIterator()
{ {
delete d;
} }
/*! /*!

View file

@ -190,7 +190,7 @@ protected:
QAbstractFileEngine(); QAbstractFileEngine();
QAbstractFileEngine(QAbstractFileEnginePrivate &); QAbstractFileEngine(QAbstractFileEnginePrivate &);
QScopedPointer<QAbstractFileEnginePrivate> d_ptr; QAbstractFileEnginePrivate* d_ptr;
private: private:
Q_DECLARE_PRIVATE(QAbstractFileEngine) Q_DECLARE_PRIVATE(QAbstractFileEngine)
Q_DISABLE_COPY(QAbstractFileEngine) Q_DISABLE_COPY(QAbstractFileEngine)
@ -234,7 +234,7 @@ private:
friend class QDirIterator; friend class QDirIterator;
friend class QDirIteratorPrivate; friend class QDirIteratorPrivate;
void setPath(const QString &path); void setPath(const QString &path);
QScopedPointer<QAbstractFileEngineIteratorPrivate> d; QAbstractFileEngineIteratorPrivate* d;
}; };
QT_END_NAMESPACE QT_END_NAMESPACE

View file

@ -260,6 +260,7 @@ QT_BEGIN_NAMESPACE
QDataStream::QDataStream() QDataStream::QDataStream()
{ {
d = Q_NULLPTR;
dev = 0; dev = 0;
owndev = false; owndev = false;
byteorder = BigEndian; byteorder = BigEndian;
@ -280,9 +281,10 @@ QDataStream::QDataStream()
\sa setDevice(), device() \sa setDevice(), device()
*/ */
QDataStream::QDataStream(QIODevice *d) QDataStream::QDataStream(QIODevice *device)
{ {
dev = d; // set device d = Q_NULLPTR;
dev = device; // set device
owndev = false; owndev = false;
byteorder = BigEndian; // default byte order byteorder = BigEndian; // default byte order
ver = QDataStream::Qt_Default; ver = QDataStream::Qt_Default;
@ -306,6 +308,7 @@ QDataStream::QDataStream(QIODevice *d)
QDataStream::QDataStream(QByteArray *a, QIODevice::OpenMode flags) QDataStream::QDataStream(QByteArray *a, QIODevice::OpenMode flags)
{ {
d = Q_NULLPTR;
QBuffer *buf = new QBuffer(a); QBuffer *buf = new QBuffer(a);
#ifndef QT_NO_QOBJECT #ifndef QT_NO_QOBJECT
buf->blockSignals(true); buf->blockSignals(true);
@ -329,6 +332,7 @@ QDataStream::QDataStream(QByteArray *a, QIODevice::OpenMode flags)
*/ */
QDataStream::QDataStream(const QByteArray &a) QDataStream::QDataStream(const QByteArray &a)
{ {
d = Q_NULLPTR;
QBuffer *buf = new QBuffer; QBuffer *buf = new QBuffer;
#ifndef QT_NO_QOBJECT #ifndef QT_NO_QOBJECT
buf->blockSignals(true); buf->blockSignals(true);
@ -356,6 +360,7 @@ QDataStream::~QDataStream()
{ {
if (owndev) if (owndev)
delete dev; delete dev;
delete d;
} }
@ -433,7 +438,7 @@ QDataStream::FloatingPointPrecision QDataStream::floatingPointPrecision() const
void QDataStream::setFloatingPointPrecision(QDataStream::FloatingPointPrecision precision) void QDataStream::setFloatingPointPrecision(QDataStream::FloatingPointPrecision precision)
{ {
if (d == 0) if (d == 0)
d.reset(new QDataStreamPrivate()); d = new QDataStreamPrivate();
d->floatingPointPrecision = precision; d->floatingPointPrecision = precision;
} }

View file

@ -161,7 +161,7 @@ public:
private: private:
Q_DISABLE_COPY(QDataStream) Q_DISABLE_COPY(QDataStream)
QScopedPointer<QDataStreamPrivate> d; QDataStreamPrivate* d;
QIODevice *dev; QIODevice *dev;
bool owndev; bool owndev;

View file

@ -57,6 +57,7 @@
#include "qfilesystementry_p.h" #include "qfilesystementry_p.h"
#include "qfilesystemmetadata_p.h" #include "qfilesystemmetadata_p.h"
#include "qfilesystemengine_p.h" #include "qfilesystemengine_p.h"
#include "qscopedpointer.h"
#ifdef QT_BUILD_CORE_LIB #ifdef QT_BUILD_CORE_LIB
# include "qresource.h" # include "qresource.h"
@ -82,6 +83,7 @@ QDirPrivate::QDirPrivate(const QString &path, const QStringList &nameFilters_, Q
, nameFilters(nameFilters_) , nameFilters(nameFilters_)
, sort(sort_) , sort(sort_)
, filters(filters_) , filters(filters_)
, fileEngine(Q_NULLPTR)
, fileListsInitialized(false) , fileListsInitialized(false)
{ {
setPath(path.isEmpty() ? QString::fromLatin1(".") : path); setPath(path.isEmpty() ? QString::fromLatin1(".") : path);
@ -105,15 +107,21 @@ QDirPrivate::QDirPrivate(const QDirPrivate &copy)
, nameFilters(copy.nameFilters) , nameFilters(copy.nameFilters)
, sort(copy.sort) , sort(copy.sort)
, filters(copy.filters) , filters(copy.filters)
, fileEngine(0)
, fileListsInitialized(false) , fileListsInitialized(false)
, dirEntry(copy.dirEntry) , dirEntry(copy.dirEntry)
, metaData(copy.metaData) , metaData(copy.metaData)
{ {
} }
QDirPrivate::~QDirPrivate()
{
delete fileEngine;
}
bool QDirPrivate::exists() const bool QDirPrivate::exists() const
{ {
if (fileEngine.isNull()) { if (!fileEngine) {
QFileSystemEngine::fillMetaData(dirEntry, metaData, QFileSystemEngine::fillMetaData(dirEntry, metaData,
QFileSystemMetaData::ExistsAttribute | QFileSystemMetaData::DirectoryType); // always stat QFileSystemMetaData::ExistsAttribute | QFileSystemMetaData::DirectoryType); // always stat
return metaData.exists() && metaData.isDirectory(); return metaData.exists() && metaData.isDirectory();
@ -175,7 +183,7 @@ inline void QDirPrivate::resolveAbsoluteEntry() const
return; return;
QString absoluteName; QString absoluteName;
if (fileEngine.isNull()) { if (!fileEngine) {
if (!dirEntry.isRelative() && dirEntry.isClean()) { if (!dirEntry.isRelative() && dirEntry.isClean()) {
absoluteDirEntry = dirEntry; absoluteDirEntry = dirEntry;
return; return;
@ -315,7 +323,8 @@ inline void QDirPrivate::initFileLists(const QDir &dir) const
inline void QDirPrivate::initFileEngine() 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 QString QDir::canonicalPath() const
{ {
const QDirPrivate* d = d_ptr.constData(); const QDirPrivate* d = d_ptr.constData();
if (d->fileEngine.isNull()) { if (!d->fileEngine) {
QFileSystemEntry answer = QFileSystemEngine::canonicalName(d->dirEntry, d->metaData); QFileSystemEntry answer = QFileSystemEngine::canonicalName(d->dirEntry, d->metaData);
return answer.filePath(); return answer.filePath();
} }
@ -1261,7 +1270,7 @@ bool QDir::mkdir(const QString &dirName) const
const QDirPrivate* d = d_ptr.constData(); const QDirPrivate* d = d_ptr.constData();
QString fn = filePath(dirName); QString fn = filePath(dirName);
if (d->fileEngine.isNull()) if (!d->fileEngine)
return QFileSystemEngine::createDirectory(QFileSystemEntry(fn), false); return QFileSystemEngine::createDirectory(QFileSystemEntry(fn), false);
return d->fileEngine->mkdir(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(); const QDirPrivate* d = d_ptr.constData();
QString fn = filePath(dirName); QString fn = filePath(dirName);
if (d->fileEngine.isNull()) if (!d->fileEngine)
return QFileSystemEngine::removeDirectory(QFileSystemEntry(fn), false); return QFileSystemEngine::removeDirectory(QFileSystemEntry(fn), false);
return d->fileEngine->rmdir(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(); const QDirPrivate* d = d_ptr.constData();
QString fn = filePath(dirPath); QString fn = filePath(dirPath);
if (d->fileEngine.isNull()) if (!d->fileEngine)
return QFileSystemEngine::createDirectory(QFileSystemEntry(fn), true); return QFileSystemEngine::createDirectory(QFileSystemEntry(fn), true);
return d->fileEngine->mkdir(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(); const QDirPrivate* d = d_ptr.constData();
QString fn = filePath(dirPath); QString fn = filePath(dirPath);
if (d->fileEngine.isNull()) if (!d->fileEngine)
return QFileSystemEngine::removeDirectory(QFileSystemEntry(fn), true); return QFileSystemEngine::removeDirectory(QFileSystemEntry(fn), true);
return d->fileEngine->rmdir(fn, true); return d->fileEngine->rmdir(fn, true);
} }
@ -1358,7 +1367,7 @@ bool QDir::isReadable() const
{ {
const QDirPrivate* d = d_ptr.constData(); const QDirPrivate* d = d_ptr.constData();
if (d->fileEngine.isNull()) { if (!d->fileEngine) {
if (!d->metaData.hasFlags(QFileSystemMetaData::UserReadPermission)) if (!d->metaData.hasFlags(QFileSystemMetaData::UserReadPermission))
QFileSystemEngine::fillMetaData(d->dirEntry, d->metaData, QFileSystemMetaData::UserReadPermission); QFileSystemEngine::fillMetaData(d->dirEntry, d->metaData, QFileSystemMetaData::UserReadPermission);
@ -1403,7 +1412,7 @@ bool QDir::exists() const
*/ */
bool QDir::isRoot() const bool QDir::isRoot() const
{ {
if (d_ptr->fileEngine.isNull()) if (!d_ptr->fileEngine)
return d_ptr->dirEntry.isRoot(); return d_ptr->dirEntry.isRoot();
return d_ptr->fileEngine->fileFlags(QAbstractFileEngine::FlagsMask) & QAbstractFileEngine::RootFlag; return d_ptr->fileEngine->fileFlags(QAbstractFileEngine::FlagsMask) & QAbstractFileEngine::RootFlag;
} }
@ -1435,7 +1444,7 @@ bool QDir::isRoot() const
*/ */
bool QDir::isRelative() const bool QDir::isRelative() const
{ {
if (d_ptr->fileEngine.isNull()) if (!d_ptr->fileEngine)
return d_ptr->dirEntry.isRelative(); return d_ptr->dirEntry.isRelative();
return d_ptr->fileEngine->isRelativePath(); return d_ptr->fileEngine->isRelativePath();
} }
@ -1452,7 +1461,7 @@ bool QDir::makeAbsolute()
{ {
const QDirPrivate *d = d_ptr.constData(); const QDirPrivate *d = d_ptr.constData();
QScopedPointer<QDirPrivate> dir; QScopedPointer<QDirPrivate> dir;
if (!d->fileEngine.isNull()) { if (d->fileEngine) {
QString absolutePath = d->fileEngine->fileName(QAbstractFileEngine::AbsoluteName); QString absolutePath = d->fileEngine->fileName(QAbstractFileEngine::AbsoluteName);
if (QDir::isRelativePath(absolutePath)) if (QDir::isRelativePath(absolutePath))
return false; return false;
@ -1485,8 +1494,8 @@ bool QDir::operator==(const QDir &dir) const
if (d == other) if (d == other)
return true; return true;
Qt::CaseSensitivity sensitive; Qt::CaseSensitivity sensitive;
if (d->fileEngine.isNull() || other->fileEngine.isNull()) { if (!d->fileEngine || !other->fileEngine) {
if (d->fileEngine.data() != other->fileEngine.data()) // one is native, the other is a custom file-engine if (d->fileEngine != other->fileEngine) // one is native, the other is a custom file-engine
return false; return false;
sensitive = QFileSystemEngine::isCaseSensitive() ? Qt::CaseSensitive : Qt::CaseInsensitive; sensitive = QFileSystemEngine::isCaseSensitive() ? Qt::CaseSensitive : Qt::CaseInsensitive;

View file

@ -55,6 +55,7 @@ public:
QDir::Filters filters_ = QDir::AllEntries); QDir::Filters filters_ = QDir::AllEntries);
QDirPrivate(const QDirPrivate &copy); QDirPrivate(const QDirPrivate &copy);
~QDirPrivate();
bool exists() const; bool exists() const;
@ -78,7 +79,7 @@ public:
QDir::Filters filters; QDir::Filters filters;
QScopedPointer<QAbstractFileEngine> fileEngine; QAbstractFileEngine* fileEngine;
mutable bool fileListsInitialized; mutable bool fileListsInitialized;
mutable QStringList files; mutable QStringList files;

View file

@ -406,11 +406,12 @@ bool QDirIteratorPrivate::matchesFilters(const QString &fileName, const QFileInf
\sa hasNext(), next(), IteratorFlags \sa hasNext(), next(), IteratorFlags
*/ */
QDirIterator::QDirIterator(const QDir &dir, IteratorFlags flags) 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 // 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(); } }; class MyQDir : public QDir { public: const QDirPrivate *priv() const { return d_ptr.constData(); } };
const QDirPrivate *other = static_cast<const MyQDir*>(&dir)->priv(); const QDirPrivate *other = static_cast<const MyQDir*>(&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() QDirIterator::~QDirIterator()
{ {
delete d;
} }
/*! /*!

View file

@ -83,7 +83,7 @@ public:
private: private:
Q_DISABLE_COPY(QDirIterator) Q_DISABLE_COPY(QDirIterator)
QScopedPointer<QDirIteratorPrivate> d; QDirIteratorPrivate* d;
friend class QDir; friend class QDir;
}; };

View file

@ -111,6 +111,11 @@ public:
metaData = QFileSystemMetaData(); metaData = QFileSystemMetaData();
} }
inline ~QFileInfoPrivate()
{
delete fileEngine;
}
inline void clearFlags() const { inline void clearFlags() const {
fileFlags = 0; fileFlags = 0;
cachedFlags = 0; cachedFlags = 0;
@ -134,7 +139,7 @@ public:
QFileSystemEntry fileEntry; QFileSystemEntry fileEntry;
mutable QFileSystemMetaData metaData; mutable QFileSystemMetaData metaData;
QScopedPointer<QAbstractFileEngine> const fileEngine; QAbstractFileEngine* const fileEngine;
mutable QString fileNames[QAbstractFileEngine::NFileNames]; mutable QString fileNames[QAbstractFileEngine::NFileNames];
mutable QString fileOwners[2]; mutable QString fileOwners[2];

View file

@ -50,19 +50,21 @@ QT_BEGIN_NAMESPACE
QFSFileEngineIterator::QFSFileEngineIterator(QDir::Filters filters, const QStringList &filterNames) QFSFileEngineIterator::QFSFileEngineIterator(QDir::Filters filters, const QStringList &filterNames)
: QAbstractFileEngineIterator(filters, filterNames) : QAbstractFileEngineIterator(filters, filterNames)
, nativeIterator(Q_NULLPTR)
, done(false) , done(false)
{ {
} }
QFSFileEngineIterator::~QFSFileEngineIterator() QFSFileEngineIterator::~QFSFileEngineIterator()
{ {
delete nativeIterator;
} }
bool QFSFileEngineIterator::hasNext() const bool QFSFileEngineIterator::hasNext() const
{ {
if (!done && !nativeIterator) { if (!done && !nativeIterator) {
nativeIterator.reset(new QFileSystemIterator(QFileSystemEntry(path()), nativeIterator = new QFileSystemIterator(QFileSystemEntry(path()),
filters(), nameFilters())); filters(), nameFilters());
advance(); advance();
} }
@ -88,7 +90,8 @@ void QFSFileEngineIterator::advance() const
nextInfo = QFileInfo(new QFileInfoPrivate(entry, data)); nextInfo = QFileInfo(new QFileInfoPrivate(entry, data));
} else { } else {
done = true; done = true;
nativeIterator.reset(); delete nativeIterator;
nativeIterator = Q_NULLPTR;
} }
} }

View file

@ -79,7 +79,7 @@ public:
private: private:
void advance() const; void advance() const;
mutable QScopedPointer<QFileSystemIterator> nativeIterator; mutable QFileSystemIterator* nativeIterator;
mutable QFileInfo currentInfo; mutable QFileInfo currentInfo;
mutable QFileInfo nextInfo; mutable QFileInfo nextInfo;
mutable bool done; mutable bool done;

View file

@ -405,6 +405,9 @@ QIODevice::~QIODevice()
#if defined QIODEVICE_DEBUG #if defined QIODEVICE_DEBUG
printf("%p QIODevice::~QIODevice()\n", this); printf("%p QIODevice::~QIODevice()\n", this);
#endif #endif
#ifdef QT_NO_QOBJECT
delete d_ptr;
#endif
} }
/*! /*!

View file

@ -46,7 +46,6 @@
#include <QtCore/qobject.h> #include <QtCore/qobject.h>
#else #else
#include <QtCore/qobjectdefs.h> #include <QtCore/qobjectdefs.h>
#include <QtCore/qscopedpointer.h>
#endif #endif
#include <QtCore/qstring.h> #include <QtCore/qstring.h>
@ -160,7 +159,7 @@ protected:
void setErrorString(const QString &errorString); void setErrorString(const QString &errorString);
#ifdef QT_NO_QOBJECT #ifdef QT_NO_QOBJECT
QScopedPointer<QIODevicePrivate> d_ptr; QIODevicePrivate* d_ptr;
#endif #endif
private: private:

View file

@ -88,7 +88,7 @@ protected:
QStringList children() const; QStringList children() const;
protected: protected:
QScopedPointer<QResourcePrivate> d_ptr; QResourcePrivate* d_ptr;
private: private:
Q_DECLARE_PRIVATE(QResource) Q_DECLARE_PRIVATE(QResource)

View file

@ -2472,6 +2472,7 @@ QSettings::~QSettings()
; // ok. then don't flush but at least don't throw in the destructor ; // ok. then don't flush but at least don't throw in the destructor
} }
} }
delete d_ptr;
} }
/*! /*!

View file

@ -72,7 +72,7 @@ class Q_CORE_EXPORT QSettings
#ifndef QT_NO_QOBJECT #ifndef QT_NO_QOBJECT
Q_OBJECT Q_OBJECT
#else #else
QScopedPointer<QSettingsPrivate> d_ptr; QSettingsPrivate* d_ptr;
#endif #endif
Q_DECLARE_PRIVATE(QSettings) Q_DECLARE_PRIVATE(QSettings)

View file

@ -1109,6 +1109,7 @@ QTextStream::~QTextStream()
#endif #endif
if (!d->writeBuffer.isEmpty()) if (!d->writeBuffer.isEmpty())
d->flushWriteBuffer(); d->flushWriteBuffer();
delete d_ptr;
} }
/*! /*!

View file

@ -191,7 +191,7 @@ private:
Q_DISABLE_COPY(QTextStream) Q_DISABLE_COPY(QTextStream)
QScopedPointer<QTextStreamPrivate> d_ptr; QTextStreamPrivate* d_ptr;
}; };
Q_DECLARE_OPERATORS_FOR_FLAGS(QTextStream::NumberFlags) Q_DECLARE_OPERATORS_FOR_FLAGS(QTextStream::NumberFlags)

View file

@ -65,6 +65,7 @@
#include <qfunctions_p.h> #include <qfunctions_p.h>
#include <qlocale_p.h> #include <qlocale_p.h>
#include <qmutexpool_p.h> #include <qmutexpool_p.h>
#include <qscopedpointer.h>
#if !defined(QT_NO_GLIB) #if !defined(QT_NO_GLIB)
# include "qeventdispatcher_glib_p.h" # include "qeventdispatcher_glib_p.h"

View file

@ -560,7 +560,7 @@ QObject::QObject(QObject *parent)
: d_ptr(new QObjectPrivate) : d_ptr(new QObjectPrivate)
{ {
Q_D(QObject); 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 = (parent && !parent->thread()) ? parent->d_func()->threadData : QThreadData::current();
d->threadData->ref(); d->threadData->ref();
if (parent) { if (parent) {
@ -583,7 +583,7 @@ QObject::QObject(QObjectPrivate &dd, QObject *parent)
: d_ptr(&dd) : d_ptr(&dd)
{ {
Q_D(QObject); 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 = (parent && !parent->thread()) ? parent->d_func()->threadData : QThreadData::current();
d->threadData->ref(); d->threadData->ref();
if (parent) { if (parent) {
@ -744,6 +744,8 @@ QObject::~QObject()
if (d->parent) // remove it from parent object if (d->parent) // remove it from parent object
d->setParent_helper(0); d->setParent_helper(0);
delete d_ptr;
} }
QObjectPrivate::Connection::~Connection() QObjectPrivate::Connection::~Connection()

View file

@ -47,9 +47,9 @@
#include <QtCore/qobjectdefs.h> #include <QtCore/qobjectdefs.h>
#include <QtCore/qstring.h> #include <QtCore/qstring.h>
#include <QtCore/qlist.h> #include <QtCore/qlist.h>
#include <QtCore/qscopedpointer.h>
#ifdef QT_INCLUDE_COMPAT #ifdef QT_INCLUDE_COMPAT
#include <QtCore/qscopedpointer.h>
#include <QtCore/qcoreevent.h> #include <QtCore/qcoreevent.h>
#endif #endif
@ -233,12 +233,9 @@ protected:
virtual void connectNotify(const char *signal); virtual void connectNotify(const char *signal);
virtual void disconnectNotify(const char *signal); virtual void disconnectNotify(const char *signal);
protected:
QObject(QObjectPrivate &dd, QObject *parent = 0); QObject(QObjectPrivate &dd, QObject *parent = 0);
protected: QObjectData* d_ptr;
QScopedPointer<QObjectData> d_ptr;
static const QMetaObject staticQtMetaObject; static const QMetaObject staticQtMetaObject;

View file

@ -181,6 +181,7 @@ QSystemSemaphore::QSystemSemaphore(const QString &key, int initialValue, AccessM
QSystemSemaphore::~QSystemSemaphore() QSystemSemaphore::~QSystemSemaphore()
{ {
d->cleanHandle(); d->cleanHandle();
delete d;
} }
/*! /*!

View file

@ -43,7 +43,6 @@
#define QSYSTEMSEMAPHORE_H #define QSYSTEMSEMAPHORE_H
#include <QtCore/qstring.h> #include <QtCore/qstring.h>
#include <QtCore/qscopedpointer.h>
QT_BEGIN_HEADER QT_BEGIN_HEADER
@ -89,7 +88,7 @@ public:
private: private:
Q_DISABLE_COPY(QSystemSemaphore) Q_DISABLE_COPY(QSystemSemaphore)
QScopedPointer<QSystemSemaphorePrivate> d; QSystemSemaphorePrivate* d;
}; };
#endif // QT_NO_SYSTEMSEMAPHORE #endif // QT_NO_SYSTEMSEMAPHORE

View file

@ -45,10 +45,11 @@
#include "qmutexpool_p.h" #include "qmutexpool_p.h"
#include "qreadwritelock.h" #include "qreadwritelock.h"
#include "qabstracteventdispatcher.h" #include "qabstracteventdispatcher.h"
#include <qeventloop.h> #include "qeventloop.h"
#include <qhash.h> #include "qhash.h"
#include "qthread_p.h" #include "qthread_p.h"
#include "qcoreapplication_p.h" #include "qcoreapplication_p.h"
#include "qscopedpointer.h"
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE

View file

@ -53,6 +53,7 @@
#include "qstringmatcher.h" #include "qstringmatcher.h"
#include "qvector.h" #include "qvector.h"
#include "qfunctions_p.h" #include "qfunctions_p.h"
#include "qscopedpointer.h"
#include <limits.h> #include <limits.h>

View file

@ -426,6 +426,7 @@ QXmlStreamReader::~QXmlStreamReader()
Q_D(QXmlStreamReader); Q_D(QXmlStreamReader);
if (d->deleteDevice) if (d->deleteDevice)
delete d->device; delete d->device;
delete d_ptr;
} }
/*! \fn bool QXmlStreamReader::hasError() const /*! \fn bool QXmlStreamReader::hasError() const
@ -3225,6 +3226,7 @@ QXmlStreamWriter::QXmlStreamWriter(QString *string)
*/ */
QXmlStreamWriter::~QXmlStreamWriter() QXmlStreamWriter::~QXmlStreamWriter()
{ {
delete d_ptr;
} }

View file

@ -339,7 +339,7 @@ public:
private: private:
Q_DISABLE_COPY(QXmlStreamReader) Q_DISABLE_COPY(QXmlStreamReader)
Q_DECLARE_PRIVATE(QXmlStreamReader) Q_DECLARE_PRIVATE(QXmlStreamReader)
QScopedPointer<QXmlStreamReaderPrivate> d_ptr; QXmlStreamReaderPrivate* d_ptr;
}; };
#endif // QT_NO_XMLSTREAMREADER #endif // QT_NO_XMLSTREAMREADER
@ -414,7 +414,7 @@ public:
private: private:
Q_DISABLE_COPY(QXmlStreamWriter) Q_DISABLE_COPY(QXmlStreamWriter)
Q_DECLARE_PRIVATE(QXmlStreamWriter) Q_DECLARE_PRIVATE(QXmlStreamWriter)
QScopedPointer<QXmlStreamWriterPrivate> d_ptr; QXmlStreamWriterPrivate* d_ptr;
}; };
#endif // QT_NO_XMLSTREAMWRITER #endif // QT_NO_XMLSTREAMWRITER

View file

@ -277,7 +277,7 @@ void QDBusAdaptorConnector::polish()
void QDBusAdaptorConnector::relaySlot(void **argv) void QDBusAdaptorConnector::relaySlot(void **argv)
{ {
QObjectPrivate *d = static_cast<QObjectPrivate *>(d_ptr.data()); QObjectPrivate *d = static_cast<QObjectPrivate *>(d_ptr);
if (Q_LIKELY(d->currentSender)) { if (Q_LIKELY(d->currentSender)) {
relay(d->currentSender->sender, d->currentSender->signal, argv); relay(d->currentSender->sender, d->currentSender->signal, argv);
} else { } else {

View file

@ -1488,7 +1488,7 @@ QGraphicsItem::~QGraphicsItem()
if (d_ptr->transformData) { if (d_ptr->transformData) {
for(int i = 0; i < d_ptr->transformData->graphicsTransforms.size(); ++i) { for(int i = 0; i < d_ptr->transformData->graphicsTransforms.size(); ++i) {
QGraphicsTransform *t = d_ptr->transformData->graphicsTransforms.at(i); QGraphicsTransform *t = d_ptr->transformData->graphicsTransforms.at(i);
static_cast<QGraphicsTransformPrivate *>(t->d_ptr.data())->item = 0; static_cast<QGraphicsTransformPrivate *>(t->d_ptr)->item = 0;
delete t; delete t;
} }
} }

View file

@ -332,7 +332,7 @@ public:
*/ */
inline bool isPersistent(const QModelIndex &index) const inline bool isPersistent(const QModelIndex &index) const
{ {
return static_cast<QAbstractItemModelPrivate *>(model->d_ptr.data())->persistent.indexes.contains(index); return static_cast<QAbstractItemModelPrivate *>(model->d_ptr)->persistent.indexes.contains(index);
} }
QModelIndexList selectedDraggableIndexes() const; QModelIndexList selectedDraggableIndexes() const;

View file

@ -857,7 +857,7 @@ void QTreeModel::sortItems(QList<QTreeWidgetItem*> *items, int column, Qt::SortO
items->replace(r, item); items->replace(r, item);
for (int c = 0; c < colCount; ++c) { for (int c = 0; c < colCount; ++c) {
QModelIndex from = createIndex(oldRow, c, item); QModelIndex from = createIndex(oldRow, c, item);
if (static_cast<QAbstractItemModelPrivate *>(d_ptr.data())->persistent.indexes.contains(from)) { if (static_cast<QAbstractItemModelPrivate *>(d_ptr)->persistent.indexes.contains(from)) {
QModelIndex to = createIndex(r, c, item); QModelIndex to = createIndex(r, c, item);
fromList << from; fromList << from;
toList << to; toList << to;

View file

@ -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 //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<QAbstractScrollArea *>(parent); QAbstractScrollArea *scrollArea = qobject_cast<QAbstractScrollArea *>(parent);
if (scrollArea && scrollArea->viewport() == q) { if (scrollArea && scrollArea->viewport() == q) {
QObjectData *scrollPrivate = static_cast<QWidget *>(scrollArea)->d_ptr.data(); QObjectData *scrollPrivate = static_cast<QWidget *>(scrollArea)->d_ptr;
QAbstractScrollAreaPrivate *priv = static_cast<QAbstractScrollAreaPrivate *>(scrollPrivate); QAbstractScrollAreaPrivate *priv = static_cast<QAbstractScrollAreaPrivate *>(scrollPrivate);
oldBrushOrigin = painter->brushOrigin(); oldBrushOrigin = painter->brushOrigin();
resetBrushOrigin = true; resetBrushOrigin = true;

View file

@ -50,6 +50,7 @@
#include <qendian.h> #include <qendian.h>
#include <qdebug.h> #include <qdebug.h>
#include <qdir.h> #include <qdir.h>
#include <qscopedpointer.h>
#if 0 #if 0
#define ZDEBUG qDebug #define ZDEBUG qDebug

View file

@ -619,6 +619,7 @@ QHttpHeader::QHttpHeader(QHttpHeaderPrivate &dd, const QHttpHeader &header)
*/ */
QHttpHeader::~QHttpHeader() QHttpHeader::~QHttpHeader()
{ {
delete d_ptr;
} }
/*! /*!

View file

@ -46,7 +46,6 @@
#include <QtCore/qstringlist.h> #include <QtCore/qstringlist.h>
#include <QtCore/qmap.h> #include <QtCore/qmap.h>
#include <QtCore/qpair.h> #include <QtCore/qpair.h>
#include <QtCore/qscopedpointer.h>
QT_BEGIN_HEADER QT_BEGIN_HEADER
@ -108,7 +107,7 @@ protected:
QHttpHeader(QHttpHeaderPrivate &dd, const QString &str = QString()); QHttpHeader(QHttpHeaderPrivate &dd, const QString &str = QString());
QHttpHeader(QHttpHeaderPrivate &dd, const QHttpHeader &header); QHttpHeader(QHttpHeaderPrivate &dd, const QHttpHeader &header);
QScopedPointer<QHttpHeaderPrivate> d_ptr; QHttpHeaderPrivate* d_ptr;
private: private:
Q_DECLARE_PRIVATE(QHttpHeader) Q_DECLARE_PRIVATE(QHttpHeader)

View file

@ -486,7 +486,7 @@ QHostAddress::QHostAddress(const struct sockaddr *sockaddr)
Constructs a copy of the given \a address. Constructs a copy of the given \a address.
*/ */
QHostAddress::QHostAddress(const QHostAddress &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() QHostAddress::~QHostAddress()
{ {
delete d;
} }
/*! /*!
@ -530,7 +531,7 @@ QHostAddress::~QHostAddress()
*/ */
QHostAddress &QHostAddress::operator=(const QHostAddress &address) QHostAddress &QHostAddress::operator=(const QHostAddress &address)
{ {
*d.data() = *address.d.data(); d = address.d;
return *this; return *this;
} }

View file

@ -44,7 +44,6 @@
#include <QtCore/qpair.h> #include <QtCore/qpair.h>
#include <QtCore/qstring.h> #include <QtCore/qstring.h>
#include <QtCore/qscopedpointer.h>
#include <QtNetwork/qabstractsocket.h> #include <QtNetwork/qabstractsocket.h>
struct sockaddr; struct sockaddr;
@ -122,7 +121,7 @@ public:
static QPair<QHostAddress, int> parseSubnet(const QString &subnet); static QPair<QHostAddress, int> parseSubnet(const QString &subnet);
protected: protected:
QScopedPointer<QHostAddressPrivate> d; QHostAddressPrivate* d;
}; };
inline bool operator ==(QHostAddress::SpecialAddress address1, const QHostAddress &address2) inline bool operator ==(QHostAddress::SpecialAddress address1, const QHostAddress &address2)

View file

@ -293,7 +293,7 @@ QHostInfo::QHostInfo(int id)
Constructs a copy of \a other. Constructs a copy of \a other.
*/ */
QHostInfo::QHostInfo(const QHostInfo &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) QHostInfo &QHostInfo::operator=(const QHostInfo &other)
{ {
*d.data() = *other.d.data(); d = other.d;
return *this; return *this;
} }
@ -312,6 +312,7 @@ QHostInfo &QHostInfo::operator=(const QHostInfo &other)
*/ */
QHostInfo::~QHostInfo() QHostInfo::~QHostInfo()
{ {
delete d;
} }
/*! /*!

View file

@ -43,7 +43,6 @@
#define QHOSTINFO_H #define QHOSTINFO_H
#include <QtCore/qlist.h> #include <QtCore/qlist.h>
#include <QtCore/qscopedpointer.h>
#include <QtNetwork/qhostaddress.h> #include <QtNetwork/qhostaddress.h>
QT_BEGIN_HEADER QT_BEGIN_HEADER
@ -91,7 +90,7 @@ public:
static QString localDomainName(); static QString localDomainName();
private: private:
QScopedPointer<QHostInfoPrivate> d; QHostInfoPrivate* d;
}; };
QT_END_NAMESPACE QT_END_NAMESPACE

View file

@ -165,7 +165,7 @@ QNetworkAddressEntry::QNetworkAddressEntry()
object \a other. object \a other.
*/ */
QNetworkAddressEntry::QNetworkAddressEntry(const QNetworkAddressEntry &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) QNetworkAddressEntry &QNetworkAddressEntry::operator=(const QNetworkAddressEntry &other)
{ {
*d.data() = *other.d.data(); d = other.d;
return *this; return *this;
} }
@ -183,6 +183,7 @@ QNetworkAddressEntry &QNetworkAddressEntry::operator=(const QNetworkAddressEntry
*/ */
QNetworkAddressEntry::~QNetworkAddressEntry() QNetworkAddressEntry::~QNetworkAddressEntry()
{ {
delete d;
} }
/*! /*!

View file

@ -43,7 +43,6 @@
#define QNETWORKINTERFACE_H #define QNETWORKINTERFACE_H
#include <QtCore/qshareddata.h> #include <QtCore/qshareddata.h>
#include <QtCore/qscopedpointer.h>
#include <QtNetwork/qhostaddress.h> #include <QtNetwork/qhostaddress.h>
#ifndef QT_NO_NETWORKINTERFACE #ifndef QT_NO_NETWORKINTERFACE
@ -79,7 +78,7 @@ public:
void setBroadcast(const QHostAddress &newBroadcast); void setBroadcast(const QHostAddress &newBroadcast);
private: private:
QScopedPointer<QNetworkAddressEntryPrivate> d; QNetworkAddressEntryPrivate* d;
}; };
class QNetworkInterfacePrivate; class QNetworkInterfacePrivate;

View file

@ -58,6 +58,7 @@
#include "qendian.h" #include "qendian.h"
#include "qnetworkinterface.h" #include "qnetworkinterface.h"
#include "qnetworkcommon_p.h" #include "qnetworkcommon_p.h"
#include "qscopedpointer.h"
QT_BEGIN_NAMESPACE QT_BEGIN_NAMESPACE

View file

@ -103,7 +103,7 @@ QSslCipher::QSslCipher(const QString &name, QSsl::SslProtocol protocol)
QSslCipher::QSslCipher(const QSslCipher &other) QSslCipher::QSslCipher(const QSslCipher &other)
: d(new QSslCipherPrivate) : d(new QSslCipherPrivate)
{ {
*d.data() = *other.d.data(); d = other.d;
} }
/*! /*!
@ -111,6 +111,7 @@ QSslCipher::QSslCipher(const QSslCipher &other)
*/ */
QSslCipher::~QSslCipher() QSslCipher::~QSslCipher()
{ {
delete d;
} }
/*! /*!
@ -119,7 +120,7 @@ QSslCipher::~QSslCipher()
*/ */
QSslCipher &QSslCipher::operator=(const QSslCipher &other) QSslCipher &QSslCipher::operator=(const QSslCipher &other)
{ {
*d.data() = *other.d.data(); d = other.d;
return *this; return *this;
} }

View file

@ -44,7 +44,6 @@
#define QSSLCIPHER_H #define QSSLCIPHER_H
#include <QtCore/qstring.h> #include <QtCore/qstring.h>
#include <QtCore/qscopedpointer.h>
#include <QtNetwork/qssl.h> #include <QtNetwork/qssl.h>
QT_BEGIN_HEADER QT_BEGIN_HEADER
@ -75,7 +74,7 @@ public:
QSsl::SslProtocol protocol() const; QSsl::SslProtocol protocol() const;
private: private:
QScopedPointer<QSslCipherPrivate> d; QSslCipherPrivate* d;
friend class QSslSocketBackendPrivate; friend class QSslSocketBackendPrivate;
}; };

View file

@ -107,34 +107,8 @@ public:
}; };
/*! /*!
Constructs a QSslError object with no error and default certificate. Constructs a QSslError object. The two arguments specify the
\a error that occurred, and which \a certificate the error relates to.
*/
// 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.
\sa QSslCertificate \sa QSslCertificate
*/ */
@ -151,7 +125,7 @@ QSslError::QSslError(SslError error, const QSslCertificate &certificate)
QSslError::QSslError(const QSslError &other) QSslError::QSslError(const QSslError &other)
: d(new QSslErrorPrivate) : d(new QSslErrorPrivate)
{ {
*d.data() = *other.d.data(); d = other.d;
} }
/*! /*!
@ -159,6 +133,7 @@ QSslError::QSslError(const QSslError &other)
*/ */
QSslError::~QSslError() QSslError::~QSslError()
{ {
delete d;
} }
/*! /*!
@ -168,7 +143,7 @@ QSslError::~QSslError()
*/ */
QSslError &QSslError::operator=(const QSslError &other) QSslError &QSslError::operator=(const QSslError &other)
{ {
*d.data() = *other.d.data(); d = other.d;
return *this; return *this;
} }

View file

@ -83,11 +83,7 @@ public:
UnspecifiedError = -1 UnspecifiedError = -1
}; };
// RVCT compiler in debug build does not like about default values in const- QSslError(SslError error = QSslError::NoError, const QSslCertificate &certificate = QSslCertificate());
// So as an workaround we define all constructor overloads here explicitly
QSslError();
QSslError(SslError error);
QSslError(SslError error, const QSslCertificate &certificate);
QSslError(const QSslError &other); QSslError(const QSslError &other);
@ -102,7 +98,7 @@ public:
QSslCertificate certificate() const; QSslCertificate certificate() const;
private: private:
QScopedPointer<QSslErrorPrivate> d; QSslErrorPrivate* d;
}; };
#ifndef QT_NO_DEBUG_STREAM #ifndef QT_NO_DEBUG_STREAM

View file

@ -87,6 +87,7 @@ QtGradientStop::QtGradientStop(QtGradientStopsModel *model)
QtGradientStop::~QtGradientStop() QtGradientStop::~QtGradientStop()
{ {
delete d_ptr;
} }
class QtGradientStopsModelPrivate class QtGradientStopsModelPrivate
@ -112,6 +113,7 @@ QtGradientStopsModel::QtGradientStopsModel(QObject *parent)
QtGradientStopsModel::~QtGradientStopsModel() QtGradientStopsModel::~QtGradientStopsModel()
{ {
clear(); clear();
delete d_ptr;
} }
QtGradientStopsModel::PositionStopMap QtGradientStopsModel::stops() const QtGradientStopsModel::PositionStopMap QtGradientStopsModel::stops() const

View file

@ -50,6 +50,8 @@ QT_BEGIN_NAMESPACE
class QColor; class QColor;
class QtGradientStopsModel; class QtGradientStopsModel;
class QtGradientStopPrivate;
class QtGradientStopsModelPrivate;
class QtGradientStop class QtGradientStop
{ {
@ -64,7 +66,7 @@ private:
friend class QtGradientStopsModel; friend class QtGradientStopsModel;
QtGradientStop(QtGradientStopsModel *model = 0); QtGradientStop(QtGradientStopsModel *model = 0);
~QtGradientStop(); ~QtGradientStop();
QScopedPointer<class QtGradientStopPrivate> d_ptr; QtGradientStopPrivate* d_ptr;
}; };
class QtGradientStopsModel : public QObject class QtGradientStopsModel : public QObject
@ -111,7 +113,7 @@ signals:
void currentStopChanged(QtGradientStop *stop); void currentStopChanged(QtGradientStop *stop);
private: private:
QScopedPointer<class QtGradientStopsModelPrivate> d_ptr; QtGradientStopsModelPrivate* d_ptr;
Q_DECLARE_PRIVATE(QtGradientStopsModel) Q_DECLARE_PRIVATE(QtGradientStopsModel)
Q_DISABLE_COPY(QtGradientStopsModel) Q_DISABLE_COPY(QtGradientStopsModel)
}; };

View file

@ -54,6 +54,7 @@
#include <QtCore/qdir.h> #include <QtCore/qdir.h>
#include <QtCore/qprocess.h> #include <QtCore/qprocess.h>
#include <QtCore/qdebug.h> #include <QtCore/qdebug.h>
#include <QtCore/qscopedpointer.h>
#include "QtTest/qtestlog_p.h" #include "QtTest/qtestlog_p.h"
#include "QtTest/qtesttable_p.h" #include "QtTest/qtesttable_p.h"