diff options
author | Robert Griebl <robert.griebl@qt.io> | 2022-06-10 19:12:08 +0200 |
---|---|---|
committer | Robert Griebl <robert.griebl@qt.io> | 2022-11-25 13:10:46 +0000 |
commit | ddf24a08e6af6d58eb4beb0800642e92bcba7e51 (patch) | |
tree | f1f4ec970f045d8b0f25484aa4e273156f24b567 | |
parent | f06c526b802d2ad1c18fb5467a614327a5f51ca2 (diff) | |
download | qtapplicationmanager-ddf24a08e6af6d58eb4beb0800642e92bcba7e51.tar.gz |
Fix QScopedPointer::take deprecation warning
Also replaced the remaining usages of QScopedPointer with
std::unique_ptr for consistency.
Change-Id: Ic63d1b3ea03a4562e4e40c3e9c7992459fde716e
Reviewed-by: Dominik Holland <dominik.holland@qt.io>
(cherry picked from commit c81cd64bf589adef4213a3bf25872efa1528e0f9)
Reviewed-by: Bernd Weimer <bernd.weimer@qt.io>
30 files changed, 91 insertions, 80 deletions
diff --git a/src/application-lib/packagedatabase.cpp b/src/application-lib/packagedatabase.cpp index e0fff284..bbb8ba08 100644 --- a/src/application-lib/packagedatabase.cpp +++ b/src/application-lib/packagedatabase.cpp @@ -4,7 +4,6 @@ #include <QDir> #include <QFile> -#include <QScopedPointer> #include <QDataStream> #include "packagedatabase.h" diff --git a/src/application-lib/packageinfo.cpp b/src/application-lib/packageinfo.cpp index 7a113ddc..648d2179 100644 --- a/src/application-lib/packageinfo.cpp +++ b/src/application-lib/packageinfo.cpp @@ -111,7 +111,7 @@ QVector<IntentInfo *> PackageInfo::intents() const const InstallationReport *PackageInfo::installationReport() const { - return m_installationReport.data(); + return m_installationReport.get(); } void PackageInfo::setInstallationReport(InstallationReport *report) diff --git a/src/application-lib/packageinfo.h b/src/application-lib/packageinfo.h index 4b6dd7d8..761f3ba8 100644 --- a/src/application-lib/packageinfo.h +++ b/src/application-lib/packageinfo.h @@ -11,6 +11,8 @@ #include <QVariantMap> #include <QVector> +#include <memory> + #include <QtAppManCommon/global.h> QT_FORWARD_DECLARE_CLASS(QDataStream) @@ -79,7 +81,7 @@ private: QVector<IntentInfo *> m_intents; // added by installer - QScopedPointer<InstallationReport> m_installationReport; + std::unique_ptr<InstallationReport> m_installationReport; QDir m_baseDir; friend class YamlPackageScanner; diff --git a/src/application-lib/yamlpackagescanner.cpp b/src/application-lib/yamlpackagescanner.cpp index fb055603..a34bfb80 100644 --- a/src/application-lib/yamlpackagescanner.cpp +++ b/src/application-lib/yamlpackagescanner.cpp @@ -9,7 +9,6 @@ #include <QJsonArray> #include <QFile> #include <QFileInfo> -#include <QScopedPointer> #include "global.h" #include "qtyaml.h" diff --git a/src/common-lib/exception.h b/src/common-lib/exception.h index ed825c1b..ecb9b7a1 100644 --- a/src/common-lib/exception.h +++ b/src/common-lib/exception.h @@ -8,7 +8,6 @@ #include <QString> #include <QDir> #include <QByteArray> -#include <QScopedPointer> #include <QException> #include <exception> diff --git a/src/crypto-lib/signature_openssl.cpp b/src/crypto-lib/signature_openssl.cpp index 5718887e..3ffd5010 100644 --- a/src/crypto-lib/signature_openssl.cpp +++ b/src/crypto-lib/signature_openssl.cpp @@ -3,6 +3,8 @@ // Copyright (C) 2018 Pelagicore AG // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only +#include <QScopedPointer> + #include "exception.h" #include "cryptography.h" #include "libcryptofunction.h" @@ -100,7 +102,7 @@ QByteArray SignaturePrivate::create(const QByteArray &signingCertificatePkcs12, throw OpenSslException("Could not create BIO buffer for PKCS#12 data"); //PKCS12 *d2i_PKCS12_bio(BIO *bp, PKCS12 **p12); - OpenSslPointer<PKCS12> pkcs12(am_d2i_PKCS12_bio(bioPkcs12.data(), nullptr)); + OpenSslPointer<PKCS12> pkcs12(am_d2i_PKCS12_bio(bioPkcs12.get(), nullptr)); if (!pkcs12) throw OpenSslException("Could not read PKCS#12 data from BIO buffer"); @@ -108,7 +110,7 @@ QByteArray SignaturePrivate::create(const QByteArray &signingCertificatePkcs12, EVP_PKEY *tempSignKey = nullptr; X509 *tempSignCert = nullptr; STACK_OF_X509 *tempCaCerts = nullptr; - int parseOk = am_PKCS12_parse(pkcs12.data(), signingCertificatePassword.constData(), &tempSignKey, &tempSignCert, &tempCaCerts); + int parseOk = am_PKCS12_parse(pkcs12.get(), signingCertificatePassword.constData(), &tempSignKey, &tempSignCert, &tempCaCerts); OpenSslPointer<EVP_PKEY> signKey(tempSignKey); OpenSslPointer<X509> signCert(tempSignCert); OpenSslPointer<STACK_OF_X509> caCerts(tempCaCerts); @@ -126,8 +128,8 @@ QByteArray SignaturePrivate::create(const QByteArray &signingCertificatePkcs12, throw OpenSslException("Could not create a BIO buffer for the hash"); //PKCS7 *PKCS7_sign(X509 *signcert, EVP_PKEY *pkey, STACK_OF(X509) *certs, BIO *data, int flags); - OpenSslPointer<PKCS7> signature(am_PKCS7_sign(signCert.data(), signKey.data(), caCerts.data(), - bioHash.data(), 0x40 /*PKCS7_DETACHED*/)); + OpenSslPointer<PKCS7> signature(am_PKCS7_sign(signCert.get(), signKey.get(), caCerts.get(), + bioHash.get(), 0x40 /*PKCS7_DETACHED*/)); if (!signature) throw OpenSslException("Could not create the PKCS#7 signature"); @@ -136,13 +138,13 @@ QByteArray SignaturePrivate::create(const QByteArray &signingCertificatePkcs12, throw OpenSslException("Could not create a BIO buffer for the PKCS#7 signature"); // int PEM_write_bio_PKCS7(BIO *bp, PKCS7 *x); - //if (!am_PEM_ASN1_write_bio((i2d_of_void *) am_i2d_PKCS7.functionPointer(), PEM_STRING_PKCS7, bioSignature.data(), signature.data(), nullptr, nullptr, 0, nullptr, nullptr)) - if (!am_i2d_PKCS7_bio(bioSignature.data(), signature.data())) + //if (!am_PEM_ASN1_write_bio((i2d_of_void *) am_i2d_PKCS7.functionPointer(), PEM_STRING_PKCS7, bioSignature.get(), signature.get(), nullptr, nullptr, 0, nullptr, nullptr)) + if (!am_i2d_PKCS7_bio(bioSignature.get(), signature.get())) throw OpenSslException("Could not write the PKCS#7 signature to the BIO buffer"); char *data = nullptr; - // long size = BIO_get_mem_data(bioSignature.data(), &data); - int size = static_cast<int>(am_BIO_ctrl(bioSignature.data(), 3 /*BIO_CTRL_INFO*/, 0, reinterpret_cast<char *>(&data))); + // long size = BIO_get_mem_data(bioSignature.get(), &data); + int size = static_cast<int>(am_BIO_ctrl(bioSignature.get(), 3 /*BIO_CTRL_INFO*/, 0, reinterpret_cast<char *>(&data))); if (size <= 0 || !data) throw OpenSslException("The BIO buffer for the PKCS#7 signature is invalid"); @@ -157,8 +159,8 @@ bool SignaturePrivate::verify(const QByteArray &signaturePkcs7, throw OpenSslException("Could not create BIO buffer for PKCS#7 data"); // PKCS7 *PEM_read_bio_PKCS7(BIO *bp, PKCS7 **x, pem_password_cb *cb, void *u); - //OpenSslPointer<PKCS7> signature((PKCS7 *) am_PEM_ASN1_read_bio((d2i_of_void *) am_d2i_PKCS7.functionPointer(), PEM_STRING_PKCS7, bioSignature.data(), nullptr, nullptr, nullptr)); - OpenSslPointer<PKCS7> signature(am_d2i_PKCS7_bio(bioSignature.data(), nullptr)); + //OpenSslPointer<PKCS7> signature((PKCS7 *) am_PEM_ASN1_read_bio((d2i_of_void *) am_d2i_PKCS7.functionPointer(), PEM_STRING_PKCS7, bioSignature.get(), nullptr, nullptr, nullptr)); + OpenSslPointer<PKCS7> signature(am_d2i_PKCS7_bio(bioSignature.get(), nullptr)); if (!signature) throw OpenSslException("Could not read PKCS#7 data from BIO buffer"); @@ -176,21 +178,21 @@ bool SignaturePrivate::verify(const QByteArray &signaturePkcs7, throw OpenSslException("Could not create BIO buffer for a certificate"); // BIO_eof(b) == (int)BIO_ctrl(b,BIO_CTRL_EOF,0,NULL) - while (!am_BIO_ctrl(bioCert.data(), 2 /*BIO_CTRL_EOF*/, 0, nullptr)) { - //OpenSslPointer<X509> cert(PEM_read_bio_X509(bioCert.data(), 0, 0, 0)); + while (!am_BIO_ctrl(bioCert.get(), 2 /*BIO_CTRL_EOF*/, 0, nullptr)) { + //OpenSslPointer<X509> cert(PEM_read_bio_X509(bioCert.get(), 0, 0, 0)); OpenSslPointer<X509> cert(static_cast<X509 *>(am_PEM_ASN1_read_bio(reinterpret_cast<d2i_of_void *>((Cryptography::LibCryptoFunctionBase::isOpenSSL11() ? am_d2i_X509_AUX : am_d2i_X509).functionPointer()), - "CERTIFICATE" /*PEM_STRING_X509*/, bioCert.data(), + "CERTIFICATE" /*PEM_STRING_X509*/, bioCert.get(), nullptr, nullptr, nullptr))); if (!cert) throw OpenSslException("Could not load a certificate from the chain of trust"); - if (!am_X509_STORE_add_cert(certChain.data(), cert.data())) + if (!am_X509_STORE_add_cert(certChain.get(), cert.get())) throw OpenSslException("Could not add a certificate from the chain of trust to the certificate store"); // X509 certs are ref-counted, so we need to "free" the one we got via PEM_read_bio } } // int PKCS7_verify(PKCS7 *p7, STACK_OF(X509) *certs, X509_STORE *store, BIO *indata, BIO *out, int flags); - if (am_PKCS7_verify(signature.data(), nullptr, certChain.data(), bioHash.data(), nullptr, 0x8 /*PKCS7_NOCHAIN*/) != 1) { + if (am_PKCS7_verify(signature.get(), nullptr, certChain.get(), bioHash.get(), nullptr, 0x8 /*PKCS7_NOCHAIN*/) != 1) { bool failed = (am_ERR_get_error() != 0); if (failed) throw OpenSslException("Failed to verify signature"); diff --git a/src/intent-client-lib/intentclient.cpp b/src/intent-client-lib/intentclient.cpp index 28af2a62..17f2ac25 100644 --- a/src/intent-client-lib/intentclient.cpp +++ b/src/intent-client-lib/intentclient.cpp @@ -3,7 +3,6 @@ // Copyright (C) 2018 Pelagicore AG // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only -#include <QScopedPointer> #include <QQmlEngine> #include <QQmlInfo> diff --git a/src/launcher-lib/launchermain.h b/src/launcher-lib/launchermain.h index a06a904a..3afa9cc1 100644 --- a/src/launcher-lib/launchermain.h +++ b/src/launcher-lib/launchermain.h @@ -8,6 +8,8 @@ #include <QtAppManCommon/global.h> #include <QtAppManSharedMain/sharedmain.h> +#include <memory> + QT_FORWARD_DECLARE_CLASS(QWindow) QT_BEGIN_NAMESPACE_AM @@ -76,7 +78,7 @@ private: QVariant m_useAMConsoleLogger; QString m_dltLongMessageBehavior; #if defined(QT_WAYLANDCLIENT_LIB) - QScopedPointer<WaylandQtAMClientExtension> m_waylandExtension; + std::unique_ptr<WaylandQtAMClientExtension> m_waylandExtension; #endif }; diff --git a/src/main-lib/configuration.cpp b/src/main-lib/configuration.cpp index 385abc07..e1cce45f 100644 --- a/src/main-lib/configuration.cpp +++ b/src/main-lib/configuration.cpp @@ -313,7 +313,7 @@ void Configuration::parseWithArguments(const QStringList &arguments) try { cache.parse(); m_data.reset(cache.takeMergedResult()); - if (m_data.isNull()) + if (!m_data) m_data.reset(new ConfigurationData()); } catch (const Exception &e) { showParserMessage(e.errorString() + qL1C('\n'), ErrorMessage); @@ -330,7 +330,7 @@ void Configuration::parseWithArguments(const QStringList &arguments) try { ConfigurationData *cd = ConfigCacheAdaptor<ConfigurationData>::loadFromSource(&buffer, qSL("command line")); if (cd) { - ConfigCacheAdaptor<ConfigurationData>::merge(m_data.data(), cd); + ConfigCacheAdaptor<ConfigurationData>::merge(m_data.get(), cd); delete cd; } } catch (const Exception &e) { diff --git a/src/main-lib/configuration.h b/src/main-lib/configuration.h index 1acd9b6c..e597fe09 100644 --- a/src/main-lib/configuration.h +++ b/src/main-lib/configuration.h @@ -11,6 +11,8 @@ #include <QVector> #include <QCommandLineParser> +#include <memory> + QT_BEGIN_NAMESPACE_AM struct ConfigurationData; @@ -122,7 +124,7 @@ private: QStringList m_defaultConfigFilePaths; QString m_buildConfigFilePath; QCommandLineParser m_clp; - QScopedPointer<ConfigurationData> m_data; + std::unique_ptr<ConfigurationData> m_data; QString m_mainQmlFile; bool m_onlyOnePositionalArgument = false; bool m_forceVerbose = false; diff --git a/src/main-lib/main.cpp b/src/main-lib/main.cpp index 80b96751..14b287f4 100644 --- a/src/main-lib/main.cpp +++ b/src/main-lib/main.cpp @@ -654,7 +654,7 @@ void Main::setupWindowManager(const QString &waylandSocketName, const QVariantLi sudo->removeRecursive(path); } - QScopedPointer<QLocalServer> extraSocket(new QLocalServer); + std::unique_ptr<QLocalServer> extraSocket(new QLocalServer); extraSocket->setMaxPendingConnections(0); // disable Qt's new connection handling if (!extraSocket->listen(path)) { throw Exception("could not listen on extra Wayland socket %1: %2") @@ -688,13 +688,13 @@ void Main::setupWindowManager(const QString &waylandSocketName, const QVariantLi } // if we changed the owner, ~QLocalServer might not be able to clean up the // socket inode, so we need to sudo this removal as well - QObject::connect(extraSocket.data(), &QObject::destroyed, [path, sudo]() { + QObject::connect(extraSocket.get(), &QObject::destroyed, [path, sudo]() { sudo->removeRecursive(path); }); } } - m_windowManager->addWaylandSocket(extraSocket.take()); + m_windowManager->addWaylandSocket(extraSocket.release()); } catch (const std::exception &e) { qCCritical(LogSystem) << "ERROR:" << e.what(); } diff --git a/src/manager-lib/application.h b/src/manager-lib/application.h index aba684e2..ed7dfa41 100644 --- a/src/manager-lib/application.h +++ b/src/manager-lib/application.h @@ -6,7 +6,6 @@ #pragma once #include <QObject> -#include <QScopedPointer> #include <QVariantMap> #include <QUrl> #include <QtAppManApplication/applicationinfo.h> diff --git a/src/manager-lib/containerfactory.cpp b/src/manager-lib/containerfactory.cpp index 9494118d..dfae28ab 100644 --- a/src/manager-lib/containerfactory.cpp +++ b/src/manager-lib/containerfactory.cpp @@ -3,7 +3,6 @@ // Copyright (C) 2018 Pelagicore AG // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only -#include <QScopedPointer> #include <QCoreApplication> #include <QThreadPool> diff --git a/src/manager-lib/installationtask.h b/src/manager-lib/installationtask.h index 3d93e688..ffce832c 100644 --- a/src/manager-lib/installationtask.h +++ b/src/manager-lib/installationtask.h @@ -58,7 +58,7 @@ private: bool m_managerApproval = false; std::unique_ptr<PackageInfo> m_package; uint m_applicationUid = uint(-1); - QScopedPointer<Package> m_tempPackageForAcknowledge; + std::unique_ptr<Package> m_tempPackageForAcknowledge; // changes to these 4 member variables are protected by m_mutex PackageExtractor *m_extractor = nullptr; diff --git a/src/manager-lib/nativeruntime.cpp b/src/manager-lib/nativeruntime.cpp index c7cbf71e..d583856a 100644 --- a/src/manager-lib/nativeruntime.cpp +++ b/src/manager-lib/nativeruntime.cpp @@ -3,6 +3,8 @@ // Copyright (C) 2018 Pelagicore AG // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only +#include <memory> + #include <QCoreApplication> #include <QProcess> #include <QDBusServer> @@ -567,11 +569,11 @@ AbstractRuntime *NativeRuntimeManager::create(AbstractContainer *container, Appl { if (!container) return nullptr; - QScopedPointer<NativeRuntime> nrt(new NativeRuntime(container, app, this)); + std::unique_ptr<NativeRuntime> nrt(new NativeRuntime(container, app, this)); if (!nrt || !nrt->initialize()) return nullptr; - return nrt.take(); + return nrt.release(); } QT_END_NAMESPACE_AM diff --git a/src/manager-lib/packagemanager_p.h b/src/manager-lib/packagemanager_p.h index 7beaecdd..169f6e50 100644 --- a/src/manager-lib/packagemanager_p.h +++ b/src/manager-lib/packagemanager_p.h @@ -8,7 +8,6 @@ #include <QMutex> #include <QList> #include <QSet> -#include <QScopedPointer> #include <QThread> #include <QtAppManManager/packagemanager.h> diff --git a/src/manager-lib/runtimefactory.cpp b/src/manager-lib/runtimefactory.cpp index 76201660..2083096e 100644 --- a/src/manager-lib/runtimefactory.cpp +++ b/src/manager-lib/runtimefactory.cpp @@ -3,7 +3,6 @@ // Copyright (C) 2018 Pelagicore AG // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only -#include <QScopedPointer> #include <QCoreApplication> #include "logging.h" diff --git a/src/monitor-lib/processreader.cpp b/src/monitor-lib/processreader.cpp index 3a5145d6..ae092ce8 100644 --- a/src/monitor-lib/processreader.cpp +++ b/src/monitor-lib/processreader.cpp @@ -70,7 +70,7 @@ qreal ProcessReader::readCpuLoad() m_elapsedTime.start(); } - if (m_statReader.isNull() || !m_statReader->isOpen()) { + if (!m_statReader || !m_statReader->isOpen()) { m_lastCpuUsage = 0.0; return 0.0; } diff --git a/src/monitor-lib/processreader.h b/src/monitor-lib/processreader.h index d7309c42..1239ec78 100644 --- a/src/monitor-lib/processreader.h +++ b/src/monitor-lib/processreader.h @@ -12,7 +12,7 @@ #include <QtAppManCommon/global.h> #if defined(Q_OS_LINUX) -# include <QScopedPointer> +# include <memory> # include <QtAppManMonitor/sysfsreader.h> #endif @@ -57,7 +57,7 @@ private: #if defined(Q_OS_LINUX) bool readSmaps(const QByteArray &smapsFile, Memory &mem); - QScopedPointer<SysFsReader> m_statReader; + std::unique_ptr<SysFsReader> m_statReader; QElapsedTimer m_elapsedTime; quint64 m_lastCpuUsage = 0.0; #endif diff --git a/src/monitor-lib/systemreader.cpp b/src/monitor-lib/systemreader.cpp index 5612e4cc..23f2d9e7 100644 --- a/src/monitor-lib/systemreader.cpp +++ b/src/monitor-lib/systemreader.cpp @@ -69,7 +69,7 @@ int dprintf(int fd, const char *format, ...) #endif -QScopedPointer<SysFsReader> CpuReader::s_sysFs; +std::unique_ptr<SysFsReader> CpuReader::s_sysFs; CpuReader::CpuReader() { @@ -533,8 +533,8 @@ bool MemoryWatcher::startWatching(const QString &groupPath) m_memLimit = groupPath.isEmpty() ? m_reader->totalValue() : m_reader->groupLimit(); m_threshold.reset(new MemoryThreshold({m_warning, m_critical})); - connect(m_threshold.data(), &MemoryThreshold::thresholdTriggered, this, &MemoryWatcher::checkMemoryConsumption); - return m_threshold->setEnabled(true, groupPath, m_reader.data()); + connect(m_threshold.get(), &MemoryThreshold::thresholdTriggered, this, &MemoryWatcher::checkMemoryConsumption); + return m_threshold->setEnabled(true, groupPath, m_reader.get()); } void MemoryWatcher::checkMemoryConsumption() diff --git a/src/monitor-lib/systemreader.h b/src/monitor-lib/systemreader.h index 03c3e154..1d89e39e 100644 --- a/src/monitor-lib/systemreader.h +++ b/src/monitor-lib/systemreader.h @@ -11,8 +11,9 @@ #include <QObject> #include <QtAppManCommon/global.h> +#include <memory> + #if defined(Q_OS_LINUX) -# include <QScopedPointer> # include <QtAppManMonitor/sysfsreader.h> QT_FORWARD_DECLARE_CLASS(QSocketNotifier) #endif @@ -30,7 +31,7 @@ private: qint64 m_lastTotal = 0; qreal m_load = 1; #if defined(Q_OS_LINUX) - static QScopedPointer<SysFsReader> s_sysFs; + static std::unique_ptr<SysFsReader> s_sysFs; #endif Q_DISABLE_COPY(CpuReader) }; @@ -81,7 +82,7 @@ public: private: static quint64 s_totalValue; #if defined(Q_OS_LINUX) - QScopedPointer<SysFsReader> m_sysFs; + std::unique_ptr<SysFsReader> m_sysFs; const QString m_groupPath; #elif defined(Q_OS_MACOS) || defined(Q_OS_IOS) static int s_pageSize; @@ -101,7 +102,7 @@ private: QElapsedTimer m_lastCheck; qint64 m_lastIoTime = 0; qreal m_load = 1; - QScopedPointer<SysFsReader> m_sysFs; + std::unique_ptr<SysFsReader> m_sysFs; #endif Q_DISABLE_COPY(IoReader) }; @@ -161,8 +162,8 @@ private: qreal m_memLimit; bool hasMemoryLowWarning = false; bool hasMemoryCriticalWarning = false; - QScopedPointer<MemoryThreshold> m_threshold; - QScopedPointer<MemoryReader> m_reader; + std::unique_ptr<MemoryThreshold> m_threshold; + std::unique_ptr<MemoryReader> m_reader; }; #if defined(Q_OS_LINUX) diff --git a/src/shared-main-lib/cpustatus.h b/src/shared-main-lib/cpustatus.h index 41644029..b598a584 100644 --- a/src/shared-main-lib/cpustatus.h +++ b/src/shared-main-lib/cpustatus.h @@ -5,12 +5,13 @@ #pragma once -#include <QtAppManCommon/global.h> +#include <memory> + +#include <QObject> +#include <QtAppManCommon/global.h> #include <QtAppManMonitor/systemreader.h> -#include <QObject> -#include <QScopedPointer> QT_BEGIN_NAMESPACE_AM @@ -37,7 +38,7 @@ signals: void cpuLoadChanged(); private: - QScopedPointer<CpuReader> m_cpuReader; + std::unique_ptr<CpuReader> m_cpuReader; qreal m_cpuLoad; }; diff --git a/src/shared-main-lib/gpustatus.h b/src/shared-main-lib/gpustatus.h index 5b1326a0..607f7c96 100644 --- a/src/shared-main-lib/gpustatus.h +++ b/src/shared-main-lib/gpustatus.h @@ -5,12 +5,12 @@ #pragma once -#include <QtAppManCommon/global.h> - -#include <QtAppManMonitor/systemreader.h> +#include <memory> #include <QObject> -#include <QScopedPointer> + +#include <QtAppManCommon/global.h> +#include <QtAppManMonitor/systemreader.h> QT_BEGIN_NAMESPACE_AM @@ -35,7 +35,7 @@ signals: void gpuLoadChanged(); private: - QScopedPointer<GpuReader> m_gpuReader; + std::unique_ptr<GpuReader> m_gpuReader; qreal m_gpuLoad; }; diff --git a/src/shared-main-lib/memorystatus.h b/src/shared-main-lib/memorystatus.h index 4c6fcf96..921fdff2 100644 --- a/src/shared-main-lib/memorystatus.h +++ b/src/shared-main-lib/memorystatus.h @@ -5,12 +5,12 @@ #pragma once -#include <QtAppManCommon/global.h> - -#include <QtAppManMonitor/systemreader.h> +#include <memory> #include <QObject> -#include <QScopedPointer> + +#include <QtAppManCommon/global.h> +#include <QtAppManMonitor/systemreader.h> QT_BEGIN_NAMESPACE_AM @@ -37,7 +37,7 @@ signals: void memoryUsedChanged(); private: - QScopedPointer<MemoryReader> m_memoryReader; + std::unique_ptr<MemoryReader> m_memoryReader; quint64 m_memoryUsed; }; diff --git a/src/tools/launcher-qml/launcher-qml.cpp b/src/tools/launcher-qml/launcher-qml.cpp index d5b8fb2a..e7eaf1bf 100644 --- a/src/tools/launcher-qml/launcher-qml.cpp +++ b/src/tools/launcher-qml/launcher-qml.cpp @@ -3,6 +3,8 @@ // Copyright (C) 2018 Pelagicore AG // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only +#include <memory> + #include <QQmlComponent> #include <QQmlContext> #include <QQmlDebuggingEnabler> @@ -235,7 +237,7 @@ Controller::Controller(LauncherMain *launcher, bool quickLaunched, const QPair<Q static const char registerWindowQml[] = "import QtQuick 2.0\nimport QtQuick.Window 2.2\nQtObject { }\n"; QQmlComponent registerWindowComp(&m_engine); registerWindowComp.setData(QByteArray::fromRawData(registerWindowQml, sizeof(registerWindowQml) - 1), QUrl()); - QScopedPointer<QObject> dummy(registerWindowComp.create()); + std::unique_ptr<QObject> dummy(registerWindowComp.create()); } StartupTimer::instance()->checkpoint("after window registration"); @@ -283,7 +285,7 @@ Controller::Controller(LauncherMain *launcher, bool quickLaunched, const QPair<Q if (!quicklaunchQml.isEmpty() && quickLaunched) { QQmlComponent quicklaunchComp(&m_engine, filePathToUrl(quicklaunchQml, launcher->baseDir())); if (!quicklaunchComp.isError()) { - QScopedPointer<QObject> quicklaunchInstance(quicklaunchComp.create()); + std::unique_ptr<QObject> quicklaunchInstance(quicklaunchComp.create()); } else { const QList<QQmlError> errors = quicklaunchComp.errors(); for (const QQmlError &error : errors) diff --git a/src/tools/packager/packager.cpp b/src/tools/packager/packager.cpp index 3cbc0d0e..fd0bfffc 100644 --- a/src/tools/packager/packager.cpp +++ b/src/tools/packager/packager.cpp @@ -3,6 +3,9 @@ // Copyright (C) 2018 Pelagicore AG // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +#include <memory> +#include <stdio.h> + #include <QCoreApplication> #include <QCommandLineParser> #include <QStringList> @@ -11,8 +14,6 @@ #include <QJsonDocument> #include <QDebug> -#include <stdio.h> - #include <QtAppManCommon/exception.h> #include <QtAppManCommon/qtyaml.h> #include <QtAppManCommon/utilities.h> @@ -111,7 +112,7 @@ int main(int argc, char *argv[]) clp.setOptionsAfterPositionalArgumentsMode(QCommandLineParser::ParseAsOptions); try { - QScopedPointer<PackagingJob> p; + std::unique_ptr<PackagingJob> p; // REMEMBER to update the completion file util/bash/appman-prompt, if you apply changes below! switch (command(clp)) { diff --git a/src/tools/packager/packagingjob.cpp b/src/tools/packager/packagingjob.cpp index 1d0ac841..cd312302 100644 --- a/src/tools/packager/packagingjob.cpp +++ b/src/tools/packager/packagingjob.cpp @@ -3,6 +3,10 @@ // Copyright (C) 2018 Pelagicore AG // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +#include <memory> +#include <stdio.h> +#include <stdlib.h> + #include <QFile> #include <QFileInfo> #include <QUrl> @@ -11,9 +15,6 @@ #include <QJsonDocument> #include <QTemporaryDir> -#include <stdio.h> -#include <stdlib.h> - #include "exception.h" #include "signature.h" #include "qtyaml.h" @@ -126,7 +127,7 @@ void PackagingJob::execute() Q_DECL_NOEXCEPT_EXPR(false) // check metadata QString infoName = qSL("info.yaml"); - QScopedPointer<PackageInfo> package(PackageInfo::fromManifest(source.absoluteFilePath(infoName))); + std::unique_ptr<PackageInfo> package(PackageInfo::fromManifest(source.absoluteFilePath(infoName))); // warn the user that old-style manifests are going to be deprecated in the future try { diff --git a/src/window-lib/inprocesswindow.h b/src/window-lib/inprocesswindow.h index bac5ead0..63e82082 100644 --- a/src/window-lib/inprocesswindow.h +++ b/src/window-lib/inprocesswindow.h @@ -7,7 +7,6 @@ #include <QObject> #include <QSharedPointer> -#include <QScopedPointer> #include <QtAppManWindow/window.h> #include <QtAppManManager/inprocesssurfaceitem.h> diff --git a/tests/auto/packageextractor/tst_packageextractor.cpp b/tests/auto/packageextractor/tst_packageextractor.cpp index d3db2eca..d1b1f05e 100644 --- a/tests/auto/packageextractor/tst_packageextractor.cpp +++ b/tests/auto/packageextractor/tst_packageextractor.cpp @@ -3,6 +3,8 @@ // Copyright (C) 2018 Pelagicore AG // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +#include <memory> + #include <QtTest> #include <QtNetwork> #include <QTemporaryDir> @@ -45,7 +47,7 @@ private slots: private: QString m_taest; - QScopedPointer<QTemporaryDir> m_extractDir; + std::unique_ptr<QTemporaryDir> m_extractDir; }; tst_PackageExtractor::tst_PackageExtractor() diff --git a/tests/auto/runtime/tst_runtime.cpp b/tests/auto/runtime/tst_runtime.cpp index e4c5a3f1..d3591f64 100644 --- a/tests/auto/runtime/tst_runtime.cpp +++ b/tests/auto/runtime/tst_runtime.cpp @@ -3,6 +3,8 @@ // Copyright (C) 2018 Pelagicore AG // SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0 +#include <memory> + #include <QtTest> #include <QQmlEngine> @@ -85,7 +87,7 @@ tst_Runtime::tst_Runtime() void tst_Runtime::factory() { - QScopedPointer<RuntimeFactory> rf { RuntimeFactory::instance() }; + std::unique_ptr<RuntimeFactory> rf { RuntimeFactory::instance() }; QVERIFY(rf); QVERIFY(rf.get() == RuntimeFactory::instance()); @@ -111,9 +113,9 @@ void tst_Runtime::factory() QCOMPARE(temp.write(yaml), yaml.size()); temp.close(); - QScopedPointer<Application> a; - QScopedPointer<PackageInfo> pi; - QScopedPointer<Package> p; + std::unique_ptr<Application> a; + std::unique_ptr<PackageInfo> pi; + std::unique_ptr<Package> p; try { pi.reset(PackageInfo::fromManifest(temp.fileName())); QVERIFY(pi); @@ -124,17 +126,17 @@ void tst_Runtime::factory() } QVERIFY(a); - QScopedPointer<AbstractRuntime> r { rf->create(nullptr, a.get()) }; + std::unique_ptr<AbstractRuntime> r { rf->create(nullptr, a.get()) }; QVERIFY(r); QVERIFY(r->application() == a.get()); QVERIFY(r->manager()->inProcess()); QVERIFY(r->state() == Am::NotRunning); QVERIFY(r->applicationProcessId() == 0); { - QScopedPointer<QQmlEngine> engine(new QQmlEngine()); + std::unique_ptr<QQmlEngine> engine(new QQmlEngine()); QVERIFY(!r->inProcessQmlEngine()); - r->setInProcessQmlEngine(engine.data()); - QVERIFY(r->inProcessQmlEngine() == engine.data()); + r->setInProcessQmlEngine(engine.get()); + QVERIFY(r->inProcessQmlEngine() == engine.get()); r->setInProcessQmlEngine(nullptr); } QVERIFY(r->start()); |