diff --git a/src/corelib/CMakeLists.txt b/src/corelib/CMakeLists.txt index 11b3c220c86..18345a2fdea 100644 --- a/src/corelib/CMakeLists.txt +++ b/src/corelib/CMakeLists.txt @@ -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 diff --git a/src/corelib/global/global.pri b/src/corelib/global/global.pri index 4e9a0a0c8bd..5850792bdb3 100644 --- a/src/corelib/global/global.pri +++ b/src/corelib/global/global.pri @@ -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 \ diff --git a/src/corelib/global/qmemory_p.h b/src/corelib/global/qmemory_p.h deleted file mode 100644 index ac791385bdf..00000000000 --- a/src/corelib/global/qmemory_p.h +++ /dev/null @@ -1,71 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2019 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com, author Marc Mutz -** Contact: http://www.qt.io/licensing/ -** -** This file is part of the QtCore module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and The Qt Company. For licensing terms -** and conditions see https://www.qt.io/terms-conditions. For further -** information use the contact form at https://www.qt.io/contact-us. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 3 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL3 included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 3 requirements -** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. -** -** GNU General Public License Usage -** Alternatively, this file may be used under the terms of the GNU -** General Public License version 2.0 or (at your option) the GNU General -** Public license version 3 or any later version approved by the KDE Free -** Qt Foundation. The licenses are as published by the Free Software -** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 -** included in the packaging of this file. Please review the following -** information to ensure the GNU General Public License requirements will -** be met: https://www.gnu.org/licenses/gpl-2.0.html and -** https://www.gnu.org/licenses/gpl-3.0.html. -** -** $QT_END_LICENSE$ -** -****************************************************************************/ -#ifndef QMEMORY_P_H -#define QMEMORY_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -// Like std::make_unique, but less ambitious, so keep as private API, for use in Qt itself: -template -typename std::enable_if::value, std::unique_ptr>::type -qt_make_unique(Args &&...args) -{ - return std::unique_ptr{new T(std::forward(args)...)}; -} - -QT_END_NAMESPACE - -#endif /* QMEMORY_P_H */ diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp index 36e2b4476a6..223745b73c3 100644 --- a/src/corelib/io/qfile.cpp +++ b/src/corelib/io/qfile.cpp @@ -55,8 +55,6 @@ # include "qcoreapplication.h" #endif -#include - #ifdef QT_NO_QOBJECT #define tr(X) QString::fromLatin1(X) #endif @@ -87,7 +85,7 @@ QFilePrivate::openExternalFile(int flags, int fd, QFile::FileHandleFlags handleF Q_UNUSED(fd); return false; #else - auto fs = qt_make_unique(); + auto fs = std::make_unique(); auto fe = fs.get(); fileEngine = std::move(fs); return fe->open(QIODevice::OpenMode(flags), fd, handleFlags); @@ -102,7 +100,7 @@ QFilePrivate::openExternalFile(int flags, FILE *fh, QFile::FileHandleFlags handl Q_UNUSED(fh); return false; #else - auto fs = qt_make_unique(); + auto fs = std::make_unique(); auto fe = fs.get(); fileEngine = std::move(fs); return fe->open(QIODevice::OpenMode(flags), fh, handleFlags); diff --git a/src/corelib/io/qfiledevice.cpp b/src/corelib/io/qfiledevice.cpp index f9160715048..58c78108c81 100644 --- a/src/corelib/io/qfiledevice.cpp +++ b/src/corelib/io/qfiledevice.cpp @@ -42,8 +42,6 @@ #include "qfiledevice_p.h" #include "qfsfileengine_p.h" -#include - #ifdef QT_NO_QOBJECT #define tr(X) QString::fromLatin1(X) #endif @@ -66,7 +64,7 @@ QFileDevicePrivate::~QFileDevicePrivate() = default; QAbstractFileEngine *QFileDevicePrivate::engine() const { if (!fileEngine) - fileEngine = qt_make_unique(); + fileEngine = std::make_unique(); return fileEngine.get(); } diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp index 2b5839923a4..b019fe65a99 100644 --- a/src/corelib/io/qurl.cpp +++ b/src/corelib/io/qurl.cpp @@ -418,7 +418,6 @@ #include "private/qipaddress_p.h" #include "qurlquery.h" #include "private/qdir_p.h" -#include QT_BEGIN_NAMESPACE @@ -617,7 +616,7 @@ inline QUrlPrivate::~QUrlPrivate() std::unique_ptr QUrlPrivate::cloneError() const { - return error ? qt_make_unique(*error) : nullptr; + return error ? std::make_unique(*error) : nullptr; } inline void QUrlPrivate::clearError() @@ -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 = std::make_unique(); error->code = errorCode; error->source = source; error->position = supplement; diff --git a/src/corelib/serialization/qjsondocument.cpp b/src/corelib/serialization/qjsondocument.cpp index 6ef657d50d0..6b015d759dc 100644 --- a/src/corelib/serialization/qjsondocument.cpp +++ b/src/corelib/serialization/qjsondocument.cpp @@ -52,8 +52,6 @@ #include "qjson_p.h" #include "qdatastream.h" -#include - QT_BEGIN_NAMESPACE /*! \class QJsonDocument @@ -139,7 +137,7 @@ QJsonDocument::QJsonDocument(const QJsonArray &array) \internal */ QJsonDocument::QJsonDocument(const QCborValue &data) - : d(qt_make_unique(data)) + : d(std::make_unique(data)) { Q_ASSERT(d); } @@ -158,7 +156,7 @@ QJsonDocument::QJsonDocument(const QJsonDocument &other) { if (other.d) { if (!d) - d = qt_make_unique(); + d = std::make_unique(); d->value = other.d->value; } else { d.reset(); @@ -184,7 +182,7 @@ QJsonDocument &QJsonDocument::operator =(const QJsonDocument &other) if (this != &other) { if (other.d) { if (!d) - d = qt_make_unique(); + d = std::make_unique(); else d->clearRawData(); d->value = other.d->value; @@ -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(); + doc.d = std::make_unique(); doc.d->value = QCborArray::fromStringList(variant.toStringList()); break; default: @@ -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(); + result.d = std::make_unique(); result.d->value = val; } return result; @@ -405,7 +403,7 @@ QJsonArray QJsonDocument::array() const void QJsonDocument::setObject(const QJsonObject &object) { if (!d) - d = qt_make_unique(); + d = std::make_unique(); else d->clearRawData(); @@ -420,7 +418,7 @@ void QJsonDocument::setObject(const QJsonObject &object) void QJsonDocument::setArray(const QJsonArray &array) { if (!d) - d = qt_make_unique(); + d = std::make_unique(); else d->clearRawData(); diff --git a/src/corelib/serialization/qxmlstream.cpp b/src/corelib/serialization/qxmlstream.cpp index e56877082b6..769b33931eb 100644 --- a/src/corelib/serialization/qxmlstream.cpp +++ b/src/corelib/serialization/qxmlstream.cpp @@ -63,7 +63,6 @@ public: \ { return QString::fromUtf8(sourceText); } \ private: #endif -#include #include #include "qxmlstream_p.h" @@ -875,7 +874,7 @@ void QXmlStreamReaderPrivate::parseEntity(const QString &value) if (!entityParser) - entityParser = qt_make_unique(q); + entityParser = std::make_unique(q); else entityParser->init(); entityParser->inParseEntity = true; diff --git a/src/network/ssl/qsslsocket_openssl_symbols.cpp b/src/network/ssl/qsslsocket_openssl_symbols.cpp index 9396516670e..b9b23a5a0c1 100644 --- a/src/network/ssl/qsslsocket_openssl_symbols.cpp +++ b/src/network/ssl/qsslsocket_openssl_symbols.cpp @@ -67,7 +67,6 @@ #if defined(Q_OS_UNIX) #include #endif -#include #include #if defined(Q_OS_LINUX) && !defined(Q_OS_ANDROID) #include @@ -658,12 +657,12 @@ struct LoadedOpenSsl { static bool tryToLoadOpenSslWin32Library(QLatin1String ssleay32LibName, QLatin1String libeay32LibName, LoadedOpenSsl &result) { - auto ssleay32 = qt_make_unique(ssleay32LibName); + auto ssleay32 = std::make_unique(ssleay32LibName); if (!ssleay32->load(false)) { return FALSE; } - auto libeay32 = qt_make_unique(libeay32LibName); + auto libeay32 = std::make_unique(libeay32LibName); if (!libeay32->load(false)) { return FALSE; } @@ -700,7 +699,7 @@ struct LoadedOpenSsl { static LoadedOpenSsl loadOpenSsl() { - LoadedOpenSsl result = {qt_make_unique(), qt_make_unique()}; + LoadedOpenSsl result = { std::make_unique(), std::make_unique() }; # if defined(Q_OS_UNIX) QLibrary * const libssl = result.ssl.get(); diff --git a/src/platformsupport/input/evdevtablet/qevdevtabletmanager.cpp b/src/platformsupport/input/evdevtablet/qevdevtabletmanager.cpp index d9888c5b970..d0da367d2d1 100644 --- a/src/platformsupport/input/evdevtablet/qevdevtabletmanager.cpp +++ b/src/platformsupport/input/evdevtablet/qevdevtabletmanager.cpp @@ -48,7 +48,6 @@ #include #include #include -#include QT_BEGIN_NAMESPACE @@ -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(deviceNode, m_spec); + auto handler = std::make_unique(deviceNode, m_spec); if (handler) { m_activeDevices.add(deviceNode, std::move(handler)); updateDeviceCount(); diff --git a/src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp b/src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp index a1226ac66a4..b3e90cdca8c 100644 --- a/src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp +++ b/src/platformsupport/input/evdevtouch/qevdevtouchmanager.cpp @@ -48,7 +48,6 @@ #include #include #include -#include QT_BEGIN_NAMESPACE @@ -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(deviceNode, m_spec); + auto handler = std::make_unique(deviceNode, m_spec); if (handler) { connect(handler.get(), &QEvdevTouchScreenHandlerThread::touchDeviceRegistered, this, &QEvdevTouchManager::updateInputDeviceCount); m_activeDevices.add(deviceNode, std::move(handler)); diff --git a/src/widgets/graphicsview/qgraphicswidget_p.cpp b/src/widgets/graphicsview/qgraphicswidget_p.cpp index c1a24932fed..0580c6d9382 100644 --- a/src/widgets/graphicsview/qgraphicswidget_p.cpp +++ b/src/widgets/graphicsview/qgraphicswidget_p.cpp @@ -51,8 +51,6 @@ #include #include -#include - QT_BEGIN_NAMESPACE void QGraphicsWidgetPrivate::init(QGraphicsItem *parentItem, Qt::WindowFlags wFlags) @@ -121,7 +119,7 @@ QGraphicsWidgetPrivate::~QGraphicsWidgetPrivate() void QGraphicsWidgetPrivate::ensureMargins() const { if (!margins) - margins = qt_make_unique(); + margins = std::make_unique(); } /*! @@ -133,7 +131,7 @@ void QGraphicsWidgetPrivate::ensureMargins() const void QGraphicsWidgetPrivate::ensureWindowFrameMargins() const { if (!windowFrameMargins) - windowFrameMargins = qt_make_unique(); + windowFrameMargins = std::make_unique(); } /*! @@ -145,7 +143,7 @@ void QGraphicsWidgetPrivate::ensureWindowFrameMargins() const void QGraphicsWidgetPrivate::ensureWindowData() { if (!windowData) - windowData = qt_make_unique(); + windowData = std::make_unique(); } void QGraphicsWidgetPrivate::setPalette_helper(const QPalette &palette) diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 43c13aa4aac..27d301f3c61 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -113,8 +113,6 @@ #include "qwindowcontainer_p.h" -#include - // widget/widget data creation count //#define QWIDGET_EXTRA_DEBUG //#define ALIEN_DEBUG @@ -1570,7 +1568,7 @@ void QWidgetPrivate::createTLExtra() if (!extra) createExtra(); if (!extra->topextra) { - extra->topextra = qt_make_unique(); + extra->topextra = std::make_unique(); QTLWExtra* x = extra->topextra.get(); x->backingStore = nullptr; x->sharedPainter = nullptr; @@ -1601,7 +1599,7 @@ void QWidgetPrivate::createTLExtra() void QWidgetPrivate::createExtra() { if (!extra) { // if not exists - extra = qt_make_unique(); + extra = std::make_unique(); extra->glContext = nullptr; #if QT_CONFIG(graphicsview) extra->proxyWidget = nullptr; @@ -4807,7 +4805,7 @@ void QWidget::setCursor(const QCursor &cursor) || (d->extra && d->extra->curs)) { d->createExtra(); - d->extra->curs = qt_make_unique(cursor); + d->extra->curs = std::make_unique(cursor); } setAttribute(Qt::WA_SetCursor); d->setCursor_sys(cursor); @@ -6028,7 +6026,7 @@ void QWidget::setWindowIcon(const QIcon &icon) d->createTLExtra(); if (!d->extra->topextra->icon) - d->extra->topextra->icon = qt_make_unique(icon); + d->extra->topextra->icon = std::make_unique(icon); else *d->extra->topextra->icon = icon; @@ -11970,7 +11968,7 @@ QOpenGLContext *QWidgetPrivate::shareContext() const return nullptr; if (!extra->topextra->shareContext) { - auto ctx = qt_make_unique(); + auto ctx = std::make_unique(); ctx->setShareContext(qt_gl_global_share_context()); ctx->setFormat(extra->topextra->window->format()); ctx->setScreen(extra->topextra->window->screen()); diff --git a/src/widgets/kernel/qwidgetrepaintmanager.cpp b/src/widgets/kernel/qwidgetrepaintmanager.cpp index 595f8578477..1997f76b1d7 100644 --- a/src/widgets/kernel/qwidgetrepaintmanager.cpp +++ b/src/widgets/kernel/qwidgetrepaintmanager.cpp @@ -63,8 +63,6 @@ #include -#include - QT_BEGIN_NAMESPACE #ifndef QT_NO_OPENGL @@ -653,7 +651,7 @@ static void findAllTextureWidgetsRecursively(QWidget *tlw, QWidget *widget) // textureChildSeen does not take native child widgets into account and that's good. if (QWidgetPrivate::get(widget)->textureChildSeen) { QList nativeChildren; - auto tl = qt_make_unique(); + auto tl = std::make_unique(); // Look for texture widgets (incl. widget itself) from 'widget' down, // but skip subtrees with a parent of a native child widget. findTextureWidgetsRecursively(tlw, widget, tl.get(), &nativeChildren); diff --git a/src/widgets/widgets/qtoolbox.cpp b/src/widgets/widgets/qtoolbox.cpp index cbb25ec1596..787554551da 100644 --- a/src/widgets/widgets/qtoolbox.cpp +++ b/src/widgets/widgets/qtoolbox.cpp @@ -52,8 +52,6 @@ #endif #include -#include - #include "qframe_p.h" QT_BEGIN_NAMESPACE @@ -349,7 +347,7 @@ int QToolBox::insertItem(int index, QWidget *widget, const QIcon &icon, const QS Q_D(QToolBox); connect(widget, SIGNAL(destroyed(QObject*)), this, SLOT(_q_widgetDestroyed(QObject*))); - auto newPage = qt_make_unique(); + auto newPage = std::make_unique(); auto &c = *newPage; c.widget = widget; c.button = new QToolBoxButton(this); diff --git a/tests/benchmarks/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp b/tests/benchmarks/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp index b0b19471e1b..12059b375f3 100644 --- a/tests/benchmarks/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp +++ b/tests/benchmarks/corelib/thread/qreadwritelock/tst_qreadwritelock.cpp @@ -28,7 +28,6 @@ #include #include -#include #include #if __has_include() #if __cplusplus > 201103L @@ -154,7 +153,7 @@ void testReadOnly() Mutex lock; std::vector> threads; for (int i = 0; i < threadCount; ++i) { - auto t = qt_make_unique(); + auto t = std::make_unique(); t->lock = &lock; threads.push_back(std::move(t)); } @@ -215,7 +214,7 @@ void testWriteOnly() Mutex lock; std::vector> threads; for (int i = 0; i < threadCount; ++i) { - auto t = qt_make_unique(); + auto t = std::make_unique(); t->lock = &lock; threads.push_back(std::move(t)); }