Skip to content

Commit

Permalink
Replace qt_make_unique with std::make_unique
Browse files Browse the repository at this point in the history
We can depend on C++14 now.

Change-Id: Iee9796cd22dbfbb70d4bdb25f0eee1662a026d6d
Reviewed-by: Lars Knoll <[email protected]>
  • Loading branch information
Allan Sandfeld Jensen committed Nov 23, 2020
1 parent 03ab486 commit f61f8bb
Show file tree
Hide file tree
Showing 16 changed files with 30 additions and 123 deletions.
1 change: 0 additions & 1 deletion src/corelib/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ qt_internal_add_module(Core
global/qlibraryinfo.cpp global/qlibraryinfo.h
global/qlogging.cpp global/qlogging.h
global/qmalloc.cpp
global/qmemory_p.h
# global/qnamespace.h # special case
global/qnumeric.cpp global/qnumeric.h global/qnumeric_p.h
global/qoperatingsystemversion.cpp global/qoperatingsystemversion.h global/qoperatingsystemversion_p.h
Expand Down
1 change: 0 additions & 1 deletion src/corelib/global/global.pri
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ HEADERS += \
global/qcompilerdetection.h \
global/qcontainerinfo.h \
global/qprocessordetection.h \
global/qmemory_p.h \
global/qnamespace.h \
global/qendian.h \
global/qendian_p.h \
Expand Down
71 changes: 0 additions & 71 deletions src/corelib/global/qmemory_p.h

This file was deleted.

6 changes: 2 additions & 4 deletions src/corelib/io/qfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@
# include "qcoreapplication.h"
#endif

#include <private/qmemory_p.h>

#ifdef QT_NO_QOBJECT
#define tr(X) QString::fromLatin1(X)
#endif
Expand Down Expand Up @@ -87,7 +85,7 @@ QFilePrivate::openExternalFile(int flags, int fd, QFile::FileHandleFlags handleF
Q_UNUSED(fd);
return false;
#else
auto fs = qt_make_unique<QFSFileEngine>();
auto fs = std::make_unique<QFSFileEngine>();
auto fe = fs.get();
fileEngine = std::move(fs);
return fe->open(QIODevice::OpenMode(flags), fd, handleFlags);
Expand All @@ -102,7 +100,7 @@ QFilePrivate::openExternalFile(int flags, FILE *fh, QFile::FileHandleFlags handl
Q_UNUSED(fh);
return false;
#else
auto fs = qt_make_unique<QFSFileEngine>();
auto fs = std::make_unique<QFSFileEngine>();
auto fe = fs.get();
fileEngine = std::move(fs);
return fe->open(QIODevice::OpenMode(flags), fh, handleFlags);
Expand Down
4 changes: 1 addition & 3 deletions src/corelib/io/qfiledevice.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,6 @@
#include "qfiledevice_p.h"
#include "qfsfileengine_p.h"

#include <private/qmemory_p.h>

#ifdef QT_NO_QOBJECT
#define tr(X) QString::fromLatin1(X)
#endif
Expand All @@ -66,7 +64,7 @@ QFileDevicePrivate::~QFileDevicePrivate() = default;
QAbstractFileEngine *QFileDevicePrivate::engine() const
{
if (!fileEngine)
fileEngine = qt_make_unique<QFSFileEngine>();
fileEngine = std::make_unique<QFSFileEngine>();
return fileEngine.get();
}

Expand Down
5 changes: 2 additions & 3 deletions src/corelib/io/qurl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -418,7 +418,6 @@
#include "private/qipaddress_p.h"
#include "qurlquery.h"
#include "private/qdir_p.h"
#include <private/qmemory_p.h>

QT_BEGIN_NAMESPACE

Expand Down Expand Up @@ -617,7 +616,7 @@ inline QUrlPrivate::~QUrlPrivate()

std::unique_ptr<QUrlPrivate::Error> QUrlPrivate::cloneError() const
{
return error ? qt_make_unique<Error>(*error) : nullptr;
return error ? std::make_unique<Error>(*error) : nullptr;
}

inline void QUrlPrivate::clearError()
Expand All @@ -631,7 +630,7 @@ inline void QUrlPrivate::setError(ErrorCode errorCode, const QString &source, in
// don't overwrite an error set in a previous section during parsing
return;
}
error = qt_make_unique<Error>();
error = std::make_unique<Error>();
error->code = errorCode;
error->source = source;
error->position = supplement;
Expand Down
16 changes: 7 additions & 9 deletions src/corelib/serialization/qjsondocument.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@
#include "qjson_p.h"
#include "qdatastream.h"

#include <private/qmemory_p.h>

QT_BEGIN_NAMESPACE

/*! \class QJsonDocument
Expand Down Expand Up @@ -139,7 +137,7 @@ QJsonDocument::QJsonDocument(const QJsonArray &array)
\internal
*/
QJsonDocument::QJsonDocument(const QCborValue &data)
: d(qt_make_unique<QJsonDocumentPrivate>(data))
: d(std::make_unique<QJsonDocumentPrivate>(data))
{
Q_ASSERT(d);
}
Expand All @@ -158,7 +156,7 @@ QJsonDocument::QJsonDocument(const QJsonDocument &other)
{
if (other.d) {
if (!d)
d = qt_make_unique<QJsonDocumentPrivate>();
d = std::make_unique<QJsonDocumentPrivate>();
d->value = other.d->value;
} else {
d.reset();
Expand All @@ -184,7 +182,7 @@ QJsonDocument &QJsonDocument::operator =(const QJsonDocument &other)
if (this != &other) {
if (other.d) {
if (!d)
d = qt_make_unique<QJsonDocumentPrivate>();
d = std::make_unique<QJsonDocumentPrivate>();
else
d->clearRawData();
d->value = other.d->value;
Expand Down Expand Up @@ -239,7 +237,7 @@ QJsonDocument QJsonDocument::fromVariant(const QVariant &variant)
doc.setArray(QJsonArray::fromVariantList(variant.toList()));
break;
case QMetaType::QStringList:
doc.d = qt_make_unique<QJsonDocumentPrivate>();
doc.d = std::make_unique<QJsonDocumentPrivate>();
doc.d->value = QCborArray::fromStringList(variant.toStringList());
break;
default:
Expand Down Expand Up @@ -320,7 +318,7 @@ QJsonDocument QJsonDocument::fromJson(const QByteArray &json, QJsonParseError *e
QJsonDocument result;
const QCborValue val = parser.parse(error);
if (val.isArray() || val.isMap()) {
result.d = qt_make_unique<QJsonDocumentPrivate>();
result.d = std::make_unique<QJsonDocumentPrivate>();
result.d->value = val;
}
return result;
Expand Down Expand Up @@ -405,7 +403,7 @@ QJsonArray QJsonDocument::array() const
void QJsonDocument::setObject(const QJsonObject &object)
{
if (!d)
d = qt_make_unique<QJsonDocumentPrivate>();
d = std::make_unique<QJsonDocumentPrivate>();
else
d->clearRawData();

Expand All @@ -420,7 +418,7 @@ void QJsonDocument::setObject(const QJsonObject &object)
void QJsonDocument::setArray(const QJsonArray &array)
{
if (!d)
d = qt_make_unique<QJsonDocumentPrivate>();
d = std::make_unique<QJsonDocumentPrivate>();
else
d->clearRawData();

Expand Down
3 changes: 1 addition & 2 deletions src/corelib/serialization/qxmlstream.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public: \
{ return QString::fromUtf8(sourceText); } \
private:
#endif
#include <private/qmemory_p.h>

#include <iterator>
#include "qxmlstream_p.h"
Expand Down Expand Up @@ -875,7 +874,7 @@ void QXmlStreamReaderPrivate::parseEntity(const QString &value)


if (!entityParser)
entityParser = qt_make_unique<QXmlStreamReaderPrivate>(q);
entityParser = std::make_unique<QXmlStreamReaderPrivate>(q);
else
entityParser->init();
entityParser->inParseEntity = true;
Expand Down
7 changes: 3 additions & 4 deletions src/network/ssl/qsslsocket_openssl_symbols.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,6 @@
#if defined(Q_OS_UNIX)
#include <QtCore/qdir.h>
#endif
#include <QtCore/private/qmemory_p.h>
#include <QtCore/private/qduplicatetracker_p.h>
#if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID)
#include <link.h>
Expand Down Expand Up @@ -658,12 +657,12 @@ struct LoadedOpenSsl {

static bool tryToLoadOpenSslWin32Library(QLatin1String ssleay32LibName, QLatin1String libeay32LibName, LoadedOpenSsl &result)
{
auto ssleay32 = qt_make_unique<QSystemLibrary>(ssleay32LibName);
auto ssleay32 = std::make_unique<QSystemLibrary>(ssleay32LibName);
if (!ssleay32->load(false)) {
return FALSE;
}

auto libeay32 = qt_make_unique<QSystemLibrary>(libeay32LibName);
auto libeay32 = std::make_unique<QSystemLibrary>(libeay32LibName);
if (!libeay32->load(false)) {
return FALSE;
}
Expand Down Expand Up @@ -700,7 +699,7 @@ struct LoadedOpenSsl {

static LoadedOpenSsl loadOpenSsl()
{
LoadedOpenSsl result = {qt_make_unique<QLibrary>(), qt_make_unique<QLibrary>()};
LoadedOpenSsl result = { std::make_unique<QLibrary>(), std::make_unique<QLibrary>() };

# if defined(Q_OS_UNIX)
QLibrary * const libssl = result.ssl.get();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
#include <QtDeviceDiscoverySupport/private/qdevicediscovery_p.h>
#include <private/qguiapplication_p.h>
#include <private/qinputdevicemanager_p_p.h>
#include <private/qmemory_p.h>

QT_BEGIN_NAMESPACE

Expand Down Expand Up @@ -96,7 +95,7 @@ QEvdevTabletManager::~QEvdevTabletManager()
void QEvdevTabletManager::addDevice(const QString &deviceNode)
{
qCDebug(qLcEvdevTablet, "Adding device at %ls", qUtf16Printable(deviceNode));
auto handler = qt_make_unique<QEvdevTabletHandlerThread>(deviceNode, m_spec);
auto handler = std::make_unique<QEvdevTabletHandlerThread>(deviceNode, m_spec);
if (handler) {
m_activeDevices.add(deviceNode, std::move(handler));
updateDeviceCount();
Expand Down
3 changes: 1 addition & 2 deletions src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
#include <QtDeviceDiscoverySupport/private/qdevicediscovery_p.h>
#include <private/qguiapplication_p.h>
#include <private/qinputdevicemanager_p_p.h>
#include <private/qmemory_p.h>

QT_BEGIN_NAMESPACE

Expand Down Expand Up @@ -96,7 +95,7 @@ QEvdevTouchManager::~QEvdevTouchManager()
void QEvdevTouchManager::addDevice(const QString &deviceNode)
{
qCDebug(qLcEvdevTouch, "evdevtouch: Adding device at %ls", qUtf16Printable(deviceNode));
auto handler = qt_make_unique<QEvdevTouchScreenHandlerThread>(deviceNode, m_spec);
auto handler = std::make_unique<QEvdevTouchScreenHandlerThread>(deviceNode, m_spec);
if (handler) {
connect(handler.get(), &QEvdevTouchScreenHandlerThread::touchDeviceRegistered, this, &QEvdevTouchManager::updateInputDeviceCount);
m_activeDevices.add(deviceNode, std::move(handler));
Expand Down
8 changes: 3 additions & 5 deletions src/widgets/graphicsview/qgraphicswidget_p.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@
#include <QtWidgets/QStyleOptionTitleBar>
#include <QtWidgets/QGraphicsSceneMouseEvent>

#include <private/qmemory_p.h>

QT_BEGIN_NAMESPACE

void QGraphicsWidgetPrivate::init(QGraphicsItem *parentItem, Qt::WindowFlags wFlags)
Expand Down Expand Up @@ -121,7 +119,7 @@ QGraphicsWidgetPrivate::~QGraphicsWidgetPrivate()
void QGraphicsWidgetPrivate::ensureMargins() const
{
if (!margins)
margins = qt_make_unique<QMarginsF>();
margins = std::make_unique<QMarginsF>();
}

/*!
Expand All @@ -133,7 +131,7 @@ void QGraphicsWidgetPrivate::ensureMargins() const
void QGraphicsWidgetPrivate::ensureWindowFrameMargins() const
{
if (!windowFrameMargins)
windowFrameMargins = qt_make_unique<QMarginsF>();
windowFrameMargins = std::make_unique<QMarginsF>();
}

/*!
Expand All @@ -145,7 +143,7 @@ void QGraphicsWidgetPrivate::ensureWindowFrameMargins() const
void QGraphicsWidgetPrivate::ensureWindowData()
{
if (!windowData)
windowData = qt_make_unique<WindowData>();
windowData = std::make_unique<WindowData>();
}

void QGraphicsWidgetPrivate::setPalette_helper(const QPalette &palette)
Expand Down
Loading

0 comments on commit f61f8bb

Please sign in to comment.