From 034d8898f8166423db085da529787e56204c8e15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Fri, 4 Mar 2022 12:28:49 +0100 Subject: Fix deprecated uses of QScopedPointer By changing it to unique_ptr. Pick-to: 6.2 6.3 Change-Id: I91abb69445b537d4c95983ae735341882352b29d Reviewed-by: Marc Mutz Reviewed-by: Thiago Macieira --- src/corelib/kernel/qcoreapplication.cpp | 23 ++++++++++++----------- src/corelib/kernel/qmetaobject.cpp | 5 +++-- src/corelib/kernel/qobject.cpp | 5 +++-- 3 files changed, 18 insertions(+), 15 deletions(-) (limited to 'src/corelib/kernel') diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 25fdc5b546..af0be3ff75 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -134,6 +134,7 @@ #endif #include +#include QT_BEGIN_NAMESPACE @@ -391,8 +392,8 @@ struct QCoreApplicationData { bool applicationVersionSet; // true if setApplicationVersion was called #if QT_CONFIG(library) - QScopedPointer app_libpaths; - QScopedPointer manual_libpaths; + std::unique_ptr app_libpaths; + std::unique_ptr manual_libpaths; #endif }; @@ -568,7 +569,7 @@ void QCoreApplicationPrivate::checkReceiverThread(QObject *receiver) void QCoreApplicationPrivate::appendApplicationPathToLibraryPaths() { #if QT_CONFIG(library) - QStringList *app_libpaths = coreappdata()->app_libpaths.data(); + QStringList *app_libpaths = coreappdata()->app_libpaths.get(); if (!app_libpaths) coreappdata()->app_libpaths.reset(app_libpaths = new QStringList); QString app_location = QCoreApplication::applicationFilePath(); @@ -815,8 +816,8 @@ void QCoreApplicationPrivate::init() // Reset the lib paths, so that they will be recomputed, taking the availability of argv[0] // into account. If necessary, recompute right away and replay the manual changes on top of the // new lib paths. - QStringList *appPaths = coreappdata()->app_libpaths.take(); - QStringList *manualPaths = coreappdata()->manual_libpaths.take(); + QStringList *appPaths = coreappdata()->app_libpaths.release(); + QStringList *manualPaths = coreappdata()->manual_libpaths.release(); if (appPaths) { if (manualPaths) { // Replay the delta. As paths can only be prepended to the front or removed from @@ -1612,10 +1613,10 @@ void QCoreApplication::postEvent(QObject *receiver, QEvent *event, int priority) // delete the event on exceptions to protect against memory leaks till the event is // properly owned in the postEventList - QScopedPointer eventDeleter(event); + std::unique_ptr eventDeleter(event); Q_TRACE(QCoreApplication_postEvent_event_posted, receiver, event, event->type()); data->postEventList.addEvent(QPostEvent(receiver, event, priority)); - eventDeleter.take(); + Q_UNUSED(eventDeleter.release()); event->m_posted = true; ++receiver->d_func()->postedEvents; data->canWait = false; @@ -2868,14 +2869,14 @@ void QCoreApplication::addLibraryPath(const QString &path) QMutexLocker locker(libraryPathMutex()); - QStringList *libpaths = coreappdata()->manual_libpaths.data(); + QStringList *libpaths = coreappdata()->manual_libpaths.get(); if (libpaths) { if (libpaths->contains(canonicalPath)) return; } else { // make sure that library paths are initialized libraryPathsLocked(); - QStringList *app_libpaths = coreappdata()->app_libpaths.data(); + QStringList *app_libpaths = coreappdata()->app_libpaths.get(); if (app_libpaths->contains(canonicalPath)) return; @@ -2907,14 +2908,14 @@ void QCoreApplication::removeLibraryPath(const QString &path) QMutexLocker locker(libraryPathMutex()); - QStringList *libpaths = coreappdata()->manual_libpaths.data(); + QStringList *libpaths = coreappdata()->manual_libpaths.get(); if (libpaths) { if (libpaths->removeAll(canonicalPath) == 0) return; } else { // make sure that library paths is initialized libraryPathsLocked(); - QStringList *app_libpaths = coreappdata()->app_libpaths.data(); + QStringList *app_libpaths = coreappdata()->app_libpaths.get(); if (!app_libpaths->contains(canonicalPath)) return; diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index f2aafba008..0c9f54c791 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -62,6 +62,7 @@ #include "private/qmetaobject_moc_p.h" #include +#include QT_BEGIN_NAMESPACE @@ -2399,7 +2400,7 @@ bool QMetaMethod::invoke(QObject *object, return false; } - QScopedPointer event(new QMetaCallEvent(idx_offset, idx_relative, callFunction, nullptr, -1, paramCount)); + auto event = std::make_unique(idx_offset, idx_relative, callFunction, nullptr, -1, paramCount); QMetaType *types = event->types(); void **args = event->args(); @@ -2423,7 +2424,7 @@ bool QMetaMethod::invoke(QObject *object, } } - QCoreApplication::postEvent(object, event.take()); + QCoreApplication::postEvent(object, event.release()); } else { // blocking queued connection #if QT_CONFIG(thread) if (receiverInSameThread) { diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 8f528177d9..13708be391 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -71,6 +71,7 @@ #include #include +#include #include #include @@ -125,7 +126,7 @@ static int *queuedConnectionTypes(const QMetaMethod &method) static int *queuedConnectionTypes(const QArgumentType *argumentTypes, int argc) { - QScopedArrayPointer types(new int[argc + 1]); + auto types = std::make_unique(argc + 1); for (int i = 0; i < argc; ++i) { const QArgumentType &type = argumentTypes[i]; if (type.type()) @@ -145,7 +146,7 @@ static int *queuedConnectionTypes(const QArgumentType *argumentTypes, int argc) } types[argc] = 0; - return types.take(); + return types.release(); } static QBasicMutex _q_ObjectMutexPool[131]; -- cgit v1.2.3