From 00d972fa4f458554cece7f66f1b43f00b0a5458c Mon Sep 17 00:00:00 2001 From: Marc Mutz Date: Thu, 22 Aug 2019 10:46:29 +0200 Subject: [PATCH 1/8] QReadWriteLock QT_NO_THREAD shell: make API compatible with the regular one - add missing explicit - drop static from member functions that aren't static in the regular version (ie. all functions) As a drive-by, remove redundant inline keyword where it doesn't cause wanton inconsistency with surrounding code. Change-Id: I5aed73c3afa85d98d97b57c2c1874b1a5e664960 Reviewed-by: Edward Welbourne Reviewed-by: Volker Hilsheimer --- src/corelib/thread/qreadwritelock.h | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/corelib/thread/qreadwritelock.h b/src/corelib/thread/qreadwritelock.h index 139fde9214..3c1ed91b94 100644 --- a/src/corelib/thread/qreadwritelock.h +++ b/src/corelib/thread/qreadwritelock.h @@ -183,15 +183,15 @@ public: inline explicit QReadWriteLock(RecursionMode = NonRecursive) noexcept { } inline ~QReadWriteLock() { } - static inline void lockForRead() noexcept { } - static inline bool tryLockForRead() noexcept { return true; } - static inline bool tryLockForRead(int timeout) noexcept { Q_UNUSED(timeout); return true; } + void lockForRead() noexcept { } + bool tryLockForRead() noexcept { return true; } + bool tryLockForRead(int timeout) noexcept { Q_UNUSED(timeout); return true; } - static inline void lockForWrite() noexcept { } - static inline bool tryLockForWrite() noexcept { return true; } - static inline bool tryLockForWrite(int timeout) noexcept { Q_UNUSED(timeout); return true; } + void lockForWrite() noexcept { } + bool tryLockForWrite() noexcept { return true; } + bool tryLockForWrite(int timeout) noexcept { Q_UNUSED(timeout); return true; } - static inline void unlock() noexcept { } + void unlock() noexcept { } private: Q_DISABLE_COPY(QReadWriteLock) @@ -200,12 +200,12 @@ private: class Q_CORE_EXPORT QReadLocker { public: - inline QReadLocker(QReadWriteLock *) noexcept { } + inline explicit QReadLocker(QReadWriteLock *) noexcept { } inline ~QReadLocker() noexcept { } - static inline void unlock() noexcept { } - static inline void relock() noexcept { } - static inline QReadWriteLock *readWriteLock() noexcept { return nullptr; } + void unlock() noexcept { } + void relock() noexcept { } + QReadWriteLock *readWriteLock() noexcept { return nullptr; } private: Q_DISABLE_COPY(QReadLocker) @@ -217,9 +217,9 @@ public: inline explicit QWriteLocker(QReadWriteLock *) noexcept { } inline ~QWriteLocker() noexcept { } - static inline void unlock() noexcept { } - static inline void relock() noexcept { } - static inline QReadWriteLock *readWriteLock() noexcept { return nullptr; } + void unlock() noexcept { } + void relock() noexcept { } + QReadWriteLock *readWriteLock() noexcept { return nullptr; } private: Q_DISABLE_COPY(QWriteLocker) From 4cc3615b4e3b48f8fda19f0165ad542da9b39768 Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Tue, 20 Aug 2019 10:06:29 +0300 Subject: [PATCH 2/8] Use QLatin1String where possible Change-Id: I8f94ba4880bcac735e4445d71f0e22774d9f78eb Reviewed-by: Marc Mutz --- src/tools/androiddeployqt/main.cpp | 229 ++++++++++++++--------------- 1 file changed, 114 insertions(+), 115 deletions(-) diff --git a/src/tools/androiddeployqt/main.cpp b/src/tools/androiddeployqt/main.cpp index 4c7b8a6917..4cba67051b 100644 --- a/src/tools/androiddeployqt/main.cpp +++ b/src/tools/androiddeployqt/main.cpp @@ -259,7 +259,7 @@ static QString shellQuoteUnix(const QString &arg) }; // 0-32 \'"$`<>|;&(){}*?#!~[] if (!arg.length()) - return QString::fromLatin1("\"\""); + return QLatin1String("\"\""); QString ret(arg); if (hasSpecialChars(ret, iqm)) { @@ -282,7 +282,7 @@ static QString shellQuoteWin(const QString &arg) }; if (!arg.length()) - return QString::fromLatin1("\"\""); + return QLatin1String("\"\""); QString ret(arg); if (hasSpecialChars(ret, iqm)) { @@ -324,11 +324,11 @@ QString fileArchitecture(const Options &options, const QString &path) if (!arch.isEmpty()) return arch; - QString readElf = QStringLiteral("%1/toolchains/%2/prebuilt/%3/bin/llvm-readobj").arg(options.ndkPath, + QString readElf = QLatin1String("%1/toolchains/%2/prebuilt/%3/bin/llvm-readobj").arg(options.ndkPath, options.toolchainPrefix, options.ndkHost); #if defined(Q_OS_WIN32) - readElf += QStringLiteral(".exe"); + readElf += QLatin1String(".exe"); #endif if (!QFile::exists(readElf)) { @@ -336,7 +336,7 @@ QString fileArchitecture(const Options &options, const QString &path) return {}; } - readElf = QStringLiteral("%1 -needed-libs %2").arg(shellQuote(readElf), shellQuote(path)); + readElf = QLatin1String("%1 -needed-libs %2").arg(shellQuote(readElf), shellQuote(path)); FILE *readElfCommand = openProcess(readElf); if (!readElfCommand) { @@ -524,7 +524,7 @@ Options parseOptions() } if (options.inputFileName.isEmpty()) - options.inputFileName = QString::fromLatin1("android-lib%1.so-deployment-settings.json").arg(QDir::current().dirName()); + options.inputFileName = QLatin1String("android-lib%1.so-deployment-settings.json").arg(QDir::current().dirName()); options.timing = qEnvironmentVariableIsSet("ANDROIDDEPLOYQT_TIMING_OUTPUT"); @@ -717,7 +717,7 @@ QString cleanPackageName(QString packageName) } } if (keywords.contains(word)) { - packageName.insert(next, QStringLiteral("_")); + packageName.insert(next, QLatin1String("_")); index = next + 1; } else { index = next; @@ -729,7 +729,7 @@ QString cleanPackageName(QString packageName) QString detectLatestAndroidPlatform(const QString &sdkPath) { - QDir dir(sdkPath + QStringLiteral("/platforms")); + QDir dir(sdkPath + QLatin1String("/platforms")); if (!dir.exists()) { fprintf(stderr, "Directory %s does not exist\n", qPrintable(dir.absolutePath())); return QString(); @@ -759,7 +759,7 @@ QString packageNameFromAndroidManifest(const QString &androidManifestPath) reader.attributes().value(QLatin1String("package")).toString()); } } - return QString(); + return {}; } bool readInputFile(Options *options) @@ -801,13 +801,13 @@ bool readInputFile(Options *options) { - const QJsonValue value = jsonObject.value(QStringLiteral("sdkBuildToolsRevision")); + const QJsonValue value = jsonObject.value(QLatin1String("sdkBuildToolsRevision")); if (!value.isUndefined()) options->sdkBuildToolsVersion = value.toString(); } { - const QJsonValue qtInstallDirectory = jsonObject.value(QStringLiteral("qt")); + const QJsonValue qtInstallDirectory = jsonObject.value(QLatin1String("qt")); if (qtInstallDirectory.isUndefined()) { fprintf(stderr, "No Qt directory in json file %s\n", qPrintable(options->inputFileName)); return false; @@ -824,13 +824,13 @@ bool readInputFile(Options *options) } { - const QJsonValue androidSourcesDirectory = jsonObject.value(QStringLiteral("android-package-source-directory")); + const QJsonValue androidSourcesDirectory = jsonObject.value(QLatin1String("android-package-source-directory")); if (!androidSourcesDirectory.isUndefined()) options->androidSourceDirectory = androidSourcesDirectory.toString(); } { - const QJsonValue androidVersionName = jsonObject.value(QStringLiteral("android-version-name")); + const QJsonValue androidVersionName = jsonObject.value(QLatin1String("android-version-name")); if (!androidVersionName.isUndefined()) options->versionName = androidVersionName.toString(); else @@ -838,7 +838,7 @@ bool readInputFile(Options *options) } { - const QJsonValue androidVersionCode = jsonObject.value(QStringLiteral("android-version-code")); + const QJsonValue androidVersionCode = jsonObject.value(QLatin1String("android-version-code")); if (!androidVersionCode.isUndefined()) options->versionCode = androidVersionCode.toString(); else @@ -846,7 +846,7 @@ bool readInputFile(Options *options) } { - const QJsonObject targetArchitectures = jsonObject.value(QStringLiteral("architectures")).toObject(); + const QJsonObject targetArchitectures = jsonObject.value(QLatin1String("architectures")).toObject(); if (targetArchitectures.isEmpty()) { fprintf(stderr, "No target architecture defined in json file.\n"); return false; @@ -863,7 +863,7 @@ bool readInputFile(Options *options) } { - const QJsonValue ndk = jsonObject.value(QStringLiteral("ndk")); + const QJsonValue ndk = jsonObject.value(QLatin1String("ndk")); if (ndk.isUndefined()) { fprintf(stderr, "No NDK path defined in json file.\n"); return false; @@ -872,7 +872,7 @@ bool readInputFile(Options *options) } { - const QJsonValue toolchainPrefix = jsonObject.value(QStringLiteral("toolchain-prefix")); + const QJsonValue toolchainPrefix = jsonObject.value(QLatin1String("toolchain-prefix")); if (toolchainPrefix.isUndefined()) { fprintf(stderr, "No toolchain prefix defined in json file.\n"); return false; @@ -881,7 +881,7 @@ bool readInputFile(Options *options) } { - const QJsonValue ndkHost = jsonObject.value(QStringLiteral("ndk-host")); + const QJsonValue ndkHost = jsonObject.value(QLatin1String("ndk-host")); if (ndkHost.isUndefined()) { fprintf(stderr, "No NDK host defined in json file.\n"); return false; @@ -890,19 +890,19 @@ bool readInputFile(Options *options) } { - const QJsonValue extraLibs = jsonObject.value(QStringLiteral("android-extra-libs")); + const QJsonValue extraLibs = jsonObject.value(QLatin1String("android-extra-libs")); if (!extraLibs.isUndefined()) options->extraLibs = extraLibs.toString().split(QLatin1Char(','), QString::SkipEmptyParts); } { - const QJsonValue extraPlugins = jsonObject.value(QStringLiteral("android-extra-plugins")); + const QJsonValue extraPlugins = jsonObject.value(QLatin1String("android-extra-plugins")); if (!extraPlugins.isUndefined()) options->extraPlugins = extraPlugins.toString().split(QLatin1Char(',')); } { - const QJsonValue stdcppPath = jsonObject.value(QStringLiteral("stdcpp-path")); + const QJsonValue stdcppPath = jsonObject.value(QLatin1String("stdcpp-path")); if (stdcppPath.isUndefined()) { fprintf(stderr, "No stdcpp-path defined in json file.\n"); return false; @@ -911,19 +911,19 @@ bool readInputFile(Options *options) } { - const QJsonValue qmlRootPath = jsonObject.value(QStringLiteral("qml-root-path")); + const QJsonValue qmlRootPath = jsonObject.value(QLatin1String("qml-root-path")); if (!qmlRootPath.isUndefined()) options->rootPath = qmlRootPath.toString(); } { - const QJsonValue qmlImportPaths = jsonObject.value(QStringLiteral("qml-import-paths")); + const QJsonValue qmlImportPaths = jsonObject.value(QLatin1String("qml-import-paths")); if (!qmlImportPaths.isUndefined()) options->qmlImportPaths = qmlImportPaths.toString().split(QLatin1Char(',')); } { - const QJsonValue applicationBinary = jsonObject.value(QStringLiteral("application-binary")); + const QJsonValue applicationBinary = jsonObject.value(QLatin1String("application-binary")); if (applicationBinary.isUndefined()) { fprintf(stderr, "No application binary defined in json file.\n"); return false; @@ -931,7 +931,7 @@ bool readInputFile(Options *options) options->applicationBinary = applicationBinary.toString(); if (options->build) { for (auto it = options->architectures.constBegin(); it != options->architectures.constEnd(); ++it) { - if (!QFile::exists(QStringLiteral("%1/libs/%2/lib%3_%2.so").arg(options->outputDirectory, it.key(), options->applicationBinary))) { + if (!QFile::exists(QLatin1String("%1/libs/%2/lib%3_%2.so").arg(options->outputDirectory, it.key(), options->applicationBinary))) { fprintf(stderr, "Cannot find application binary %s.\n", qPrintable(options->applicationBinary)); return false; } @@ -940,7 +940,7 @@ bool readInputFile(Options *options) } { - const QJsonValue deploymentDependencies = jsonObject.value(QStringLiteral("deployment-dependencies")); + const QJsonValue deploymentDependencies = jsonObject.value(QLatin1String("deployment-dependencies")); if (!deploymentDependencies.isUndefined()) { QString deploymentDependenciesString = deploymentDependencies.toString(); const auto dependencies = deploymentDependenciesString.splitRef(QLatin1Char(',')); @@ -975,9 +975,9 @@ bool readInputFile(Options *options) } } - options->packageName = packageNameFromAndroidManifest(options->androidSourceDirectory + QStringLiteral("/AndroidManifest.xml")); + options->packageName = packageNameFromAndroidManifest(options->androidSourceDirectory + QLatin1String("/AndroidManifest.xml")); if (options->packageName.isEmpty()) - options->packageName = cleanPackageName(QStringLiteral("org.qtproject.example.%1").arg(options->applicationBinary)); + options->packageName = cleanPackageName(QLatin1String("org.qtproject.example.%1").arg(options->applicationBinary)); return true; } @@ -993,7 +993,7 @@ bool copyFiles(const QDir &sourceDirectory, const QDir &destinationDirectory, co return false; } - if (!copyFiles(dir, QDir(destinationDirectory.path() + QStringLiteral("/") + dir.dirName()), options, forceOverwrite)) + if (!copyFiles(dir, QDir(destinationDirectory.path() + QLatin1Char('/') + dir.dirName()), options, forceOverwrite)) return false; } else { QString destination = destinationDirectory.absoluteFilePath(entry.fileName()); @@ -1107,13 +1107,13 @@ bool copyAndroidExtraLibs(Options *options) fprintf(stdout, "Skipping \"%s\", architecture mismatch.\n", qPrintable(extraLib)); continue; } - if (!extraLibInfo.fileName().startsWith(QStringLiteral("lib")) || extraLibInfo.suffix() != QStringLiteral("so")) { + if (!extraLibInfo.fileName().startsWith(QLatin1String("lib")) || extraLibInfo.suffix() != QLatin1String("so")) { fprintf(stderr, "The file name of external library %s must begin with \"lib\" and end with the suffix \".so\".\n", qPrintable(extraLib)); return false; } QString destinationFile(options->outputDirectory - + QStringLiteral("/libs/") + + QLatin1String("/libs/") + options->currentArchitecture + QLatin1Char('/') + extraLibInfo.fileName()); @@ -1157,19 +1157,19 @@ bool copyAndroidExtraResources(Options *options) } QDir resourceDir(extraResource); - QString assetsDir = options->outputDirectory + QStringLiteral("/assets/") + resourceDir.dirName() + QLatin1Char('/'); - QString libsDir = options->outputDirectory + QStringLiteral("/libs/") + options->currentArchitecture + QLatin1Char('/'); + QString assetsDir = options->outputDirectory + QLatin1String("/assets/") + resourceDir.dirName() + QLatin1Char('/'); + QString libsDir = options->outputDirectory + QLatin1String("/libs/") + options->currentArchitecture + QLatin1Char('/'); const QStringList files = allFilesInside(resourceDir, resourceDir); for (const QString &resourceFile : files) { QString originFile(resourceDir.filePath(resourceFile)); QString destinationFile; - if (!resourceFile.endsWith(QStringLiteral(".so"))) { + if (!resourceFile.endsWith(QLatin1String(".so"))) { destinationFile = assetsDir + resourceFile; } else { if (!checkArchitecture(*options, originFile)) continue; - destinationFile = libsDir + QStringLiteral("/lib") + QString(resourceDir.dirName() + QLatin1Char('/') + resourceFile).replace(QLatin1Char('/'), QLatin1Char('_')); + destinationFile = libsDir + QLatin1String("/lib") + QString(resourceDir.dirName() + QLatin1Char('/') + resourceFile).replace(QLatin1Char('/'), QLatin1Char('_')); options->archExtraPlugins[options->currentArchitecture] += resourceFile; } if (!copyFileIfNewer(originFile, destinationFile, *options)) @@ -1229,7 +1229,7 @@ bool updateLibsXml(Options *options) if (options->verbose) fprintf(stdout, " -- res/values/libs.xml\n"); - QString fileName = options->outputDirectory + QStringLiteral("/res/values/libs.xml"); + QString fileName = options->outputDirectory + QLatin1String("/res/values/libs.xml"); if (!QFile::exists(fileName)) { fprintf(stderr, "Cannot find %s in prepared packaged. This file is required.\n", qPrintable(fileName)); return false; @@ -1242,22 +1242,22 @@ bool updateLibsXml(Options *options) QString extraLibs; for (auto it = options->architectures.constBegin(); it != options->architectures.constEnd(); ++it) { - QString libsPath = QStringLiteral("libs/") + it.key() + QLatin1Char('/'); + QString libsPath = QLatin1String("libs/") + it.key() + QLatin1Char('/'); - qtLibs += QStringLiteral(" %1;%2\n").arg(it.key(), options->stdCppName); + qtLibs += QLatin1String(" %1;%2\n").arg(it.key(), options->stdCppName); for (const Options::BundledFile &bundledFile : options->bundledFiles[it.key()]) { - if (bundledFile.second.startsWith(QStringLiteral("lib/"))) { + if (bundledFile.second.startsWith(QLatin1String("lib/"))) { QString s = bundledFile.second.mid(sizeof("lib/lib") - 1); s.chop(sizeof(".so") - 1); - qtLibs += QStringLiteral(" %1;%2\n").arg(it.key(), s); + qtLibs += QLatin1String(" %1;%2\n").arg(it.key(), s); } else if (bundledFile.first.startsWith(libsPath)) { QString s = bundledFile.first.mid(libsPath.length()); bundledInLibs += QString::fromLatin1(" %1;%2:%3\n") .arg(it.key(), s, bundledFile.second); - } else if (bundledFile.first.startsWith(QStringLiteral("assets/"))) { + } else if (bundledFile.first.startsWith(QLatin1String("assets/"))) { QString s = bundledFile.first.mid(sizeof("assets/") - 1); bundledInAssets += QString::fromLatin1(" %1:%2\n") - .arg(s).arg(bundledFile.second); + .arg(s, bundledFile.second); } } @@ -1267,11 +1267,11 @@ bool updateLibsXml(Options *options) const QStringList files = allFilesInside(resourceDir, resourceDir); for (const QString &file : files) { QString destinationPath = resourceDir.dirName() + QLatin1Char('/') + file; - if (!file.endsWith(QStringLiteral(".so"))) { - bundledInAssets += QStringLiteral(" %1:%1\n") + if (!file.endsWith(QLatin1String(".so"))) { + bundledInAssets += QLatin1String(" %1:%1\n") .arg(destinationPath); } else { - bundledInLibs += QStringLiteral(" %1;lib%2:%3\n") + bundledInLibs += QLatin1String(" %1;lib%2:%3\n") .arg(it.key(), QString(destinationPath).replace(QLatin1Char('/'), QLatin1Char('_')), destinationPath); @@ -1285,7 +1285,7 @@ bool updateLibsXml(Options *options) QFileInfo extraLibInfo(extraLib); QString name = extraLibInfo.fileName().mid(sizeof("lib") - 1); name.chop(sizeof(".so") - 1); - extraLibs += QStringLiteral(" %1;%2").arg(it.key(), name); + extraLibs += QLatin1String(" %1;%2").arg(it.key(), name); } } @@ -1295,8 +1295,8 @@ bool updateLibsXml(Options *options) if (localLibs.isEmpty()) { QString plugin; for (const QtDependency &qtDependency : options->qtDependencies[it.key()]) { - if (qtDependency.relativePath.endsWith(QStringLiteral("libqtforandroid.so")) - || qtDependency.relativePath.endsWith(QStringLiteral("libqtforandroidGL.so"))) { + if (qtDependency.relativePath.endsWith(QLatin1String("libqtforandroid.so")) + || qtDependency.relativePath.endsWith(QLatin1String("libqtforandroidGL.so"))) { if (!plugin.isEmpty() && plugin != qtDependency.relativePath) { fprintf(stderr, "Both platform plugins libqtforandroid.so and libqtforandroidGL.so included in package. Please include only one.\n"); return false; @@ -1304,8 +1304,8 @@ bool updateLibsXml(Options *options) plugin = qtDependency.relativePath; } - if (qtDependency.relativePath.contains(QStringLiteral("libQt5OpenGL")) - || qtDependency.relativePath.contains(QStringLiteral("libQt5Quick"))) { + if (qtDependency.relativePath.contains(QLatin1String("libQt5OpenGL")) + || qtDependency.relativePath.contains(QLatin1String("libQt5Quick"))) { options->usesOpenGL |= true; break; } @@ -1322,8 +1322,8 @@ bool updateLibsXml(Options *options) if (options->verbose) fprintf(stdout, " -- Using platform plugin %s\n", qPrintable(plugin)); } - allLocalLibs += QStringLiteral(" %1;%2\n").arg(it.key(), localLibs.join(QLatin1Char(':')) - .replace(QStringLiteral("lib/"), QString{}) + allLocalLibs += QLatin1String(" %1;%2\n").arg(it.key(), localLibs.join(QLatin1Char(':')) + .replace(QLatin1String("lib/"), QString{}) .replace(QLatin1Char('/'), QLatin1Char('_'))); } @@ -1351,7 +1351,7 @@ bool updateStringsXml(const Options &options) QHash replacements; replacements[QStringLiteral("")] = options.applicationBinary; - QString fileName = options.outputDirectory + QStringLiteral("/res/values/strings.xml"); + QString fileName = options.outputDirectory + QLatin1String("/res/values/strings.xml"); if (!QFile::exists(fileName)) { if (options.verbose) fprintf(stdout, " -- Create strings.xml since it's missing.\n"); @@ -1387,22 +1387,22 @@ bool updateAndroidManifest(Options &options) replacements[QStringLiteral("-- %%INSERT_INIT_CLASSES%% --")] = options.initClasses.join(QLatin1Char(':')); replacements[QStringLiteral("-- %%INSERT_VERSION_NAME%% --")] = options.versionName; replacements[QStringLiteral("-- %%INSERT_VERSION_CODE%% --")] = options.versionCode; - replacements[QStringLiteral("package=\"org.qtproject.example\"")] = QStringLiteral("package=\"%1\"").arg(options.packageName); + replacements[QStringLiteral("package=\"org.qtproject.example\"")] = QLatin1String("package=\"%1\"").arg(options.packageName); replacements[QStringLiteral("-- %%BUNDLE_LOCAL_QT_LIBS%% --")] - = (options.deploymentMechanism == Options::Bundled) ? QStringLiteral("1") : QStringLiteral("0"); + = (options.deploymentMechanism == Options::Bundled) ? QLatin1String("1") : QLatin1String("0"); replacements[QStringLiteral("-- %%USE_LOCAL_QT_LIBS%% --")] - = (options.deploymentMechanism != Options::Ministro) ? QStringLiteral("1") : QStringLiteral("0"); + = (options.deploymentMechanism != Options::Ministro) ? QLatin1String("1") : QLatin1String("0"); QString permissions; for (const QString &permission : qAsConst(options.permissions)) - permissions += QStringLiteral(" \n").arg(permission); + permissions += QLatin1String(" \n").arg(permission); replacements[QStringLiteral("")] = permissions.trimmed(); QString features; for (const QString &feature : qAsConst(options.features)) - features += QStringLiteral(" \n").arg(feature); + features += QLatin1String(" \n").arg(feature); if (options.usesOpenGL) - features += QStringLiteral(" "); + features += QLatin1String(" "); replacements[QStringLiteral("")] = features.trimmed(); @@ -1522,7 +1522,7 @@ bool readAndroidDependencyXml(Options *options, QSet *usedDependencies, QSet *remainingDependencies) { - QString androidDependencyName = absoluteFilePath(options, QStringLiteral("/lib/%1-android-dependencies.xml").arg(moduleName)); + QString androidDependencyName = absoluteFilePath(options, QLatin1String("/lib/%1-android-dependencies.xml").arg(moduleName)); QFile androidDependencyFile(androidDependencyName); if (androidDependencyFile.exists()) { @@ -1593,7 +1593,7 @@ bool readAndroidDependencyXml(Options *options, } else if (!fileName.isEmpty()) { options->localLibs[options->currentArchitecture].append(fileName); } - if (fileName.endsWith(QStringLiteral(".so")) && checkArchitecture(*options, fileName)) { + if (fileName.endsWith(QLatin1String(".so")) && checkArchitecture(*options, fileName)) { remainingDependencies->insert(fileName); } } else if (reader.name() == QLatin1String("permission")) { @@ -1621,11 +1621,11 @@ bool readAndroidDependencyXml(Options *options, QStringList getQtLibsFromElf(const Options &options, const QString &fileName) { - QString readElf = QStringLiteral("%1/toolchains/%2/prebuilt/%3/bin/llvm-readobj").arg(options.ndkPath, + QString readElf = QLatin1String("%1/toolchains/%2/prebuilt/%3/bin/llvm-readobj").arg(options.ndkPath, options.toolchainPrefix, options.ndkHost); #if defined(Q_OS_WIN32) - readElf += QStringLiteral(".exe"); + readElf += QLatin1String(".exe"); #endif if (!QFile::exists(readElf)) { @@ -1633,7 +1633,7 @@ QStringList getQtLibsFromElf(const Options &options, const QString &fileName) return QStringList(); } - readElf = QStringLiteral("%1 -needed-libs %2").arg(shellQuote(readElf), shellQuote(fileName)); + readElf = QLatin1String("%1 -needed-libs %2").arg(shellQuote(readElf), shellQuote(fileName)); FILE *readElfCommand = openProcess(readElf); if (!readElfCommand) { @@ -1664,7 +1664,7 @@ QStringList getQtLibsFromElf(const Options &options, const QString &fileName) if (!line.startsWith("lib")) continue; library = QString::fromLatin1(line); - QString libraryName = QStringLiteral("lib/") + library; + QString libraryName = QLatin1String("lib/") + library; if (QFile::exists(absoluteFilePath(&options, libraryName))) ret += libraryName; } @@ -1751,9 +1751,8 @@ bool scanImports(Options *options, QSet *usedDependencies) for (const QString &qmlImportPath : qAsConst(options->qmlImportPaths)) importPaths += shellQuote(qmlImportPath); - qmlImportScanner += QString::fromLatin1(" -rootPath %1 -importPath %2") - .arg(shellQuote(rootPath)) - .arg(importPaths.join(QLatin1Char(' '))); + qmlImportScanner += QLatin1String(" -rootPath %1 -importPath %2") + .arg(shellQuote(rootPath), importPaths.join(QLatin1Char(' '))); if (options->verbose) { fprintf(stdout, "Running qmlimportscanner with the following command: %s\n", @@ -1846,10 +1845,10 @@ bool scanImports(Options *options, QSet *usedDependencies) fprintf(stdout, " -- Appending dependency found by qmlimportscanner: %s\n", qPrintable(fileName.absolutePath)); // Put all imports in default import path in assets - fileName.relativePath.prepend(QStringLiteral("qml/")); + fileName.relativePath.prepend(QLatin1String("qml/")); options->qtDependencies[options->currentArchitecture].append(fileName); - if (fileName.absolutePath.endsWith(QStringLiteral(".so")) && checkArchitecture(*options, fileName.absolutePath)) { + if (fileName.absolutePath.endsWith(QLatin1String(".so")) && checkArchitecture(*options, fileName.absolutePath)) { QSet remainingDependencies; if (!readDependenciesFromElf(options, fileName.absolutePath, usedDependencies, &remainingDependencies)) return false; @@ -1878,7 +1877,7 @@ bool readDependencies(Options *options) QSet remainingDependencies; // Add dependencies of application binary first - if (!readDependenciesFromElf(options, QStringLiteral("%1/libs/%2/lib%3_%2.so").arg(options->outputDirectory, options->currentArchitecture, options->applicationBinary), &usedDependencies, &remainingDependencies)) + if (!readDependenciesFromElf(options, QLatin1String("%1/libs/%2/lib%3_%2.so").arg(options->outputDirectory, options->currentArchitecture, options->applicationBinary), &usedDependencies, &remainingDependencies)) return false; while (!remainingDependencies.isEmpty()) { @@ -1926,10 +1925,10 @@ bool containsApplicationBinary(Options *options) fprintf(stdout, "Checking if application binary is in package.\n"); QFileInfo applicationBinary(options->applicationBinary); - QString applicationFileName = QStringLiteral("lib%1_%2.so").arg(options->applicationBinary, + QString applicationFileName = QLatin1String("lib%1_%2.so").arg(options->applicationBinary, options->currentArchitecture); - QString applicationPath = QStringLiteral("%1/libs/%2/%3").arg(options->outputDirectory, + QString applicationPath = QLatin1String("%1/libs/%2/%3").arg(options->outputDirectory, options->currentArchitecture, applicationFileName); if (!QFile::exists(applicationPath)) { @@ -1962,7 +1961,7 @@ FILE *runAdb(const Options &options, const QString &arguments) if (!options.installLocation.isEmpty()) installOption = QLatin1String(" -s ") + shellQuote(options.installLocation); - adb = QString::fromLatin1("%1%2 %3").arg(shellQuote(adb)).arg(installOption).arg(arguments); + adb = QLatin1String("%1%2 %3").arg(shellQuote(adb), installOption, arguments); if (options.verbose) fprintf(stdout, "Running command \"%s\"\n", adb.toLocal8Bit().constData()); @@ -2012,24 +2011,24 @@ bool copyQtFiles(Options *options) if (!options->build) return true; + QString libsDirectory = QLatin1String("libs/"); - // Copy other Qt dependencies - QString assetsDestinationDirectory = QStringLiteral("assets/--Added-by-androiddeployqt--/"); + auto assetsDestinationDirectory = QLatin1String("assets/--Added-by-androiddeployqt--/"); for (const QtDependency &qtDependency : qAsConst(options->qtDependencies[options->currentArchitecture])) { QString sourceFileName = qtDependency.absolutePath; QString destinationFileName; - if (qtDependency.relativePath.endsWith(QStringLiteral(".so"))) { + if (qtDependency.relativePath.endsWith(QLatin1String(".so"))) { QString garbledFileName; - if (qtDependency.relativePath.startsWith(QStringLiteral("lib/"))) { + if (qtDependency.relativePath.startsWith(QLatin1String("lib/"))) { garbledFileName = qtDependency.relativePath.mid(sizeof("lib/") - 1); } else { garbledFileName = QString(qtDependency.relativePath).replace(QLatin1Char('/'), QLatin1Char('_')); } destinationFileName = libsDirectory + options->currentArchitecture + QLatin1Char('/') + garbledFileName; - } else if (qtDependency.relativePath.startsWith(QStringLiteral("jar/"))) { + } else if (qtDependency.relativePath.startsWith(QLatin1String("jar/"))) { destinationFileName = libsDirectory + qtDependency.relativePath.mid(sizeof("jar/") - 1); } else { destinationFileName = assetsDestinationDirectory + qtDependency.relativePath; @@ -2118,7 +2117,7 @@ bool createAndroidProject(const Options &options) return false; } - QString androidTool = QString::fromLatin1("%1 update project --path %2 --target %3 --name QtApp") + QString androidTool = QLatin1String("%1 update project --path %2 --target %3 --name QtApp") .arg(shellQuote(androidToolExecutable)) .arg(shellQuote(options.outputDirectory)) .arg(shellQuote(options.androidPlatform)); @@ -2140,7 +2139,7 @@ bool createAndroidProject(const Options &options) if (options.verbose) fprintf(stdout, "Updating subproject %s\n", qPrintable(libraryProject)); - androidTool = QString::fromLatin1("%1 update lib-project --path %2 --target %3") + androidTool = QLatin1String("%1 update lib-project --path %2 --target %3") .arg(shellQuote(androidToolExecutable)) .arg(shellQuote(libraryProject)) .arg(shellQuote(options.androidPlatform)); @@ -2272,7 +2271,7 @@ bool buildAndroidProject(const Options &options) return false; } - QString commandLine = QString::fromLatin1("%1 --no-daemon %2").arg(shellQuote(gradlePath)).arg(options.releasePackage ? QLatin1String(" assembleRelease") : QLatin1String(" assembleDebug")); + QString commandLine = QLatin1String("%1 --no-daemon %2").arg(shellQuote(gradlePath), options.releasePackage ? QLatin1String(" assembleRelease") : QLatin1String(" assembleDebug")); if (options.verbose) commandLine += QLatin1String(" --info"); @@ -2407,7 +2406,7 @@ bool copyStdCpp(Options *options) if (options->verbose) fprintf(stdout, "Copying STL library\n"); - QString stdCppPath = QStringLiteral("%1/%2/lib%3.so").arg(options->stdCppPath, options->architectures[options->currentArchitecture], options->stdCppName); + QString stdCppPath = QLatin1String("%1/%2/lib%3.so").arg(options->stdCppPath, options->architectures[options->currentArchitecture], options->stdCppName); if (!QFile::exists(stdCppPath)) { fprintf(stderr, "STL library does not exist at %s\n", qPrintable(stdCppPath)); fflush(stdout); @@ -2415,7 +2414,7 @@ bool copyStdCpp(Options *options) return false; } - const QString destinationFile = QStringLiteral("%1/libs/%2/lib%3.so").arg(options->outputDirectory, + const QString destinationFile = QLatin1String("%1/libs/%2/lib%3.so").arg(options->outputDirectory, options->currentArchitecture, options->stdCppName); return copyFileIfNewer(stdCppPath, destinationFile, *options); @@ -2432,9 +2431,9 @@ bool jarSignerSignPackage(const Options &options) jdkPath = QString::fromLocal8Bit(qgetenv("JAVA_HOME")); #if defined(Q_OS_WIN32) - QString jarSignerTool = QString::fromLatin1("jarsigner.exe"); + QString jarSignerTool = QLatin1String("jarsigner.exe"); #else - QString jarSignerTool = QString::fromLatin1("jarsigner"); + QString jarSignerTool = QLatin1String("jarsigner"); #endif if (jdkPath.isEmpty() || !QFile::exists(jdkPath + QLatin1String("/bin/") + jarSignerTool)) @@ -2447,29 +2446,29 @@ bool jarSignerSignPackage(const Options &options) return false; } - jarSignerTool = QString::fromLatin1("%1 -sigalg %2 -digestalg %3 -keystore %4") - .arg(shellQuote(jarSignerTool)).arg(shellQuote(options.sigAlg)).arg(shellQuote(options.digestAlg)).arg(shellQuote(options.keyStore)); + jarSignerTool = QLatin1String("%1 -sigalg %2 -digestalg %3 -keystore %4") + .arg(shellQuote(jarSignerTool), shellQuote(options.sigAlg), shellQuote(options.digestAlg), shellQuote(options.keyStore)); if (!options.keyStorePassword.isEmpty()) - jarSignerTool += QString::fromLatin1(" -storepass %1").arg(shellQuote(options.keyStorePassword)); + jarSignerTool += QLatin1String(" -storepass %1").arg(shellQuote(options.keyStorePassword)); if (!options.storeType.isEmpty()) - jarSignerTool += QString::fromLatin1(" -storetype %1").arg(shellQuote(options.storeType)); + jarSignerTool += QLatin1String(" -storetype %1").arg(shellQuote(options.storeType)); if (!options.keyPass.isEmpty()) - jarSignerTool += QString::fromLatin1(" -keypass %1").arg(shellQuote(options.keyPass)); + jarSignerTool += QLatin1String(" -keypass %1").arg(shellQuote(options.keyPass)); if (!options.sigFile.isEmpty()) - jarSignerTool += QString::fromLatin1(" -sigfile %1").arg(shellQuote(options.sigFile)); + jarSignerTool += QLatin1String(" -sigfile %1").arg(shellQuote(options.sigFile)); if (!options.signedJar.isEmpty()) - jarSignerTool += QString::fromLatin1(" -signedjar %1").arg(shellQuote(options.signedJar)); + jarSignerTool += QLatin1String(" -signedjar %1").arg(shellQuote(options.signedJar)); if (!options.tsaUrl.isEmpty()) - jarSignerTool += QString::fromLatin1(" -tsa %1").arg(shellQuote(options.tsaUrl)); + jarSignerTool += QLatin1String(" -tsa %1").arg(shellQuote(options.tsaUrl)); if (!options.tsaCert.isEmpty()) - jarSignerTool += QString::fromLatin1(" -tsacert %1").arg(shellQuote(options.tsaCert)); + jarSignerTool += QLatin1String(" -tsacert %1").arg(shellQuote(options.tsaCert)); if (options.internalSf) jarSignerTool += QLatin1String(" -internalsf"); @@ -2480,7 +2479,7 @@ bool jarSignerSignPackage(const Options &options) if (options.protectedAuthenticationPath) jarSignerTool += QLatin1String(" -protected"); - jarSignerTool += QString::fromLatin1(" %1 %2") + jarSignerTool += QLatin1String(" %1 %2") .arg(apkPath(options, UnsignedAPK)) .arg(shellQuote(options.keyStoreAlias)); @@ -2520,11 +2519,11 @@ bool jarSignerSignPackage(const Options &options) } } - zipAlignTool = QString::fromLatin1("%1%2 -f 4 %3 %4") - .arg(shellQuote(zipAlignTool)) - .arg(options.verbose ? QString::fromLatin1(" -v") : QString()) - .arg(apkPath(options, UnsignedAPK)) - .arg(apkPath(options, SignedAPK)); + zipAlignTool = QLatin1String("%1%2 -f 4 %3 %4") + .arg(shellQuote(zipAlignTool), + options.verbose ? QLatin1String(" -v") : QLatin1String(), + apkPath(options, UnsignedAPK), + apkPath(options, SignedAPK)); FILE *zipAlignCommand = openProcess(zipAlignTool); if (zipAlignCommand == 0) { @@ -2575,11 +2574,11 @@ bool signPackage(const Options &options) } } - zipAlignTool = QString::fromLatin1("%1%2 -f 4 %3 %4") - .arg(shellQuote(zipAlignTool)) - .arg(options.verbose ? QString::fromLatin1(" -v") : QString()) - .arg(apkPath(options, UnsignedAPK)) - .arg(apkPath(options, SignedAPK)); + zipAlignTool = QLatin1String("%1%2 -f 4 %3 %4") + .arg(shellQuote(zipAlignTool), + options.verbose ? QLatin1String(" -v") : QLatin1String(), + apkPath(options, UnsignedAPK), + apkPath(options, SignedAPK)); FILE *zipAlignCommand = openProcess(zipAlignTool); if (zipAlignCommand == 0) { @@ -2599,22 +2598,22 @@ bool signPackage(const Options &options) return false; } - QString apkSignerCommandLine = QString::fromLatin1("%1 sign --ks %2") - .arg(shellQuote(apksignerTool)).arg(shellQuote(options.keyStore)); + QString apkSignerCommandLine = QLatin1String("%1 sign --ks %2") + .arg(shellQuote(apksignerTool), shellQuote(options.keyStore)); if (!options.keyStorePassword.isEmpty()) - apkSignerCommandLine += QString::fromLatin1(" --ks-pass pass:%1").arg(shellQuote(options.keyStorePassword)); + apkSignerCommandLine += QLatin1String(" --ks-pass pass:%1").arg(shellQuote(options.keyStorePassword)); if (!options.keyStoreAlias.isEmpty()) - apkSignerCommandLine += QString::fromLatin1(" --ks-key-alias %1").arg(shellQuote(options.keyStoreAlias)); + apkSignerCommandLine += QLatin1String(" --ks-key-alias %1").arg(shellQuote(options.keyStoreAlias)); if (!options.keyPass.isEmpty()) - apkSignerCommandLine += QString::fromLatin1(" --key-pass pass:%1").arg(shellQuote(options.keyPass)); + apkSignerCommandLine += QLatin1String(" --key-pass pass:%1").arg(shellQuote(options.keyPass)); if (options.verbose) apkSignerCommandLine += QLatin1String(" --verbose"); - apkSignerCommandLine += QString::fromLatin1(" %1") + apkSignerCommandLine += QLatin1String(" %1") .arg(apkPath(options, SignedAPK)); auto apkSignerRunner = [&] { @@ -2642,8 +2641,8 @@ bool signPackage(const Options &options) if (!apkSignerRunner()) return false; - apkSignerCommandLine = QString::fromLatin1("%1 verify --verbose %2") - .arg(shellQuote(apksignerTool)).arg(apkPath(options, SignedAPK)); + apkSignerCommandLine = QLatin1String("%1 verify --verbose %2") + .arg(shellQuote(apksignerTool), apkPath(options, SignedAPK)); // Verify the package and remove the unsigned apk return apkSignerRunner() && QFile::remove(apkPath(options, UnsignedAPK)); @@ -2672,7 +2671,7 @@ bool generateAssetsFileList(const Options &options) const QString name = dirIterator.next().mid(assetsPath.length()); int slashIndex = name.lastIndexOf(QLatin1Char('/')); - QString pathName = slashIndex >= 0 ? name.left(slashIndex) : QString::fromLatin1("/"); + QString pathName = slashIndex >= 0 ? name.left(slashIndex) : QStringLiteral("/"); QString fileName = slashIndex >= 0 ? name.mid(pathName.length() + 1) : name; if (!fileName.isEmpty() && dirIterator.fileInfo().isDir() && !fileName.endsWith(QLatin1Char('/'))) From 3542fc4958918dc855f2e867eccb880daa621069 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 26 Aug 2019 16:23:46 +0200 Subject: [PATCH 3/8] widgets: Simplify QWidgetRepaintManager::flush Change-Id: Icba88fa068aac2ac5d8bb04e46a3e3f34e279a48 Reviewed-by: Paul Olav Tvete --- src/widgets/kernel/qwidgetrepaintmanager.cpp | 13 ++++--------- src/widgets/kernel/qwidgetrepaintmanager_p.h | 2 +- 2 files changed, 5 insertions(+), 10 deletions(-) diff --git a/src/widgets/kernel/qwidgetrepaintmanager.cpp b/src/widgets/kernel/qwidgetrepaintmanager.cpp index 11647ae05e..6b5ca4b594 100644 --- a/src/widgets/kernel/qwidgetrepaintmanager.cpp +++ b/src/widgets/kernel/qwidgetrepaintmanager.cpp @@ -1063,17 +1063,15 @@ void QWidgetRepaintManager::markNeedsFlush(QWidget *widget, const QRegion ®io /*! Flushes the contents of the backing store into the top-level widget. - If the \a widget is non-zero, the content is flushed to the \a widget. */ -void QWidgetRepaintManager::flush(QWidget *widget) +void QWidgetRepaintManager::flush() { const bool hasNeedsFlushWidgets = !needsFlushWidgets.isEmpty(); bool flushed = false; // Flush the top level widget if (!topLevelNeedsFlush.isEmpty()) { - QWidget *target = widget ? widget : tlw; - flush(target, topLevelNeedsFlush, widgetTexturesFor(tlw, tlw)); + flush(tlw, topLevelNeedsFlush, widgetTexturesFor(tlw, tlw)); topLevelNeedsFlush = QRegion(); flushed = true; } @@ -1082,11 +1080,8 @@ void QWidgetRepaintManager::flush(QWidget *widget) if (!flushed && !hasNeedsFlushWidgets) { #ifndef QT_NO_OPENGL if (!tlw->d_func()->topData()->widgetTextures.empty()) { - QPlatformTextureList *widgetTextures = widgetTexturesFor(tlw, tlw); - if (widgetTextures) { - QWidget *target = widget ? widget : tlw; - flush(target, QRegion(), widgetTextures); - } + if (QPlatformTextureList *widgetTextures = widgetTexturesFor(tlw, tlw)) + flush(tlw, QRegion(), widgetTextures); } #endif } diff --git a/src/widgets/kernel/qwidgetrepaintmanager_p.h b/src/widgets/kernel/qwidgetrepaintmanager_p.h index e81eee0816..d7e38a9d69 100644 --- a/src/widgets/kernel/qwidgetrepaintmanager_p.h +++ b/src/widgets/kernel/qwidgetrepaintmanager_p.h @@ -115,7 +115,7 @@ private: void markNeedsFlush(QWidget *widget, const QRegion ®ion = QRegion()); - void flush(QWidget *widget = nullptr); + void flush(); void flush(QWidget *widget, const QRegion ®ion, QPlatformTextureList *widgetTextures); bool isDirty() const; From 3db14b5bd38001eea3e61009c2b7c108eced54dc Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Mon, 19 Aug 2019 11:42:51 +0300 Subject: [PATCH 4/8] Say hello to -android-abis configure param This configure parameter is useful to compile Qt only for a selected ABIs. The old parameter, -android-arch, does the same thing, it's kept for compatibility. [ChangeLog][Android] -android-abis configure script parameter useful to compile Qt only for a selected Android ABIs. Change-Id: I1f418c7e0914dd83b98d763e8cd8c09841e20fdf Reviewed-by: Eskil Abrahamsen Blomfeldt --- config_help.txt | 4 ++-- configure.json | 1 + configure.pri | 11 ++++++----- mkspecs/android-clang/qmake.conf | 4 +++- 4 files changed, 12 insertions(+), 8 deletions(-) diff --git a/config_help.txt b/config_help.txt index 3f31fd351f..5880c1e00d 100644 --- a/config_help.txt +++ b/config_help.txt @@ -203,8 +203,8 @@ Build environment: -android-ndk-platform Set Android platform -android-ndk-host .... Set Android NDK host (linux-x86, linux-x86_64, etc.) [$ANDROID_NDK_HOST] - -android-arch ........ Set Android architecture (armeabi, armeabi-v7a, - arm64-v8a, x86, x86_64) + -android-abis ....... Comma separated Android abis, default is: + armeabi-v7a,arm64-v8a,x86,x86_64 -android-toolchain-version ... Set Android toolchain version -android-style-assets Automatically extract style assets from the device at run time. This option makes the Android style behave diff --git a/configure.json b/configure.json index 6a7b5924cd..c6ea80b076 100644 --- a/configure.json +++ b/configure.json @@ -51,6 +51,7 @@ "translationdir": "string", "android-arch": "string", + "android-abis": "string", "android-ndk": "string", "android-ndk-host": "string", "android-ndk-platform": "string", diff --git a/configure.pri b/configure.pri index cbd11c2f67..d803dcf086 100644 --- a/configure.pri +++ b/configure.pri @@ -618,10 +618,11 @@ defineTest(qtConfOutput_prepareOptions) { qtConfFatalError("Specified Android NDK host is invalid.") } - target_arch = $$eval(config.input.android-arch) - isEmpty(target_arch): \ - target_arch = armeabi-v7a - + android_abis = $$eval(config.input.android-abis) + isEmpty(android_abis): \ + android_abis = $$eval(config.input.android-arch) + isEmpty(android_abis): \ + android_abis = armeabi-v7a,arm64-v8a,x86,x86_64 platform = $$eval(config.input.android-ndk-platform) isEmpty(platform): \ platform = android-21 @@ -631,7 +632,7 @@ defineTest(qtConfOutput_prepareOptions) { "DEFAULT_ANDROID_NDK_ROOT = $$val_escape(ndk_root)" \ "DEFAULT_ANDROID_PLATFORM = $$platform" \ "DEFAULT_ANDROID_NDK_HOST = $$ndk_host" \ - "DEFAULT_ANDROID_TARGET_ARCH = $$target_arch" \ + "DEFAULT_ANDROID_ABIS = $$split(android_abis, ',')" \ "DEFAULT_ANDROID_NDK_TOOLCHAIN_VERSION = $$ndk_tc_ver" } diff --git a/mkspecs/android-clang/qmake.conf b/mkspecs/android-clang/qmake.conf index 8252f400a1..21847cdc7c 100644 --- a/mkspecs/android-clang/qmake.conf +++ b/mkspecs/android-clang/qmake.conf @@ -37,7 +37,9 @@ isEmpty(ANDROID_SDK_BUILD_TOOLS_REVISION) { } } -ALL_ANDROID_ABIS = arm64-v8a armeabi-v7a x86_64 x86 +ALL_ANDROID_ABIS = $$(ALL_ANDROID_ABIS) +isEmpty(ALL_ANDROID_ABIS): ALL_ANDROID_ABIS = $$DEFAULT_ANDROID_ABIS +isEmpty(ALL_ANDROID_ABIS): ALL_ANDROID_ABIS = arm64-v8a armeabi-v7a x86_64 x86 CONFIG += $$ANDROID_PLATFORM From 0315e1945e0f385106e01ef151e934c29434903b Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Mon, 26 Aug 2019 13:02:31 +0300 Subject: [PATCH 5/8] Android: install qmlfiles only for first ABI MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit qmlfiles are the same for all ABIs, and installing them for all leads to race condition Change-Id: I69fe062f59f1d7c028dff5212e2f2fac7e71398d Reviewed-by: Jörg Bornemann --- mkspecs/features/qml_module.prf | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/mkspecs/features/qml_module.prf b/mkspecs/features/qml_module.prf index 57cfec78b3..c0b50416c9 100644 --- a/mkspecs/features/qml_module.prf +++ b/mkspecs/features/qml_module.prf @@ -52,15 +52,26 @@ builtin_resources { qmldir.base = $$qmldir_path qmldir.files = $$qmldir_file qmldir.path = $$[QT_INSTALL_QML]/$$TARGETPATH -INSTALLS += qmldir qmlfiles.base = $$_PRO_FILE_PWD_ qmlfiles.files = $$fq_aux_qml_files install_qml_files: qmlfiles.files += $$fq_qml_files qmlfiles.path = $${qmldir.path} -INSTALLS += qmlfiles -!debug_and_release|!build_all|CONFIG(release, debug|release) { +INSTALL_QML_FILES = false + +android { + build_pass { + isEmpty(ANDROID_ABIS): ANDROID_ABIS = $$ALL_ANDROID_ABIS + ABI = $$first(ANDROID_ABIS) + equals(ABI, $$QT_ARCH): INSTALL_QML_FILES = true + } +} else: !debug_and_release|!build_all|CONFIG(release, debug|release): INSTALL_QML_FILES = true + +equals(INSTALL_QML_FILES, true) { + INSTALLS += qmldir + INSTALLS += qmlfiles + !prefix_build { COPIES += qmldir qmlfiles } else { From 271d3bae38ffa009f9718ffdd3a808cc75163a3a Mon Sep 17 00:00:00 2001 From: Christian Ehrlicher Date: Mon, 26 Aug 2019 19:50:03 +0200 Subject: [PATCH 6/8] QGraphicsItem: mark GraphicsItemChange::ItemMatrixChange as deprecated The enum GraphicsItemChange::ItemMatrixChange is deprecated since Qt4 times. The corresponding matrix functions were also marked as deprecated in 5.13 but the enum was forgotten. Therefore also mark it as deprecated so it can be removed with Qt6. Change-Id: I39bec89af14aaefe2e504f5a890ef314574766a1 Reviewed-by: Andreas Aardal Hanssen --- src/widgets/graphicsview/qgraphicsitem.cpp | 2 ++ src/widgets/graphicsview/qgraphicsitem.h | 6 ++++-- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp index 6273de56a6..bb00db4c01 100644 --- a/src/widgets/graphicsview/qgraphicsitem.cpp +++ b/src/widgets/graphicsview/qgraphicsitem.cpp @@ -11523,9 +11523,11 @@ QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemChange change) case QGraphicsItem::ItemFlagsHaveChanged: str = "ItemFlagsHaveChanged"; break; +#if QT_DEPRECATED_SINCE(5, 14) case QGraphicsItem::ItemMatrixChange: str = "ItemMatrixChange"; break; +#endif case QGraphicsItem::ItemParentChange: str = "ItemParentChange"; break; diff --git a/src/widgets/graphicsview/qgraphicsitem.h b/src/widgets/graphicsview/qgraphicsitem.h index 7dd4441ae9..d66a4917e5 100644 --- a/src/widgets/graphicsview/qgraphicsitem.h +++ b/src/widgets/graphicsview/qgraphicsitem.h @@ -110,8 +110,10 @@ public: enum GraphicsItemChange { ItemPositionChange, - ItemMatrixChange, - ItemVisibleChange, +#if QT_DEPRECATED_SINCE(5, 14) + ItemMatrixChange Q_DECL_ENUMERATOR_DEPRECATED_X("Use ItemTransformChange instead"), +#endif + ItemVisibleChange = 2, ItemEnabledChange, ItemSelectedChange, ItemParentChange, From 984df39c79e6129250fd0f8516fbfb2e28bcefd7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 26 Aug 2019 17:34:35 +0200 Subject: [PATCH 7/8] widgets: Add logging for widget painting Change-Id: I551ec290812369e3848c1096fed7e813cd9e1cd6 Reviewed-by: Paul Olav Tvete --- src/widgets/kernel/qwidget.cpp | 8 ++++++- src/widgets/kernel/qwidget_p.h | 2 ++ src/widgets/kernel/qwidgetrepaintmanager.cpp | 24 ++++++++++++++++++++ src/widgets/kernel/qwidgetrepaintmanager_p.h | 3 +++ 4 files changed, 36 insertions(+), 1 deletion(-) diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 9e8c0cb500..45be132e59 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -119,6 +119,8 @@ QT_BEGIN_NAMESPACE +Q_LOGGING_CATEGORY(lcWidgetPainting, "qt.widgets.painting", QtWarningMsg); + static inline bool qRectIntersects(const QRect &r1, const QRect &r2) { return (qMax(r1.left(), r2.left()) <= qMin(r1.right(), r2.right()) && @@ -5273,10 +5275,14 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP if (rgn.isEmpty()) return; + Q_Q(QWidget); + + qCInfo(lcWidgetPainting) << "Drawing" << rgn << "of" << q << "at" << offset + << "into paint device" << pdev << "with" << flags; + const bool asRoot = flags & DrawAsRoot; bool onScreen = shouldPaintOnScreen(); - Q_Q(QWidget); #if QT_CONFIG(graphicseffect) if (graphicsEffect && graphicsEffect->isEnabled()) { QGraphicsEffectSource *source = graphicsEffect->d_func()->source; diff --git a/src/widgets/kernel/qwidget_p.h b/src/widgets/kernel/qwidget_p.h index 7d8a3ae737..698928b0b0 100644 --- a/src/widgets/kernel/qwidget_p.h +++ b/src/widgets/kernel/qwidget_p.h @@ -80,6 +80,8 @@ QT_BEGIN_NAMESPACE +Q_DECLARE_LOGGING_CATEGORY(lcWidgetPainting); + // Extra QWidget data // - to minimize memory usage for members that are seldom used. // - top-level widgets have extra extra data to reduce cost further diff --git a/src/widgets/kernel/qwidgetrepaintmanager.cpp b/src/widgets/kernel/qwidgetrepaintmanager.cpp index 6b5ca4b594..d1ebf7dc25 100644 --- a/src/widgets/kernel/qwidgetrepaintmanager.cpp +++ b/src/widgets/kernel/qwidgetrepaintmanager.cpp @@ -206,6 +206,9 @@ static inline QRect widgetRectFor(QWidget *widget, const QRegion &) { return wid template void QWidgetRepaintManager::markDirty(const T &r, QWidget *widget, UpdateTime updateTime, BufferState bufferState) { + qCInfo(lcWidgetPainting) << "Marking" << r << "of" << widget << "dirty" + << "with" << updateTime; + Q_ASSERT(tlw->d_func()->extra); Q_ASSERT(tlw->d_func()->extra->topextra); Q_ASSERT(!tlw->d_func()->extra->topextra->inTopLevelResize); @@ -370,6 +373,8 @@ void QWidgetRepaintManager::sendUpdateRequest(QWidget *widget, UpdateTime update if (!widget) return; + qCInfo(lcWidgetPainting) << "Sending update request to" << widget << "with" << updateTime; + #ifndef QT_NO_OPENGL // Having every repaint() leading to a sync/flush is bad as it causes // compositing and waiting for vsync each and every time. Change to @@ -713,6 +718,8 @@ static QPlatformTextureList *widgetTexturesFor(QWidget *tlw, QWidget *widget) */ void QWidgetRepaintManager::sync(QWidget *exposedWidget, const QRegion &exposedRegion) { + qCInfo(lcWidgetPainting) << "Syncing" << exposedRegion << "of" << exposedWidget; + QTLWExtra *tlwExtra = tlw->d_func()->maybeTopData(); if (!tlw->isVisible() || !tlwExtra || tlwExtra->inTopLevelResize) return; @@ -745,6 +752,8 @@ void QWidgetRepaintManager::sync(QWidget *exposedWidget, const QRegion &exposedR */ void QWidgetRepaintManager::sync() { + qCInfo(lcWidgetPainting) << "Syncing dirty widgets"; + updateRequestSent = false; if (qt_widget_private(tlw)->shouldDiscardSyncRequest()) { // If the top-level is minimized, it's not visible on the screen so we can delay the @@ -798,6 +807,9 @@ bool QWidgetRepaintManager::syncAllowed() void QWidgetRepaintManager::paintAndFlush() { + qCInfo(lcWidgetPainting) << "Painting and flushing dirty" + << "top level" << dirty << "and dirty widgets" << dirtyWidgets; + const bool updatesDisabled = !tlw->updatesEnabled(); bool repaintAllWidgets = false; @@ -1027,10 +1039,15 @@ void QWidgetRepaintManager::markNeedsFlush(QWidget *widget, const QRegion ®io if (widget == tlw) { // Top-level (native) + qCInfo(lcWidgetPainting) << "Marking" << region << "of top level" + << widget << "as needing flush"; if (!widget->testAttribute(Qt::WA_WState_InPaintEvent)) topLevelNeedsFlush += region; } else if (!hasPlatformWindow(widget) && !widget->isWindow()) { QWidget *nativeParent = widget->nativeParentWidget(); + qCInfo(lcWidgetPainting) << "Marking" << region << "of" + << widget << "as needing flush in" << nativeParent + << "at offset" << topLevelOffset; if (nativeParent == tlw) { // Alien widgets with the top-level as the native parent (common case) if (!widget->testAttribute(Qt::WA_WState_InPaintEvent)) @@ -1042,6 +1059,8 @@ void QWidgetRepaintManager::markNeedsFlush(QWidget *widget, const QRegion ®io } } else { // Native child widgets + qCInfo(lcWidgetPainting) << "Marking" << region + << "of native child" << widget << "as needing flush"; markNeedsFlush(widget, region); } } @@ -1066,6 +1085,9 @@ void QWidgetRepaintManager::markNeedsFlush(QWidget *widget, const QRegion ®io */ void QWidgetRepaintManager::flush() { + qCInfo(lcWidgetPainting) << "Flushing top level" + << topLevelNeedsFlush << "and children" << needsFlushWidgets; + const bool hasNeedsFlushWidgets = !needsFlushWidgets.isEmpty(); bool flushed = false; @@ -1123,6 +1145,8 @@ void QWidgetRepaintManager::flush(QWidget *widget, const QRegion ®ion, QPlatf return; } + qCInfo(lcWidgetPainting) << "Flushing" << region << "of" << widget; + static bool fpsDebug = qEnvironmentVariableIntValue("QT_DEBUG_FPS"); if (fpsDebug) { if (!perfFrames++) diff --git a/src/widgets/kernel/qwidgetrepaintmanager_p.h b/src/widgets/kernel/qwidgetrepaintmanager_p.h index d7e38a9d69..58687383f4 100644 --- a/src/widgets/kernel/qwidgetrepaintmanager_p.h +++ b/src/widgets/kernel/qwidgetrepaintmanager_p.h @@ -65,16 +65,19 @@ class QWidgetRepaintManager; class Q_AUTOTEST_EXPORT QWidgetRepaintManager { + Q_GADGET public: enum UpdateTime { UpdateNow, UpdateLater }; + Q_ENUM(UpdateTime) enum BufferState{ BufferValid, BufferInvalid }; + Q_ENUM(BufferState) QWidgetRepaintManager(QWidget *t); ~QWidgetRepaintManager(); From 79bf1b7e348d186934b14c417859a48bf9b3a06c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 26 Aug 2019 22:08:59 +0200 Subject: [PATCH 8/8] widgets: Mark widgets as needing flush during painting Except for the case of syncing in response to an expose event, where the platform asked us to flush a specific region, we should strive to only flush parts that have been repainted. And we should flush those parts to their nearest native child, instead of unconditionally flushing the root/top level widget as well. By allowing drawWidget to schedule the flush we automatically flush the minimal region, to the right widgets. Change-Id: I73c143761d4a0da6991433b41dea0a0bc83a448a Reviewed-by: Paul Olav Tvete --- src/widgets/kernel/qwidget.cpp | 7 ++----- src/widgets/kernel/qwidgetrepaintmanager.cpp | 12 ++---------- 2 files changed, 4 insertions(+), 15 deletions(-) diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 45be132e59..cf5a81c204 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -5313,9 +5313,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP } sourced->context = 0; - // Native widgets need to be marked dirty on screen so painting will be done in correct context - // Same check as in the no effects case below. - if (repaintManager && !asRoot && (q->internalWinId() || !q->nativeParentWidget()->isWindow())) + if (repaintManager) repaintManager->markNeedsFlush(q, rgn, offset); return; @@ -5422,8 +5420,7 @@ void QWidgetPrivate::drawWidget(QPaintDevice *pdev, const QRegion &rgn, const QP sendPaintEvent(toBePainted); } - // Native widgets need to be marked dirty on screen so painting will be done in correct context - if (repaintManager && !asRoot && (q->internalWinId() || (q->nativeParentWidget() && !q->nativeParentWidget()->isWindow()))) + if (repaintManager) repaintManager->markNeedsFlush(q, toBePainted, offset); //restore diff --git a/src/widgets/kernel/qwidgetrepaintmanager.cpp b/src/widgets/kernel/qwidgetrepaintmanager.cpp index d1ebf7dc25..4eb298e108 100644 --- a/src/widgets/kernel/qwidgetrepaintmanager.cpp +++ b/src/widgets/kernel/qwidgetrepaintmanager.cpp @@ -979,12 +979,6 @@ void QWidgetRepaintManager::paintAndFlush() } #endif - // Always flush repainted areas. FIXME: We should mark individual widgets, - // not the top level widget unconditionally, as this results in always - // flushing the top level widget, even if the painted region is entirely - // within a native child. - markNeedsFlush(tlw, toClean, QPoint()); - store->beginPaint(toClean); // Must do this before sending any paint events because @@ -1041,8 +1035,7 @@ void QWidgetRepaintManager::markNeedsFlush(QWidget *widget, const QRegion ®io // Top-level (native) qCInfo(lcWidgetPainting) << "Marking" << region << "of top level" << widget << "as needing flush"; - if (!widget->testAttribute(Qt::WA_WState_InPaintEvent)) - topLevelNeedsFlush += region; + topLevelNeedsFlush += region; } else if (!hasPlatformWindow(widget) && !widget->isWindow()) { QWidget *nativeParent = widget->nativeParentWidget(); qCInfo(lcWidgetPainting) << "Marking" << region << "of" @@ -1050,8 +1043,7 @@ void QWidgetRepaintManager::markNeedsFlush(QWidget *widget, const QRegion ®io << "at offset" << topLevelOffset; if (nativeParent == tlw) { // Alien widgets with the top-level as the native parent (common case) - if (!widget->testAttribute(Qt::WA_WState_InPaintEvent)) - topLevelNeedsFlush += region.translated(topLevelOffset); + topLevelNeedsFlush += region.translated(topLevelOffset); } else { // Alien widgets with native parent != tlw const QPoint nativeParentOffset = widget->mapTo(nativeParent, QPoint());