Port QtCore from QScoped- to std::unique_ptr [1/2]: private uses
This patch series is in preparation of enabling QT_NO_SCOPED_POINTER when building QtCore, a prerequisite for enabling this opt-out in leaf modules. This first part of the patch series ports objects whose use cannot "leak" into other modules, e.g. because they are in .cpp files or are private members and is thus SC (and, as demonstrated by various static assertions we put into the source code over the years, BC). The second patch will deal with objects in protected and public APIs, and thus might be QUIP-6 SiC Type A. Task-number: QTBUG-132213 Change-Id: If4967f6e563a4e7d74550fad4c6d354fad1beef5 Reviewed-by: Ahmad Samir <a.samirh78@gmail.com> (cherry picked from commit 63f1c6fcbab5f36809ffc96ac5ff6cb9e01e70bb) Reviewed-by: Qt Cherry-pick Bot <cherrypick_bot@qt-project.org>
This commit is contained in:
parent
3ea877a844
commit
5cd16659ff
@ -6,6 +6,8 @@
|
|||||||
|
|
||||||
#include <QtCore/qdir.h>
|
#include <QtCore/qdir.h>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
class QDirIteratorPrivate;
|
class QDirIteratorPrivate;
|
||||||
@ -44,7 +46,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(QDirIterator)
|
Q_DISABLE_COPY(QDirIterator)
|
||||||
|
|
||||||
QScopedPointer<QDirIteratorPrivate> d;
|
std::unique_ptr<QDirIteratorPrivate> d;
|
||||||
friend class QDir;
|
friend class QDir;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
#include "qfilesystemiterator_p.h"
|
#include "qfilesystemiterator_p.h"
|
||||||
#include "qdir.h"
|
#include "qdir.h"
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#ifndef QT_NO_FILESYSTEMITERATOR
|
#ifndef QT_NO_FILESYSTEMITERATOR
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
@ -37,7 +39,7 @@ public:
|
|||||||
QFileInfo currentFileInfo() const override;
|
QFileInfo currentFileInfo() const override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
mutable QScopedPointer<QFileSystemIterator> nativeIterator;
|
mutable std::unique_ptr<QFileSystemIterator> nativeIterator;
|
||||||
};
|
};
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
@ -19,6 +19,8 @@
|
|||||||
#error qiodevice.h must be included before any header file that defines open
|
#error qiodevice.h must be included before any header file that defines open
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
|
|
||||||
@ -137,7 +139,7 @@ protected:
|
|||||||
void setErrorString(const QString &errorString);
|
void setErrorString(const QString &errorString);
|
||||||
|
|
||||||
#ifdef QT_NO_QOBJECT
|
#ifdef QT_NO_QOBJECT
|
||||||
QScopedPointer<QIODevicePrivate> d_ptr;
|
std::unique_ptr<QIODevicePrivate> d_ptr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -31,7 +31,7 @@ class Q_CORE_EXPORT QSettings
|
|||||||
#ifndef QT_NO_QOBJECT
|
#ifndef QT_NO_QOBJECT
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
#else
|
#else
|
||||||
QScopedPointer<QSettingsPrivate> d_ptr;
|
std::unique_ptr<QSettingsPrivate> d_ptr;
|
||||||
#endif
|
#endif
|
||||||
Q_DECLARE_PRIVATE(QSettings)
|
Q_DECLARE_PRIVATE(QSettings)
|
||||||
|
|
||||||
|
@ -9,6 +9,8 @@
|
|||||||
#include <QtCore/qstring.h>
|
#include <QtCore/qstring.h>
|
||||||
#include <QtCore/qscopedpointer.h>
|
#include <QtCore/qscopedpointer.h>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
#if QT_CONFIG(systemsemaphore)
|
#if QT_CONFIG(systemsemaphore)
|
||||||
@ -65,7 +67,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(QSystemSemaphore)
|
Q_DISABLE_COPY(QSystemSemaphore)
|
||||||
QScopedPointer<QSystemSemaphorePrivate> d;
|
std::unique_ptr<QSystemSemaphorePrivate> d;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // QT_CONFIG(systemsemaphore)
|
#endif // QT_CONFIG(systemsemaphore)
|
||||||
|
@ -1914,7 +1914,7 @@ void QCoreApplicationPrivate::sendPostedEvents(QObject *receiver, int event_type
|
|||||||
locker.unlock();
|
locker.unlock();
|
||||||
const auto relocker = qScopeGuard([&locker] { locker.lock(); });
|
const auto relocker = qScopeGuard([&locker] { locker.lock(); });
|
||||||
|
|
||||||
QScopedPointer<QEvent> event_deleter(e); // will delete the event (with the mutex unlocked)
|
const std::unique_ptr<QEvent> event_deleter(e); // will delete the event (with the mutex unlocked)
|
||||||
|
|
||||||
// after all that work, it's time to deliver the event.
|
// after all that work, it's time to deliver the event.
|
||||||
QCoreApplication::sendEvent(r, e);
|
QCoreApplication::sendEvent(r, e);
|
||||||
|
@ -218,7 +218,7 @@ protected:
|
|||||||
QCoreApplication(QCoreApplicationPrivate &p);
|
QCoreApplication(QCoreApplicationPrivate &p);
|
||||||
|
|
||||||
#ifdef QT_NO_QOBJECT
|
#ifdef QT_NO_QOBJECT
|
||||||
QScopedPointer<QCoreApplicationPrivate> d_ptr;
|
std::unique_ptr<QCoreApplicationPrivate> d_ptr;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
@ -92,7 +92,7 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY_MOVE(QJniEnvironment)
|
Q_DISABLE_COPY_MOVE(QJniEnvironment)
|
||||||
QScopedPointer<QJniEnvironmentPrivate> d;
|
std::unique_ptr<QJniEnvironmentPrivate> d;
|
||||||
};
|
};
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
@ -489,7 +489,7 @@ public:
|
|||||||
|
|
||||||
static QAndroidActivityResultReceiverPrivate *get(QAndroidActivityResultReceiver *publicObject)
|
static QAndroidActivityResultReceiverPrivate *get(QAndroidActivityResultReceiver *publicObject)
|
||||||
{
|
{
|
||||||
return publicObject->d.data();
|
return publicObject->d.get();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -513,7 +513,7 @@ QAndroidActivityResultReceiver::QAndroidActivityResultReceiver()
|
|||||||
: d(new QAndroidActivityResultReceiverPrivate)
|
: d(new QAndroidActivityResultReceiverPrivate)
|
||||||
{
|
{
|
||||||
d->q = this;
|
d->q = this;
|
||||||
QtAndroidPrivate::registerActivityResultListener(d.data());
|
QtAndroidPrivate::registerActivityResultListener(d.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
@ -521,7 +521,7 @@ QAndroidActivityResultReceiver::QAndroidActivityResultReceiver()
|
|||||||
*/
|
*/
|
||||||
QAndroidActivityResultReceiver::~QAndroidActivityResultReceiver()
|
QAndroidActivityResultReceiver::~QAndroidActivityResultReceiver()
|
||||||
{
|
{
|
||||||
QtAndroidPrivate::unregisterActivityResultListener(d.data());
|
QtAndroidPrivate::unregisterActivityResultListener(d.get());
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
@ -28,6 +28,8 @@
|
|||||||
#include <QtCore/qfuture.h>
|
#include <QtCore/qfuture.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
class QAndroidParcel;
|
class QAndroidParcel;
|
||||||
@ -103,7 +105,7 @@ private:
|
|||||||
friend class QAndroidActivityResultReceiverPrivate;
|
friend class QAndroidActivityResultReceiverPrivate;
|
||||||
Q_DISABLE_COPY(QAndroidActivityResultReceiver)
|
Q_DISABLE_COPY(QAndroidActivityResultReceiver)
|
||||||
|
|
||||||
QScopedPointer<QAndroidActivityResultReceiverPrivate> d;
|
std::unique_ptr<QAndroidActivityResultReceiverPrivate> d;
|
||||||
};
|
};
|
||||||
|
|
||||||
class Q_CORE_EXPORT QAndroidServiceConnection
|
class Q_CORE_EXPORT QAndroidServiceConnection
|
||||||
@ -170,7 +172,7 @@ private:
|
|||||||
friend class QAndroidServicePrivate;
|
friend class QAndroidServicePrivate;
|
||||||
Q_DISABLE_COPY(QAndroidService)
|
Q_DISABLE_COPY(QAndroidService)
|
||||||
|
|
||||||
QScopedPointer<QAndroidServicePrivate> d;
|
std::unique_ptr<QAndroidServicePrivate> d;
|
||||||
};
|
};
|
||||||
|
|
||||||
class QAndroidActivityCallbackResultReceiver: public QAndroidActivityResultReceiver
|
class QAndroidActivityCallbackResultReceiver: public QAndroidActivityResultReceiver
|
||||||
|
@ -11,6 +11,8 @@
|
|||||||
#include <QtCore/qstring.h>
|
#include <QtCore/qstring.h>
|
||||||
#include <QtCore/qstringview.h>
|
#include <QtCore/qstringview.h>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
QT_REQUIRE_CONFIG(cborstreamreader);
|
QT_REQUIRE_CONFIG(cborstreamreader);
|
||||||
|
|
||||||
/* X11 headers use these values too, but as defines */
|
/* X11 headers use these values too, but as defines */
|
||||||
@ -194,7 +196,7 @@ private:
|
|||||||
friend QCborStreamReaderPrivate;
|
friend QCborStreamReaderPrivate;
|
||||||
friend class QCborContainerPrivate;
|
friend class QCborContainerPrivate;
|
||||||
quint64 value64;
|
quint64 value64;
|
||||||
QScopedPointer<QCborStreamReaderPrivate> d;
|
std::unique_ptr<QCborStreamReaderPrivate> d;
|
||||||
quint8 type_;
|
quint8 type_;
|
||||||
quint8 reserved[3] = {};
|
quint8 reserved[3] = {};
|
||||||
};
|
};
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
#include <QtCore/qfloat16.h>
|
#include <QtCore/qfloat16.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
QT_REQUIRE_CONFIG(cborstreamwriter);
|
QT_REQUIRE_CONFIG(cborstreamwriter);
|
||||||
|
|
||||||
/* X11 headers use these values too, but as defines */
|
/* X11 headers use these values too, but as defines */
|
||||||
@ -81,7 +83,7 @@ public:
|
|||||||
// no API for encoding chunked strings
|
// no API for encoding chunked strings
|
||||||
|
|
||||||
private:
|
private:
|
||||||
QScopedPointer<QCborStreamWriterPrivate> d;
|
std::unique_ptr<QCborStreamWriterPrivate> d;
|
||||||
};
|
};
|
||||||
|
|
||||||
QT_END_NAMESPACE
|
QT_END_NAMESPACE
|
||||||
|
@ -1785,7 +1785,7 @@ static QCborValue taggedValueFromCbor(QCborStreamReader &reader, int remainingRe
|
|||||||
extern void qt_cbor_stream_set_error(QCborStreamReaderPrivate *d, QCborError error);
|
extern void qt_cbor_stream_set_error(QCborStreamReaderPrivate *d, QCborError error);
|
||||||
inline void QCborContainerPrivate::setErrorInReader(QCborStreamReader &reader, QCborError error)
|
inline void QCborContainerPrivate::setErrorInReader(QCborStreamReader &reader, QCborError error)
|
||||||
{
|
{
|
||||||
qt_cbor_stream_set_error(reader.d.data(), error);
|
qt_cbor_stream_set_error(reader.d.get(), error);
|
||||||
}
|
}
|
||||||
|
|
||||||
extern QCborStreamReader::StringResultCode qt_cbor_append_string_chunk(QCborStreamReader &reader, QByteArray *data);
|
extern QCborStreamReader::StringResultCode qt_cbor_append_string_chunk(QCborStreamReader &reader, QByteArray *data);
|
||||||
|
@ -11,6 +11,7 @@
|
|||||||
#include <QtCore/qttypetraits.h>
|
#include <QtCore/qttypetraits.h>
|
||||||
|
|
||||||
#include <iterator> // std::distance(), std::next()
|
#include <iterator> // std::distance(), std::next()
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
#ifdef Status
|
#ifdef Status
|
||||||
#error qdatastream.h must be included before any header file that defines Status
|
#error qdatastream.h must be included before any header file that defines Status
|
||||||
@ -216,7 +217,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(QDataStream)
|
Q_DISABLE_COPY(QDataStream)
|
||||||
|
|
||||||
QScopedPointer<QDataStreamPrivate> d;
|
std::unique_ptr<QDataStreamPrivate> d;
|
||||||
|
|
||||||
QIODevice *dev = nullptr;
|
QIODevice *dev = nullptr;
|
||||||
bool owndev = false;
|
bool owndev = false;
|
||||||
|
@ -13,6 +13,8 @@
|
|||||||
#include <QtCore/qscopedpointer.h>
|
#include <QtCore/qscopedpointer.h>
|
||||||
#include <QtCore/qstring.h>
|
#include <QtCore/qstring.h>
|
||||||
|
|
||||||
|
#include <memory>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
|
|
||||||
namespace QtPrivate {
|
namespace QtPrivate {
|
||||||
@ -361,7 +363,7 @@ private:
|
|||||||
|
|
||||||
Q_DISABLE_COPY(QXmlStreamReader)
|
Q_DISABLE_COPY(QXmlStreamReader)
|
||||||
Q_DECLARE_PRIVATE(QXmlStreamReader)
|
Q_DECLARE_PRIVATE(QXmlStreamReader)
|
||||||
QScopedPointer<QXmlStreamReaderPrivate> d_ptr;
|
std::unique_ptr<QXmlStreamReaderPrivate> d_ptr;
|
||||||
|
|
||||||
};
|
};
|
||||||
#endif // feature xmlstreamreader
|
#endif // feature xmlstreamreader
|
||||||
@ -461,7 +463,7 @@ public:
|
|||||||
private:
|
private:
|
||||||
Q_DISABLE_COPY(QXmlStreamWriter)
|
Q_DISABLE_COPY(QXmlStreamWriter)
|
||||||
Q_DECLARE_PRIVATE(QXmlStreamWriter)
|
Q_DECLARE_PRIVATE(QXmlStreamWriter)
|
||||||
QScopedPointer<QXmlStreamWriterPrivate> d_ptr;
|
std::unique_ptr<QXmlStreamWriterPrivate> d_ptr;
|
||||||
};
|
};
|
||||||
#endif // feature xmlstreamwriter
|
#endif // feature xmlstreamwriter
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user