From 1b6190534e3de2f9b1bea37bc3803bd061e3a628 Mon Sep 17 00:00:00 2001 From: Robert Griebl Date: Sun, 18 Feb 2024 15:06:42 +0100 Subject: Axivion: fix or document most of the reported issues Change-Id: I5723096b8db71c216b33e189a2469b3130c19504 Pick-to: 6.7 Reviewed-by: Qt CI Bot Reviewed-by: Dominik Holland --- coin/axivion/ci_config_linux.json | 37 ++++++++++++++++++++++ src/application-lib/packagedatabase.cpp | 2 +- .../intentclientdbusimplementation.h | 2 +- .../waylandqtamclientextension.cpp | 5 +++ .../waylandqtamclientextension_p.h | 4 +-- src/common-lib/configcache.h | 1 + src/common-lib/configcache_p.h | 4 +-- src/common-lib/crashhandler.cpp | 4 +-- src/common-lib/exception.cpp | 24 ++++++++++++-- src/common-lib/exception.h | 4 ++- src/common-lib/logging.cpp | 9 +++--- src/common-lib/logging.h | 5 ++- src/common-lib/qtyaml.cpp | 6 ++-- src/common-lib/utilities.h | 2 +- src/crypto-lib/cryptography.cpp | 2 ++ src/crypto-lib/libcryptofunction.cpp | 2 ++ src/crypto-lib/signature_openssl.cpp | 1 + src/dbus-lib/dbuspolicy.cpp | 17 +++++----- src/intent-server-lib/intentserver.cpp | 17 +++++----- src/main-lib/configuration.cpp | 2 +- src/main-lib/main.cpp | 28 +++++++++------- src/main-lib/main.h | 2 +- src/manager-lib/applicationmanager.cpp | 21 ++++++------ src/manager-lib/applicationmanager_p.h | 2 +- src/manager-lib/intentaminterface.cpp | 2 +- src/manager-lib/nativeruntime.cpp | 2 +- src/manager-lib/nativeruntime.h | 4 +-- src/manager-lib/notificationmanager.cpp | 22 ++++++------- src/manager-lib/packagemanager.cpp | 10 +++--- src/manager-lib/processstatus.h | 2 +- src/manager-lib/sudo.h | 2 +- src/monitor-lib/processreader.h | 2 +- src/monitor-lib/systemreader.h | 2 +- .../bubblewrapcontainer.cpp | 9 ++++-- .../bubblewrapcontainer.h | 4 +-- src/shared-main-lib/frametimer.h | 8 ++--- src/shared-main-lib/monitormodel.h | 2 +- src/window-lib/windowmanager.cpp | 9 +++--- src/window-lib/windowmanager_p.h | 2 +- 39 files changed, 183 insertions(+), 102 deletions(-) diff --git a/coin/axivion/ci_config_linux.json b/coin/axivion/ci_config_linux.json index cfe3e773..1719e86b 100644 --- a/coin/axivion/ci_config_linux.json +++ b/coin/axivion/ci_config_linux.json @@ -1,4 +1,41 @@ { + "Analysis": { + "EnableDisable": { + "_active": true + }, + "EnableDisableSingleRule": { + "_active": true + }, + "InitialExternalAnnotations": { + "_active": true, + "initial_comments": { + "$(delta:+)": { + "src/3rdparty/libarchive/*.h": [ + "AXIVION Disable" + ], + "src/3rdparty/libyaml/*/*.h": [ + "AXIVION Disable" + ], + "build/src/*/*": [ + "AXIVION Disable" + ], + "build/include/*/*": [ + "AXIVION Disable" + ] + }, + "$(delta:-)": [] + } + }, + "NextLine": { + "_active": true + }, + "PreviousLine": { + "_active": true + }, + "SameLine": { + "_active": true + } + }, "Project": { "BuildSystemIntegration": { "child_order": [ diff --git a/src/application-lib/packagedatabase.cpp b/src/application-lib/packagedatabase.cpp index c2d5b945..57a16fdf 100644 --- a/src/application-lib/packagedatabase.cpp +++ b/src/application-lib/packagedatabase.cpp @@ -158,7 +158,7 @@ void PackageDatabase::parse(PackageLocations packageLocations) if ((packageLocations & Builtin) && !(m_parsedPackageLocations & Builtin)) { QStringList manifestFiles; - for (const QString &dir : m_builtInPackagesDirs) + for (const QString &dir : std::as_const(m_builtInPackagesDirs)) manifestFiles << findManifestsInDir(dir, true); ConfigCache cache(manifestFiles, u"appdb-builtin"_s, { 'P','K','G','B' }, diff --git a/src/application-main-lib/intentclientdbusimplementation.h b/src/application-main-lib/intentclientdbusimplementation.h index bf7935e4..075e9113 100644 --- a/src/application-main-lib/intentclientdbusimplementation.h +++ b/src/application-main-lib/intentclientdbusimplementation.h @@ -26,7 +26,7 @@ public: void replyFromApplication(const QPointer &icr) override; private: - IoQtApplicationManagerIntentInterfaceInterface *m_dbusInterface; + IoQtApplicationManagerIntentInterfaceInterface *m_dbusInterface = nullptr; QString m_dbusName; }; diff --git a/src/application-main-lib/waylandqtamclientextension.cpp b/src/application-main-lib/waylandqtamclientextension.cpp index de2691b6..92caa10b 100644 --- a/src/application-main-lib/waylandqtamclientextension.cpp +++ b/src/application-main-lib/waylandqtamclientextension.cpp @@ -45,6 +45,11 @@ bool WaylandQtAMClientExtension::eventFilter(QObject *o, QEvent *e) for (auto it = wp.cbegin(); it != wp.cend(); ++it) sendPropertyToServer(surface, it.key(), it.value()); } + // pointers can be reused, so we have to remove the old mappings + connect(window, &QObject::destroyed, this, [this, window]() { + m_windowToSurface.remove(window); + m_windowProperties.remove(window); + }); } } } else if (e->type() == QEvent::Hide) { diff --git a/src/application-main-lib/waylandqtamclientextension_p.h b/src/application-main-lib/waylandqtamclientextension_p.h index c1b7f949..22f335c0 100644 --- a/src/application-main-lib/waylandqtamclientextension_p.h +++ b/src/application-main-lib/waylandqtamclientextension_p.h @@ -50,8 +50,8 @@ private: void sendPropertyToServer(::wl_surface *surface, const QString &name, const QVariant &value); void qtam_extension_window_property_changed(wl_surface *surface, const QString &name, wl_array *value) override; - QMap m_windowProperties; - QMap m_windowToSurface; + QMap m_windowProperties; // AXIVION Line Qt-QMapWithPointerKey: cleared on destroyed signal + QMap m_windowToSurface; // AXIVION Line Qt-QMapWithPointerKey: cleared on destroyed signal }; QT_END_NAMESPACE_AM diff --git a/src/common-lib/configcache.h b/src/common-lib/configcache.h index 7b7613be..10e58924 100644 --- a/src/common-lib/configcache.h +++ b/src/common-lib/configcache.h @@ -80,6 +80,7 @@ public: ConfigCache(const QStringList &configFiles, const QString &cacheBaseName, std::array typeId, quint32 typeVersion = 0, Options options = None) : AbstractConfigCache(configFiles, cacheBaseName, typeId, typeVersion, options) + , m_adaptor() { } ~ConfigCache() override diff --git a/src/common-lib/configcache_p.h b/src/common-lib/configcache_p.h index 50f44ee2..5c656593 100644 --- a/src/common-lib/configcache_p.h +++ b/src/common-lib/configcache_p.h @@ -36,8 +36,8 @@ class ConfigCachePrivate { public: AbstractConfigCache::Options options; - quint32 typeId; - quint32 typeVersion; + quint32 typeId = 0; + quint32 typeVersion = 0; QStringList rawFiles; QString cacheBaseName; QVector cache; diff --git a/src/common-lib/crashhandler.cpp b/src/common-lib/crashhandler.cpp index 427e036a..8c25d88b 100644 --- a/src/common-lib/crashhandler.cpp +++ b/src/common-lib/crashhandler.cpp @@ -351,9 +351,9 @@ static void initBacktraceUnix() throw; } catch (const std::exception &exc) { snprintf(buffer, sizeof(buffer), "uncaught exception of type %s (%s)", typeName, exc.what()); - } catch (const std::exception *exc) { + } catch (const std::exception *exc) { // AXIVION Line Qt-Generic-ThrowByValueCatchByReference: cope with anything snprintf(buffer, sizeof(buffer), "uncaught exception of type %s (%s)", typeName, exc->what()); - } catch (const char *exc) { + } catch (const char *exc) { // AXIVION Line Qt-Generic-ThrowByValueCatchByReference: cope with anything snprintf(buffer, sizeof(buffer), "uncaught exception of type 'const char *' (%s)", exc); } catch (...) { snprintf(buffer, sizeof(buffer), "uncaught exception of type %s", typeName); diff --git a/src/common-lib/exception.cpp b/src/common-lib/exception.cpp index 2421a18c..175aa91c 100644 --- a/src/common-lib/exception.cpp +++ b/src/common-lib/exception.cpp @@ -41,15 +41,33 @@ Exception::Exception(const QFileDevice &file, const char *errorString) noexcept { } Exception::Exception(const Exception ©) noexcept - : m_errorCode(copy.m_errorCode) + : QException(copy) + , m_errorCode(copy.m_errorCode) , m_errorString(copy.m_errorString) { } +Exception &Exception::operator=(const Exception ©) noexcept +{ + if (this != ©) { + QException::operator=(copy); + m_errorCode = copy.m_errorCode; + m_errorString = copy.m_errorString; + } + return *this; +} + Exception::Exception(Exception &&move) noexcept - : m_errorCode(move.m_errorCode) + : QException(move) + , m_errorCode(move.m_errorCode) , m_errorString(move.m_errorString) +{ } + +Exception &Exception::operator=(Exception &&move) noexcept { - std::swap(m_whatBuffer, move.m_whatBuffer); + QException::operator=(move); + m_errorCode = move.m_errorCode; + m_errorString = move.m_errorString; + return *this; } Exception::~Exception() noexcept diff --git a/src/common-lib/exception.h b/src/common-lib/exception.h index c1959ab3..4383c8d1 100644 --- a/src/common-lib/exception.h +++ b/src/common-lib/exception.h @@ -29,7 +29,9 @@ public: explicit Exception(const QFileDevice &file, const char *errorString) noexcept; Exception(const Exception ©) noexcept; + Exception &operator=(const Exception ©) noexcept; Exception(Exception &&move) noexcept; + Exception &operator=(Exception &&move) noexcept; ~Exception() noexcept override; @@ -74,7 +76,7 @@ public: // this will generate compiler errors if there's no suitable QString::arg(const Ts &) overload template Exception &arg(const Ts & ...ts) noexcept { - m_errorString = m_errorString.arg(ts...); + m_errorString = m_errorString.arg(ts...); // AXIVION Line Qt-QStringArg: Axivion thinks ts is an int return *this; } diff --git a/src/common-lib/logging.cpp b/src/common-lib/logging.cpp index 846ff624..14688166 100644 --- a/src/common-lib/logging.cpp +++ b/src/common-lib/logging.cpp @@ -108,6 +108,7 @@ static constexpr const char *s_defaultSystemUiDltDescription = "Qt Application M \endtable //! [am-logging-categories] */ +// AXIVION DISABLE Qt-NonPodGlobalStatic QDLT_REGISTER_CONTEXT_ON_FIRST_USE(true) QDLT_REGISTER_APPLICATION(s_defaultSystemUiDltId, s_defaultSystemUiDltDescription) QDLT_LOGGING_CATEGORY(LogSystem, "am.system", "SYS", "General system messages") @@ -125,13 +126,16 @@ QDLT_LOGGING_CATEGORY(LogCache, "am.cache", "CACH", "Cache sub-system messages") QDLT_LOGGING_CATEGORY(LogDBus, "am.dbus", "DBUS", "D-Bus related messages") QDLT_LOGGING_CATEGORY(LogGeneral, "general", "GEN", "Messages without dedicated context ID (fallback)") QDLT_FALLBACK_CATEGORY(LogGeneral) - +// AXIVION ENABLE Qt-NonPodGlobalStatic struct DeferredMessage { DeferredMessage(QtMsgType _msgType, const QMessageLogContext &_context, const QString &_message); + DeferredMessage(const DeferredMessage ©) = delete; DeferredMessage(DeferredMessage &&other) noexcept; ~DeferredMessage(); + DeferredMessage &operator=(const DeferredMessage ©) = delete; + DeferredMessage &operator=(DeferredMessage &&move) = delete; QtMsgType msgType; int line; @@ -576,7 +580,4 @@ void Logging::logToDlt(QtMsgType msgType, const QMessageLogContext &context, con #endif } -void am_trace(QDebug) -{ } - QT_END_NAMESPACE_AM diff --git a/src/common-lib/logging.h b/src/common-lib/logging.h index 938ab429..818984cb 100644 --- a/src/common-lib/logging.h +++ b/src/common-lib/logging.h @@ -65,9 +65,8 @@ private: static void deferredMessageHandler(QtMsgType msgType, const QMessageLogContext &context, const QString &message); }; -void am_trace(QDebug); -template void am_trace(QDebug dbg, T t, TRest... trest) -{ dbg << t; am_trace(dbg, trest...); } +template void am_trace(QDebug dbg, Ts &&... ts) +{ (dbg << ... << ts); } #define AM_TRACE(category, ...) \ for (bool qt_category_enabled = category().isDebugEnabled(); qt_category_enabled; qt_category_enabled = false) { \ diff --git a/src/common-lib/qtyaml.cpp b/src/common-lib/qtyaml.cpp index 059e681d..272b950f 100644 --- a/src/common-lib/qtyaml.cpp +++ b/src/common-lib/qtyaml.cpp @@ -153,8 +153,8 @@ public: QString sourceDir; QByteArray data; bool parsedHeader = false; - yaml_parser_t parser; - yaml_event_t event; + yaml_parser_t parser; // AXIVION Line Qt-Generic-InitializeAllFieldsInConstructor: not possible + yaml_event_t event; // AXIVION Line Qt-Generic-InitializeAllFieldsInConstructor: not possible }; @@ -332,7 +332,7 @@ QVariant YamlParser::parseScalar() const struct StaticMapping { QString text; - ValueIndex index; + ValueIndex index = ValueNull; }; static const QVariant staticValues[] = { diff --git a/src/common-lib/utilities.h b/src/common-lib/utilities.h index 2201a6e3..db0bc7c4 100644 --- a/src/common-lib/utilities.h +++ b/src/common-lib/utilities.h @@ -106,7 +106,7 @@ template QVector loadPlugins(const char *type, const QStringList &files) noexcept(false) { QVector result; - auto plugins = loadPlugins_helper(type, files, qobject_interface_iid()); + const auto plugins = loadPlugins_helper(type, files, qobject_interface_iid()); for (auto p : plugins) result << qobject_cast(p); return result; diff --git a/src/crypto-lib/cryptography.cpp b/src/crypto-lib/cryptography.cpp index 817ae68c..8537d2a3 100644 --- a/src/crypto-lib/cryptography.cpp +++ b/src/crypto-lib/cryptography.cpp @@ -34,6 +34,8 @@ static bool openSslInitialized = false; static bool loadOpenSsl3LegacyProvider = false; // clazy:excludeall=non-pod-global-static +// AXIVION DISABLE Qt-NonPodGlobalStatic + static QT_AM_LIBCRYPTO_FUNCTION(ERR_error_string_n, void(*)(unsigned long, char *, size_t)); QT_END_NAMESPACE_AM diff --git a/src/crypto-lib/libcryptofunction.cpp b/src/crypto-lib/libcryptofunction.cpp index 64acbaad..1774eabf 100644 --- a/src/crypto-lib/libcryptofunction.cpp +++ b/src/crypto-lib/libcryptofunction.cpp @@ -17,6 +17,8 @@ QT_BEGIN_NAMESPACE_AM // clazy:excludeall=non-pod-global-static +// AXIVION DISABLE Qt-NonPodGlobalStatic + static QT_AM_LIBCRYPTO_FUNCTION(SSLeay, unsigned long(*)(), 0); static QT_AM_LIBCRYPTO_FUNCTION(OPENSSL_add_all_algorithms_noconf, void(*)()); static QT_AM_LIBCRYPTO_FUNCTION(ERR_load_crypto_strings, void(*)()); diff --git a/src/crypto-lib/signature_openssl.cpp b/src/crypto-lib/signature_openssl.cpp index 3b65ba43..1ce38f81 100644 --- a/src/crypto-lib/signature_openssl.cpp +++ b/src/crypto-lib/signature_openssl.cpp @@ -13,6 +13,7 @@ QT_BEGIN_NAMESPACE_AM // clazy:excludeall=non-pod-global-static +// AXIVION DISABLE Qt-NonPodGlobalStatic // dummy structures struct BIO; diff --git a/src/dbus-lib/dbuspolicy.cpp b/src/dbus-lib/dbuspolicy.cpp index 1feffb63..ea829d90 100644 --- a/src/dbus-lib/dbuspolicy.cpp +++ b/src/dbus-lib/dbuspolicy.cpp @@ -14,6 +14,7 @@ #include #include "utilities.h" +#include "exception.h" #include "dbuspolicy.h" #include "dbuscontextadaptor.h" @@ -125,14 +126,14 @@ bool DBusPolicy::check(const QDBusAbstractAdaptor *dbusAdaptor, const QByteArray const QStringList apps = m_applicationIdsForPid(pid); if (apps.size() > 1) - throw "multiple apps per pid are not supported"; + throw Exception("multiple apps per pid are not supported"); const QString appId = !apps.isEmpty() ? apps.constFirst() : QString(); const QStringList appCaps = m_capabilitiesForApplicationId(appId); bool match = false; for (const QString &cap : ip->m_capabilities) match = match && std::binary_search(appCaps.cbegin(), appCaps.cend(), cap); if (!match) - throw "insufficient capabilities"; + throw Exception("insufficient capabilities"); } if (!ip->m_executables.isEmpty()) { # if defined(Q_OS_LINUX) @@ -140,23 +141,23 @@ bool DBusPolicy::check(const QDBusAbstractAdaptor *dbusAdaptor, const QByteArray pid = dbusContext->connection().interface()->servicePid(dbusContext->message().service()); QString executable = QFileInfo(u"/proc/"_s + QString::number(pid) + u"/exe"_s).symLinkTarget(); if (executable.isEmpty()) - throw "cannot get executable"; + throw Exception("cannot get executable"); if (std::binary_search(ip->m_executables.cbegin(), ip->m_executables.cend(), executable)) - throw "executable blocked"; + throw Exception("executable blocked"); # else - throw false; + throw Exception("the executables policy is not supported on this platform"); # endif // defined(Q_OS_LINUX) } if (!ip->m_uids.isEmpty()) { uint uid = dbusContext->connection().interface()->serviceUid(dbusContext->message().service()); if (std::binary_search(ip->m_uids.cbegin(), ip->m_uids.cend(), uid)) - throw "uid blocked"; + throw Exception("uid blocked"); } return true; - } catch (const char *msg) { - dbusContext->sendErrorReply(QDBusError::AccessDenied, u"Protected function call (%1)"_s.arg(QString::fromLatin1(msg))); + } catch (const Exception &e) { + dbusContext->sendErrorReply(QDBusError::AccessDenied, u"Protected function call (%1)"_s.arg(e.errorString())); return false; } #endif // !defined(Q_OS_UNIX) diff --git a/src/intent-server-lib/intentserver.cpp b/src/intent-server-lib/intentserver.cpp index 14c7ceab..b60b3acf 100644 --- a/src/intent-server-lib/intentserver.cpp +++ b/src/intent-server-lib/intentserver.cpp @@ -9,6 +9,7 @@ #include "intentmodel.h" #include +#include #include @@ -218,20 +219,20 @@ Intent *IntentServer::addIntent(const QString &id, const QString &packageId, { try { if (id.isEmpty()) - throw "no id specified"; + throw Exception("no id specified"); if (packageId.isEmpty()) - throw "no packageId specified"; + throw Exception("no packageId specified"); if (handlingApplicationId.isEmpty()) - throw "no handlingApplicationId specified"; + throw Exception("no handlingApplicationId specified"); if (!m_knownApplications.contains(packageId)) - throw "packageId is not known"; + throw Exception("packageId is not known"); if (!m_knownApplications.value(packageId).contains(handlingApplicationId)) - throw "applicationId is not known or not part of the specified package"; + throw Exception("applicationId is not known or not part of the specified package"); if (applicationIntent(id, handlingApplicationId)) - throw "intent with given id/handlingApplicationId already exists"; - } catch (const char *e) { + throw Exception("intent with given id/handlingApplicationId already exists"); + } catch (const Exception &e) { qCWarning(LogIntents) << "Cannot add intent" << id << "in package" << packageId - << "handled by" << handlingApplicationId << ":" << e; + << "handled by" << handlingApplicationId << ":" << e.errorString(); return nullptr; } diff --git a/src/main-lib/configuration.cpp b/src/main-lib/configuration.cpp index 49d4e8e3..797f28d7 100644 --- a/src/main-lib/configuration.cpp +++ b/src/main-lib/configuration.cpp @@ -640,7 +640,7 @@ ConfigurationData *ConfigurationData::loadFromSource(QIODevice *source, const QS if (containerSelection.metaType() == QMetaType::fromType()) { config.append(qMakePair(u"*"_s, containerSelection.toString())); } else if (containerSelection.metaType() == QMetaType::fromType()) { - QVariantList list = containerSelection.toList(); + const QVariantList list = containerSelection.toList(); for (const QVariant &v : list) { if (v.metaType() == QMetaType::fromType()) { QVariantMap map = v.toMap(); diff --git a/src/main-lib/main.cpp b/src/main-lib/main.cpp index b0386b6d..a5182980 100644 --- a/src/main-lib/main.cpp +++ b/src/main-lib/main.cpp @@ -325,7 +325,8 @@ void Main::loadStartupPlugins(const QStringList &startupPluginPaths) noexcept(fa { QStringList systemStartupPluginPaths; const QDir systemStartupPluginDir(QLibraryInfo::path(QLibraryInfo::PluginsPath) + QDir::separator() + u"appman_startup"_s); - for (const auto &pluginName : systemStartupPluginDir.entryList(QDir::Files | QDir::NoDotAndDotDot)) { + const auto allPluginNames = systemStartupPluginDir.entryList(QDir::Files | QDir::NoDotAndDotDot); + for (const auto &pluginName : allPluginNames) { const QString filePath = systemStartupPluginDir.absoluteFilePath(pluginName); if (!QLibrary::isLibrary(filePath)) continue; @@ -414,7 +415,8 @@ void Main::setupRuntimesAndContainers(const QVariantMap &runtimeConfigurations, #endif QStringList systemContainerPluginPaths; const QDir systemContainerPluginDir(QLibraryInfo::path(QLibraryInfo::PluginsPath) + QDir::separator() + u"appman_container"_s); - for (const auto &pluginName : systemContainerPluginDir.entryList(QDir::Files | QDir::NoDotAndDotDot)) { + const auto allPluginNames = systemContainerPluginDir.entryList(QDir::Files | QDir::NoDotAndDotDot); + for (const auto &pluginName : allPluginNames) { const QString filePath = systemContainerPluginDir.absoluteFilePath(pluginName); if (!QLibrary::isLibrary(filePath)) continue; @@ -473,7 +475,7 @@ void Main::loadPackageDatabase(bool recreateDatabase, const QString &singlePacka for (auto package : allPackages) { // check that the runtimes are supported in this instance of the AM - auto apps = package->applications(); + const auto apps = package->applications(); for (const auto app : apps) { if (!RuntimeFactory::instance()->manager(app->runtimeName())) @@ -987,11 +989,12 @@ void Main::setupDBus(const std::function &busForInterface #endif // defined(QT_DBUS_LIB) && QT_CONFIG(am_external_dbus_interfaces) } -QString Main::registerDBusObject(QDBusAbstractAdaptor *adaptor, QString dbusName, +QString Main::registerDBusObject(QDBusAbstractAdaptor *adaptor, const QString &dbusName, const char *serviceName, const char *path) noexcept(false) { #if defined(QT_DBUS_LIB) && QT_CONFIG(am_external_dbus_interfaces) QString dbusAddress; + QString dbusRealName = dbusName; QDBusConnection conn((QString())); bool isP2P = false; @@ -1015,7 +1018,7 @@ QString Main::registerDBusObject(QDBusAbstractAdaptor *adaptor, QString dbusName conn = QDBusConnection::connectToBus(dbusAddress, u"qtam_session"_s); if (!conn.isConnected()) return { }; - dbusName = u"session"_s; + dbusRealName = u"session"_s; } else if (dbusName == u"p2p") { if (!m_p2pServer && !m_p2pFailed) { m_p2pServer = new QDBusServer(this); @@ -1047,29 +1050,29 @@ QString Main::registerDBusObject(QDBusAbstractAdaptor *adaptor, QString dbusName if (!isP2P) { if (!conn.isConnected()) { throw Exception("could not connect to D-Bus (%1): %2") - .arg(dbusAddress.isEmpty() ? dbusName : dbusAddress).arg(conn.lastError().message()); + .arg(dbusAddress.isEmpty() ? dbusRealName : dbusAddress).arg(conn.lastError().message()); } if (!conn.registerObject(QString::fromLatin1(path), adaptor->parent(), QDBusConnection::ExportAdaptors)) { throw Exception("could not register object %1 on D-Bus (%2): %3") - .arg(QString::fromLatin1(path)).arg(dbusName).arg(conn.lastError().message()); + .arg(QString::fromLatin1(path)).arg(dbusRealName).arg(conn.lastError().message()); } if (!conn.registerService(QString::fromLatin1(serviceName))) { throw Exception("could not register service %1 on D-Bus (%2): %3") - .arg(QString::fromLatin1(serviceName)).arg(dbusName).arg(conn.lastError().message()); + .arg(QString::fromLatin1(serviceName)).arg(dbusRealName).arg(conn.lastError().message()); } } if (adaptor->parent() && adaptor->parent()->parent()) { // we need this information later on to tell apps where services are listening - adaptor->parent()->parent()->setProperty("_am_dbus_name", dbusName); + adaptor->parent()->parent()->setProperty("_am_dbus_name", dbusRealName); adaptor->parent()->parent()->setProperty("_am_dbus_address", dbusAddress); } - qCDebug(LogDBus).nospace().noquote() << " * " << serviceName << path << " [on bus: " << dbusName << "]"; + qCDebug(LogDBus).nospace().noquote() << " * " << serviceName << path << " [on bus: " << dbusRealName << "]"; - return dbusAddress.isEmpty() ? dbusName : dbusAddress; + return dbusAddress.isEmpty() ? dbusRealName : dbusAddress; #else Q_UNUSED(adaptor) Q_UNUSED(dbusName) @@ -1093,7 +1096,8 @@ QString Main::hardwareId() const } #else QVector candidateIfaces; - for (const QNetworkInterface &iface : QNetworkInterface::allInterfaces()) { + const auto allIfaces = QNetworkInterface::allInterfaces(); + for (const QNetworkInterface &iface : allIfaces) { if (iface.isValid() && !(iface.flags() & (QNetworkInterface::IsPointToPoint | QNetworkInterface::IsLoopBack)) && iface.type() > QNetworkInterface::Virtual diff --git a/src/main-lib/main.h b/src/main-lib/main.h index dfdd94b0..c30fc039 100644 --- a/src/main-lib/main.h +++ b/src/main-lib/main.h @@ -118,7 +118,7 @@ protected: private: static int &preConstructor(int &argc, char **argv, InitFlags initFlags); - QString registerDBusObject(QDBusAbstractAdaptor *adaptor, QString dbusName, + QString registerDBusObject(QDBusAbstractAdaptor *adaptor, const QString &dbusName, const char *serviceName, const char *path) noexcept(false); private: diff --git a/src/manager-lib/applicationmanager.cpp b/src/manager-lib/applicationmanager.cpp index 9ed0a678..0103f896 100644 --- a/src/manager-lib/applicationmanager.cpp +++ b/src/manager-lib/applicationmanager.cpp @@ -493,7 +493,7 @@ QVector ApplicationManager::applications() const Application *ApplicationManager::fromId(const QString &id) const { - for (Application *app : d->apps) { + for (Application *app : std::as_const(d->apps)) { if (app->id() == id) return app; } @@ -509,7 +509,7 @@ QVector ApplicationManager::fromProcessId(qint64 pid) const int level = 0; while ((pid > 1) && (pid != appmanPid) && (level < 5)) { - for (Application *app : d->apps) { + for (Application *app : std::as_const(d->apps)) { if (apps.contains(app)) continue; if (app->currentRuntime() && (app->currentRuntime()->applicationProcessId() == pid)) @@ -526,7 +526,7 @@ Application *ApplicationManager::fromSecurityToken(const QByteArray &securityTok if (securityToken.size() != AbstractRuntime::SecurityTokenSize) return nullptr; - for (Application *app : d->apps) { + for (Application *app : std::as_const(d->apps)) { if (app->currentRuntime() && app->currentRuntime()->securityToken() == securityToken) return app; } @@ -537,7 +537,7 @@ QVector ApplicationManager::schemeHandlers(const QString &scheme) { QVector handlers; - for (Application *app : d->apps) { + for (Application *app : std::as_const(d->apps)) { const auto mimeTypes = app->supportedMimeTypes(); for (const QString &mime : mimeTypes) { auto pos = mime.indexOf(u'/'); @@ -556,7 +556,7 @@ QVector ApplicationManager::mimeTypeHandlers(const QString &mimeT { QVector handlers; - for (Application *app : d->apps) { + for (Application *app : std::as_const(d->apps)) { if (app->supportedMimeTypes().contains(mimeType)) handlers << app; } @@ -833,17 +833,18 @@ bool ApplicationManager::startApplicationInternal(const QString &appId, const QS return successfullyStarted; }; - auto tryStartInContainer = [container, inProcess, doStartInContainer]() -> bool { + auto tryStartInContainer = [this, container, inProcess, doStartInContainer]() -> bool { if (inProcess || container->isReady()) { // Since the container is already ready, start the app immediately return doStartInContainer(); } else { // We postpone the starting of the application to a later point in time, // since the container is not ready yet -# if defined(Q_CC_MSVC) - qApp->connect(container, &AbstractContainer::ready, doStartInContainer); // MSVC cannot distinguish between static and non-static overloads in lambdas -# else - connect(container, &AbstractContainer::ready, doStartInContainer); + // since the container is not ready yet +#if defined(Q_CC_MSVC) + qApp->connect(container, &AbstractContainer::ready, this, doStartInContainer); // MSVC cannot distinguish between static and non-static overloads in lambdas +#else + connect(container, &AbstractContainer::ready, this, doStartInContainer); #endif return true; } diff --git a/src/manager-lib/applicationmanager_p.h b/src/manager-lib/applicationmanager_p.h index 318898e0..9f769cf1 100644 --- a/src/manager-lib/applicationmanager_p.h +++ b/src/manager-lib/applicationmanager_p.h @@ -18,7 +18,7 @@ class ApplicationManagerPrivate { public: bool securityChecksEnabled = true; - bool singleProcess; + bool singleProcess = true; bool shuttingDown = false; bool windowManagerCompositorReady = false; QVariantMap systemProperties; diff --git a/src/manager-lib/intentaminterface.cpp b/src/manager-lib/intentaminterface.cpp index 9bf1fb5b..f62aae6f 100644 --- a/src/manager-lib/intentaminterface.cpp +++ b/src/manager-lib/intentaminterface.cpp @@ -641,7 +641,7 @@ IntentServerHandler::~IntentServerHandler() { IntentServer *is = IntentServer::instance(); - for (const auto &intent : m_registeredIntents) + for (const auto &intent : std::as_const(m_registeredIntents)) is->removeIntent(intent); delete m_intent; diff --git a/src/manager-lib/nativeruntime.cpp b/src/manager-lib/nativeruntime.cpp index a29b7e38..5fb9921b 100644 --- a/src/manager-lib/nativeruntime.cpp +++ b/src/manager-lib/nativeruntime.cpp @@ -175,7 +175,7 @@ bool NativeRuntime::initialize() } const QString launcherName = u"/appman-launcher-"_s + manager()->identifier(); - for (const QString &possibleLocation : possibleLocations) { + for (const QString &possibleLocation : std::as_const(possibleLocations)) { QFileInfo fi(possibleLocation + launcherName); if (fi.exists() && fi.isExecutable()) { diff --git a/src/manager-lib/nativeruntime.h b/src/manager-lib/nativeruntime.h index 898c9580..54a49362 100644 --- a/src/manager-lib/nativeruntime.h +++ b/src/manager-lib/nativeruntime.h @@ -75,8 +75,8 @@ signals: private slots: void onProcessStarted(); - void onProcessFinished(int exitCode, Am::ExitStatus status); - void onProcessError(Am::ProcessError error); + void onProcessFinished(int exitCode, QtAM::Am::ExitStatus status); + void onProcessError(QtAM::Am::ProcessError error); void onDBusPeerConnection(const QDBusConnection &connection); protected: diff --git a/src/manager-lib/notificationmanager.cpp b/src/manager-lib/notificationmanager.cpp index 13fea82a..d1f71d63 100644 --- a/src/manager-lib/notificationmanager.cpp +++ b/src/manager-lib/notificationmanager.cpp @@ -172,22 +172,22 @@ enum NMRoles struct NotificationData { - uint id; - Application *application; - uint priority; + uint id = 0; + Application *application = nullptr; + uint priority = 0; QString summary; QString body; QString category; QString iconUrl; QString imageUrl; - bool showActionIcons; + bool showActionIcons = false; QVariantList actions; // list of single element maps: text (as string)> - bool dismissOnAction; - bool isSticky; - bool isSystemNotification; - bool isShowingProgress; - qreal progress; - int timeout; + bool dismissOnAction = false; + bool isSticky = false; + bool isSystemNotification = false; + bool isShowingProgress = false; + qreal progress = 0.0; + int timeout = 0; QVariantMap extended; QTimer *timer = nullptr; @@ -221,7 +221,7 @@ public: void closeNotification(uint id, CloseReason reason); - NotificationManager *q; + NotificationManager *q = nullptr; QHash roleNames; QList notifications; }; diff --git a/src/manager-lib/packagemanager.cpp b/src/manager-lib/packagemanager.cpp index 7e150a66..5121684d 100644 --- a/src/manager-lib/packagemanager.cpp +++ b/src/manager-lib/packagemanager.cpp @@ -488,7 +488,7 @@ PackageManager::~PackageManager() Package *PackageManager::fromId(const QString &id) const { - for (auto package : d->packages) { + for (auto package : std::as_const(d->packages)) { if (package->id() == id) return package; } @@ -855,7 +855,9 @@ void PackageManager::cleanupBrokenInstallations() noexcept(false) if (!d->installationPath.isEmpty()) validPaths.insert(d->installationPath, QString()); - for (Package *pkg : d->packages) { // we want to detach here! + auto packages = d->packages; + packages.detach(); // we need to detach here, as the loop below might modify the list + for (Package *pkg : std::as_const(packages)) { const InstallationReport *ir = pkg->info()->installationReport(); if (ir) { bool valid = true; @@ -876,7 +878,7 @@ void PackageManager::cleanupBrokenInstallations() noexcept(false) break; } } - for (const QString &checkDir : checkDirs) { + for (const QString &checkDir : std::as_const(checkDirs)) { QFileInfo fi(checkDir); if (!fi.exists() || !fi.isDir() || !fi.isReadable()) { valid = false; @@ -1603,7 +1605,7 @@ bool PackageManager::validateDnsName(const QString &name, int minimalPartCount) } }; - for (const QString &part : parts) + for (const QString &part : std::as_const(parts)) partCheck(part); return true; diff --git a/src/manager-lib/processstatus.h b/src/manager-lib/processstatus.h index 237b3ede..1f15f40c 100644 --- a/src/manager-lib/processstatus.h +++ b/src/manager-lib/processstatus.h @@ -61,7 +61,7 @@ signals: void memoryReportingEnabledChanged(bool enabled); private slots: - void onRunStateChanged(Am::RunState state); + void onRunStateChanged(QtAM::Am::RunState state); private: void fetchReadings(); diff --git a/src/manager-lib/sudo.h b/src/manager-lib/sudo.h index f8cb502d..c13aebf1 100644 --- a/src/manager-lib/sudo.h +++ b/src/manager-lib/sudo.h @@ -84,7 +84,7 @@ private: int m_socket; QString m_errorString; QMutex m_mutex; - SudoServer *m_shortCircuit; + SudoServer *m_shortCircuit = nullptr; static SudoClient *s_instance; }; diff --git a/src/monitor-lib/processreader.h b/src/monitor-lib/processreader.h index 87cbc67a..12b693d3 100644 --- a/src/monitor-lib/processreader.h +++ b/src/monitor-lib/processreader.h @@ -23,7 +23,7 @@ class ProcessReader : public QObject { public: QMutex mutex; - qreal cpuLoad; + qreal cpuLoad = 0.0; struct Memory { quint32 totalVm = 0; quint32 totalRss = 0; diff --git a/src/monitor-lib/systemreader.h b/src/monitor-lib/systemreader.h index ba4a2633..4f09b9d0 100644 --- a/src/monitor-lib/systemreader.h +++ b/src/monitor-lib/systemreader.h @@ -159,7 +159,7 @@ signals: private: qreal m_warning = 75.0; qreal m_critical = 90.0; - quint64 m_memLimit; + quint64 m_memLimit = 0; bool hasMemoryLowWarning = false; bool hasMemoryCriticalWarning = false; std::unique_ptr m_threshold; diff --git a/src/plugins/bubblewrap-container-plugin/bubblewrapcontainer.cpp b/src/plugins/bubblewrap-container-plugin/bubblewrapcontainer.cpp index c1f9ca37..7fb90759 100644 --- a/src/plugins/bubblewrap-container-plugin/bubblewrapcontainer.cpp +++ b/src/plugins/bubblewrap-container-plugin/bubblewrapcontainer.cpp @@ -179,7 +179,8 @@ void BubblewrapContainerManager::setConfiguration(const QVariantMap &configurati if (it.value().metaType() == QMetaType(QMetaType::QVariantMap)) { QVariantMap valueMap = it.value().toMap(); for (auto vit = valueMap.constBegin(); vit != valueMap.constEnd(); ++vit ) { - for (const QString &value : variantToStringList(vit.value())) { + const auto valueList = variantToStringList(vit.value()); + for (const QString &value : valueList) { m_bwrapArguments += u"--"_s + it.key(); m_bwrapArguments += vit.key(); m_bwrapArguments += value; @@ -191,7 +192,8 @@ void BubblewrapContainerManager::setConfiguration(const QVariantMap &configurati if (it.value().metaType() == QMetaType(QMetaType::QVariantList)) { QVariantList valueList = it.value().toList(); for (auto vit = valueList.constBegin(); vit != valueList.constEnd(); ++vit ) { - for (const QString &value : variantToStringList(*vit)) { + const auto valueList = variantToStringList(*vit); + for (const QString &value : valueList) { m_bwrapArguments += u"--"_s + it.key(); m_bwrapArguments += value; } @@ -536,7 +538,8 @@ bool BubblewrapContainer::start(const QStringList &arguments, const QMap m_stdioRedirections; QMap m_debugWrapperEnvironment; QStringList m_debugWrapperCommand; @@ -79,7 +79,7 @@ private: bool m_hasExitCode = false; int m_exitCode = 0; - QProcess *m_process; + QProcess *m_process = nullptr; }; class BubblewrapContainerManager : public QObject, public ContainerManagerInterface diff --git a/src/shared-main-lib/frametimer.h b/src/shared-main-lib/frametimer.h index 77366a1a..0604d4e0 100644 --- a/src/shared-main-lib/frametimer.h +++ b/src/shared-main-lib/frametimer.h @@ -79,10 +79,10 @@ private: QTimer m_updateTimer; - qreal m_averageFps; - qreal m_minimumFps; - qreal m_maximumFps; - qreal m_jitterFps; + qreal m_averageFps = 0.0; + qreal m_minimumFps = 0.0; + qreal m_maximumFps = 0.0; + qreal m_jitterFps = 0.0; QMetaObject::Connection m_frameSwapConnection; diff --git a/src/shared-main-lib/monitormodel.h b/src/shared-main-lib/monitormodel.h index 24ea4048..05b16ad3 100644 --- a/src/shared-main-lib/monitormodel.h +++ b/src/shared-main-lib/monitormodel.h @@ -71,7 +71,7 @@ private: }; struct DataSource { - QObject *obj; + QObject *obj = nullptr; QVector roleNames; }; diff --git a/src/window-lib/windowmanager.cpp b/src/window-lib/windowmanager.cpp index 3aa85070..d743f3ea 100644 --- a/src/window-lib/windowmanager.cpp +++ b/src/window-lib/windowmanager.cpp @@ -298,7 +298,7 @@ void WindowManager::setSlowAnimations(bool slowAnimations) if (slowAnimations != d->slowAnimations) { d->slowAnimations = slowAnimations; - for (auto view : d->views) + for (auto *view : std::as_const(d->views)) updateViewSlowMode(view); // Update timer of the main, GUI, thread @@ -308,7 +308,8 @@ void WindowManager::setSlowAnimations(bool slowAnimations) RuntimeFactory::instance()->setSlowAnimations(d->slowAnimations); // Update already running applications - for (Application *application : ApplicationManager::instance()->applications()) { + const auto allApplications = ApplicationManager::instance()->applications(); + for (Application *application : allApplications) { auto runtime = application->currentRuntime(); if (runtime) runtime->setSlowAnimations(d->slowAnimations); @@ -521,7 +522,7 @@ Window *WindowManager::window(int index) const QList WindowManager::windowsOfApplication(const QString &id) const { QList result; - for (Window *window : d->windowsInModel) { + for (Window *window : std::as_const(d->windowsInModel)) { if (window->application() && window->application()->id() == id) result << window; } @@ -673,7 +674,7 @@ void WindowManager::registerCompositorView(QQuickWindow *view) emit internalSignals.compositorAboutToBeCreated(); d->waylandCompositor = new WaylandCompositor(view, d->waylandSocketName); - for (const auto &extraSocket : d->extraWaylandSockets) + for (const auto &extraSocket : std::as_const(d->extraWaylandSockets)) d->waylandCompositor->addSocketDescriptor(extraSocket); connect(d->waylandCompositor, &QWaylandCompositor::surfaceCreated, diff --git a/src/window-lib/windowmanager_p.h b/src/window-lib/windowmanager_p.h index 517c5b52..ddf10778 100644 --- a/src/window-lib/windowmanager_p.h +++ b/src/window-lib/windowmanager_p.h @@ -45,7 +45,7 @@ public: QList views; QString waylandSocketName; - QQmlEngine *qmlEngine; + QQmlEngine *qmlEngine = nullptr; }; QT_END_NAMESPACE_AM -- cgit v1.2.3