From 7dc930d40037c99d87b09de09a882d5f86f157d5 Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Mon, 6 Aug 2018 13:47:18 +0200 Subject: qmake vcxproj generator: Fix compilation of generated C++ sources Generated C++ source files with extensions other than .cpp would not get compiled, because the code ignored all other C++ source extensions like .cc and .cxx. Fix this by respecting the value of QMAKE_EXT_CPP and QMAKE_EXT_C. Task-number: QTBUG-69770 Change-Id: I097dfef6920e353a351c97891cdbfdc9a859815f Reviewed-by: Oliver Wolff Reviewed-by: Oswald Buddenhagen --- qmake/generators/win32/msbuild_objectmodel.cpp | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/qmake/generators/win32/msbuild_objectmodel.cpp b/qmake/generators/win32/msbuild_objectmodel.cpp index 9f82ce4f8e..e58999bb97 100644 --- a/qmake/generators/win32/msbuild_objectmodel.cpp +++ b/qmake/generators/win32/msbuild_objectmodel.cpp @@ -1977,6 +1977,15 @@ bool VCXProjectWriter::outputFileConfig(OutputFilterData *d, XmlOutput &xml, Xml return fileAdded; } +static bool isFileClCompatible(const QString &filePath) +{ + auto filePathEndsWith = [&filePath] (const QString &ext) { + return filePath.endsWith(ext, Qt::CaseInsensitive); + }; + return std::any_of(Option::cpp_ext.cbegin(), Option::cpp_ext.cend(), filePathEndsWith) + || std::any_of(Option::c_ext.cbegin(), Option::c_ext.cend(), filePathEndsWith); +} + void VCXProjectWriter::outputFileConfig(XmlOutput &xml, XmlOutput &xmlFilter, const QString &filePath, const QString &filterName) { @@ -2000,7 +2009,7 @@ void VCXProjectWriter::outputFileConfig(XmlOutput &xml, XmlOutput &xmlFilter, << attrTagS("Filter", filterName); xml << tag("ClInclude") << attrTag("Include", nativeFilePath); - } else if (filePath.endsWith(".cpp")) { + } else if (isFileClCompatible(filePath)) { xmlFilter << tag("ClCompile") << attrTag("Include", nativeFilePath) << attrTagS("Filter", filterName); -- cgit v1.2.3 From 2adc06f9406ec2f8c02d1619c73f384eb2947498 Mon Sep 17 00:00:00 2001 From: Robin Lee Date: Wed, 27 Jun 2018 11:54:20 +0800 Subject: IBus: Support the portal, needed for Flatpak environment Following commit 35ce6247 in IBus, IBus input plugin now connects to session bus and use IBus portal to create input context when running in Flatpak environment or IBUS_USE_PORTAL is set. [ChangeLog][plugins][ibus] Support IBus portal. Qt programs in Flatpak environment can now trigger IBus input method. Change-Id: I561f5f873d709b8abeae554d804daa058f9f6e16 Reviewed-by: Lars Knoll Reviewed-by: Takao Fujiwara --- src/plugins/platforminputcontexts/ibus/ibus.pro | 2 + .../interfaces/org.freedesktop.IBus.Portal.xml | 10 ++++ .../ibus/qibusplatforminputcontext.cpp | 64 ++++++++++++++++++---- .../ibus/qibusproxyportal.cpp | 26 +++++++++ .../platforminputcontexts/ibus/qibusproxyportal.h | 49 +++++++++++++++++ 5 files changed, 140 insertions(+), 11 deletions(-) create mode 100644 src/plugins/platforminputcontexts/ibus/interfaces/org.freedesktop.IBus.Portal.xml create mode 100644 src/plugins/platforminputcontexts/ibus/qibusproxyportal.cpp create mode 100644 src/plugins/platforminputcontexts/ibus/qibusproxyportal.h diff --git a/src/plugins/platforminputcontexts/ibus/ibus.pro b/src/plugins/platforminputcontexts/ibus/ibus.pro index 9f6c848e6a..52836bb8b6 100644 --- a/src/plugins/platforminputcontexts/ibus/ibus.pro +++ b/src/plugins/platforminputcontexts/ibus/ibus.pro @@ -3,12 +3,14 @@ TARGET = ibusplatforminputcontextplugin QT += dbus gui-private SOURCES += $$PWD/qibusplatforminputcontext.cpp \ $$PWD/qibusproxy.cpp \ + $$PWD/qibusproxyportal.cpp \ $$PWD/qibusinputcontextproxy.cpp \ $$PWD/qibustypes.cpp \ $$PWD/main.cpp HEADERS += $$PWD/qibusplatforminputcontext.h \ $$PWD/qibusproxy.h \ + $$PWD/qibusproxyportal.h \ $$PWD/qibusinputcontextproxy.h \ $$PWD/qibustypes.h diff --git a/src/plugins/platforminputcontexts/ibus/interfaces/org.freedesktop.IBus.Portal.xml b/src/plugins/platforminputcontexts/ibus/interfaces/org.freedesktop.IBus.Portal.xml new file mode 100644 index 0000000000..1a5414d0ae --- /dev/null +++ b/src/plugins/platforminputcontexts/ibus/interfaces/org.freedesktop.IBus.Portal.xml @@ -0,0 +1,10 @@ + + + + + + + + + diff --git a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp index f339938f86..19f0afbf50 100644 --- a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp +++ b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp @@ -50,6 +50,7 @@ #include #include "qibusproxy.h" +#include "qibusproxyportal.h" #include "qibusinputcontextproxy.h" #include "qibustypes.h" @@ -78,19 +79,22 @@ public: { delete context; delete bus; + delete portalBus; delete connection; } static QString getSocketPath(); - static QDBusConnection *createConnection(); + QDBusConnection *createConnection(); void initBus(); void createBusProxy(); QDBusConnection *connection; QIBusProxy *bus; + QIBusProxyPortal *portalBus; // bus and portalBus are alternative. QIBusInputContextProxy *context; + bool usePortal; // return value of shouldConnectIbusPortal bool valid; bool busConnected; QString predit; @@ -507,6 +511,9 @@ void QIBusPlatformInputContext::filterEventFinished(QDBusPendingCallWatcher *cal QLocale QIBusPlatformInputContext::locale() const { + // d->locale is not updated when IBus portal is used + if (d->usePortal) + return QPlatformInputContext::locale(); return d->locale; } @@ -572,15 +579,34 @@ void QIBusPlatformInputContext::connectToContextSignals() } } +static inline bool checkRunningUnderFlatpak() +{ + return !QStandardPaths::locate(QStandardPaths::RuntimeLocation, QLatin1String("flatpak-info")).isEmpty(); +} + +static bool shouldConnectIbusPortal() +{ + // honor the same env as ibus-gtk + return (checkRunningUnderFlatpak() || !qgetenv("IBUS_USE_PORTAL").isNull()); +} + QIBusPlatformInputContextPrivate::QIBusPlatformInputContextPrivate() : connection(0), bus(0), + portalBus(0), context(0), + usePortal(shouldConnectIbusPortal()), valid(false), busConnected(false), needsSurroundingText(false) { - valid = !QStandardPaths::findExecutable(QString::fromLocal8Bit("ibus-daemon"), QStringList()).isEmpty(); + if (usePortal) { + valid = true; + if (debug) + qDebug() << "use IBus portal"; + } else { + valid = !QStandardPaths::findExecutable(QString::fromLocal8Bit("ibus-daemon"), QStringList()).isEmpty(); + } if (!valid) return; initBus(); @@ -603,21 +629,35 @@ void QIBusPlatformInputContextPrivate::createBusProxy() if (!connection || !connection->isConnected()) return; - bus = new QIBusProxy(QLatin1String("org.freedesktop.IBus"), - QLatin1String("/org/freedesktop/IBus"), - *connection); - if (!bus->isValid()) { - qWarning("QIBusPlatformInputContext: invalid bus."); - return; - } + const char* ibusService = usePortal ? "org.freedesktop.portal.IBus" : "org.freedesktop.IBus"; + QDBusReply ic; + if (usePortal) { + portalBus = new QIBusProxyPortal(QLatin1String(ibusService), + QLatin1String("/org/freedesktop/IBus"), + *connection); + if (!portalBus->isValid()) { + qWarning("QIBusPlatformInputContext: invalid portal bus."); + return; + } - QDBusReply ic = bus->CreateInputContext(QLatin1String("QIBusInputContext")); + ic = portalBus->CreateInputContext(QLatin1String("QIBusInputContext")); + } else { + bus = new QIBusProxy(QLatin1String(ibusService), + QLatin1String("/org/freedesktop/IBus"), + *connection); + if (!bus->isValid()) { + qWarning("QIBusPlatformInputContext: invalid bus."); + return; + } + + ic = bus->CreateInputContext(QLatin1String("QIBusInputContext")); + } if (!ic.isValid()) { qWarning("QIBusPlatformInputContext: CreateInputContext failed."); return; } - context = new QIBusInputContextProxy(QLatin1String("org.freedesktop.IBus"), ic.value().path(), *connection); + context = new QIBusInputContextProxy(QLatin1String(ibusService), ic.value().path(), *connection); if (!context->isValid()) { qWarning("QIBusPlatformInputContext: invalid input context."); @@ -665,6 +705,8 @@ QString QIBusPlatformInputContextPrivate::getSocketPath() QDBusConnection *QIBusPlatformInputContextPrivate::createConnection() { + if (usePortal) + return new QDBusConnection(QDBusConnection::connectToBus(QDBusConnection::SessionBus, QLatin1String("QIBusProxy"))); QFile file(getSocketPath()); if (!file.open(QFile::ReadOnly)) diff --git a/src/plugins/platforminputcontexts/ibus/qibusproxyportal.cpp b/src/plugins/platforminputcontexts/ibus/qibusproxyportal.cpp new file mode 100644 index 0000000000..50482e2d9a --- /dev/null +++ b/src/plugins/platforminputcontexts/ibus/qibusproxyportal.cpp @@ -0,0 +1,26 @@ +/* + * This file was generated by qdbusxml2cpp version 0.8 + * Command line was: qdbusxml2cpp -N -p qibusproxyportal -c QIBusProxyPortal interfaces/org.freedesktop.IBus.Portal.xml + * + * qdbusxml2cpp is Copyright (C) 2017 The Qt Company Ltd. + * + * This is an auto-generated file. + * This file may have been hand-edited. Look for HAND-EDIT comments + * before re-generating it. + */ + +#include "qibusproxyportal.h" + +/* + * Implementation of interface class QIBusProxyPortal + */ + +QIBusProxyPortal::QIBusProxyPortal(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent) + : QDBusAbstractInterface(service, path, staticInterfaceName(), connection, parent) +{ +} + +QIBusProxyPortal::~QIBusProxyPortal() +{ +} + diff --git a/src/plugins/platforminputcontexts/ibus/qibusproxyportal.h b/src/plugins/platforminputcontexts/ibus/qibusproxyportal.h new file mode 100644 index 0000000000..bdd1d9c395 --- /dev/null +++ b/src/plugins/platforminputcontexts/ibus/qibusproxyportal.h @@ -0,0 +1,49 @@ +/* + * This file was generated by qdbusxml2cpp version 0.8 + * Command line was: qdbusxml2cpp -N -p qibusproxyportal -c QIBusProxyPortal interfaces/org.freedesktop.IBus.Portal.xml + * + * qdbusxml2cpp is Copyright (C) 2017 The Qt Company Ltd. + * + * This is an auto-generated file. + * Do not edit! All changes made to it will be lost. + */ + +#ifndef QIBUSPROXYPORTAL_H +#define QIBUSPROXYPORTAL_H + +#include +#include +#include +#include +#include +#include +#include +#include + +/* + * Proxy class for interface org.freedesktop.IBus.Portal + */ +class QIBusProxyPortal: public QDBusAbstractInterface +{ + Q_OBJECT +public: + static inline const char *staticInterfaceName() + { return "org.freedesktop.IBus.Portal"; } + +public: + QIBusProxyPortal(const QString &service, const QString &path, const QDBusConnection &connection, QObject *parent = nullptr); + + ~QIBusProxyPortal(); + +public Q_SLOTS: // METHODS + inline QDBusPendingReply CreateInputContext(const QString &name) + { + QList argumentList; + argumentList << QVariant::fromValue(name); + return asyncCallWithArgumentList(QStringLiteral("CreateInputContext"), argumentList); + } + +Q_SIGNALS: // SIGNALS +}; + +#endif -- cgit v1.2.3 From 25feee4e061b99edab79503d81f5bd045c6c8e3d Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 7 Aug 2018 09:38:42 -0700 Subject: Fix qmake build with glibc 2.28 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We haven't yet run the configure checks to see if statx and renameat2 are present in glibc, so this fails when we redefine the structures and functions. linux/stat.h:56:8: error: redefinition of 'struct statx_timestamp' bits/statx.h:25:8: note: previous definition of 'struct statx_timestamp' qfilesystemengine_unix.cpp:110:12: error: 'int renameat2(int, const char*, int, const char*, unsigned int)' was declared 'extern' and later 'static' [-fpermissive] Change-Id: Ia741b559c24d46c78fb2fffd1548a792d22e3368 Reviewed-by: Oswald Buddenhagen Reviewed-by: Jüri Valdmann --- src/corelib/global/qconfig-bootstrapped.h | 12 ++++++++++-- src/corelib/io/qfilesystemengine_unix.cpp | 2 +- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/corelib/global/qconfig-bootstrapped.h b/src/corelib/global/qconfig-bootstrapped.h index 3469ebe5e6..c5585ea32a 100644 --- a/src/corelib/global/qconfig-bootstrapped.h +++ b/src/corelib/global/qconfig-bootstrapped.h @@ -98,10 +98,18 @@ #define QT_NO_QOBJECT #define QT_FEATURE_process -1 #define QT_FEATURE_regularexpression -1 -#define QT_FEATURE_renameat2 -1 +#ifdef __GLIBC_PREREQ +# define QT_FEATURE_renameat2 (__GLIBC_PREREQ(2, 28) ? 1 : -1) +#else +# define QT_FEATURE_renameat2 -1 +#endif #define QT_FEATURE_sharedmemory -1 #define QT_FEATURE_slog2 -1 -#define QT_FEATURE_statx -1 +#ifdef __GLIBC_PREREQ +# define QT_FEATURE_statx (__GLIBC_PREREQ(2, 28) ? 1 : -1) +#else +# define QT_FEATURE_statx -1 +#endif #define QT_FEATURE_syslog -1 #define QT_NO_SYSTEMLOCALE #define QT_FEATURE_systemsemaphore -1 diff --git a/src/corelib/io/qfilesystemengine_unix.cpp b/src/corelib/io/qfilesystemengine_unix.cpp index 0c9cdb8667..deb4a9f220 100644 --- a/src/corelib/io/qfilesystemengine_unix.cpp +++ b/src/corelib/io/qfilesystemengine_unix.cpp @@ -91,7 +91,6 @@ extern "C" NSString *NSTemporaryDirectory(); # include # include # include -# include // in case linux/fs.h is too old and doesn't define it: #ifndef FICLONE @@ -112,6 +111,7 @@ static int renameat2(int oldfd, const char *oldpath, int newfd, const char *newp # endif # if !QT_CONFIG(statx) && defined(SYS_statx) +# include static int statx(int dirfd, const char *pathname, int flag, unsigned mask, struct statx *statxbuf) { return syscall(SYS_statx, dirfd, pathname, flag, mask, statxbuf); } # elif !QT_CONFIG(statx) && !defined(SYS_statx) -- cgit v1.2.3 From 58b6b723defd8006c08624d690e32d53db91cc89 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Tue, 7 Aug 2018 20:22:27 -0700 Subject: QSysInfo: fall back to /usr/lib/os-release if the /etc one is missing Turns out that there are two files and while a lot of distros symlink one to the other, some distros lack the one in /etc. [ChangeLog][QtCore][QSysInfo] Fixed QSysInfo::productType() to properly detect some Linux distributions that ship with a minimal /etc. Change-Id: Ia741b559c24d46c78fb2fffd1548cab414037220 Reviewed-by: Oswald Buddenhagen Reviewed-by: Simon Hausmann --- src/corelib/global/qglobal.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index a6990b88f4..b30d690025 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -2211,10 +2211,19 @@ static bool readEtcFile(QUnixOSVersion &v, const char *filename, return true; } -static bool readEtcOsRelease(QUnixOSVersion &v) +static bool readOsRelease(QUnixOSVersion &v) { - return readEtcFile(v, "/etc/os-release", QByteArrayLiteral("ID="), - QByteArrayLiteral("VERSION_ID="), QByteArrayLiteral("PRETTY_NAME=")); + QByteArray id = QByteArrayLiteral("ID="); + QByteArray versionId = QByteArrayLiteral("VERSION_ID="); + QByteArray prettyName = QByteArrayLiteral("PRETTY_NAME="); + + // man os-release(5) says: + // The file /etc/os-release takes precedence over /usr/lib/os-release. + // Applications should check for the former, and exclusively use its data + // if it exists, and only fall back to /usr/lib/os-release if it is + // missing. + return readEtcFile(v, "/etc/os-release", id, versionId, prettyName) || + readEtcFile(v, "/usr/lib/os-release", id, versionId, prettyName); } static bool readEtcLsbRelease(QUnixOSVersion &v) @@ -2296,7 +2305,7 @@ static bool readEtcDebianVersion(QUnixOSVersion &v) static bool findUnixOsVersion(QUnixOSVersion &v) { - if (readEtcOsRelease(v)) + if (readOsRelease(v)) return true; if (readEtcLsbRelease(v)) return true; -- cgit v1.2.3 From f2668c6b43a80a83ebdd46407a01af8a0dc6285f Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Tue, 7 Aug 2018 08:30:07 +0200 Subject: qmake vcxproj generator: Fix extra compilers for single configs For single config mode (no debug_and_release) extra compilers wouldn't get added to the vcxproj file. Single config mode creates a temporary project, and that was incomplete. Multi config mode, on the other hand, directly operates on the "real data" and wasn't affected by this problem. Task-number: QTBUG-69769 Change-Id: I9cd942e43d80adbeac9a3c8fbe1a5766bc9645a0 Reviewed-by: Oswald Buddenhagen Reviewed-by: Joerg Bornemann --- qmake/generators/win32/msbuild_objectmodel.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/qmake/generators/win32/msbuild_objectmodel.cpp b/qmake/generators/win32/msbuild_objectmodel.cpp index e58999bb97..082f357d32 100644 --- a/qmake/generators/win32/msbuild_objectmodel.cpp +++ b/qmake/generators/win32/msbuild_objectmodel.cpp @@ -557,6 +557,12 @@ void VCXProjectWriter::write(XmlOutput &xml, VCProjectSingleConfig &tool) addFilters(tempProj, xmlFilter, "Deployment Files"); addFilters(tempProj, xmlFilter, "Distribution Files"); + tempProj.ExtraCompilers.reserve(tool.ExtraCompilersFiles.size()); + std::transform(tool.ExtraCompilersFiles.cbegin(), tool.ExtraCompilersFiles.cend(), + std::back_inserter(tempProj.ExtraCompilers), + [] (const VCFilter &filter) { return filter.Name; }); + tempProj.ExtraCompilers.removeDuplicates(); + for (int x = 0; x < tempProj.ExtraCompilers.count(); ++x) addFilters(tempProj, xmlFilter, tempProj.ExtraCompilers.at(x)); -- cgit v1.2.3 From 490d461ab080777d6418dce97db632dc2270d218 Mon Sep 17 00:00:00 2001 From: BogDan Vatra Date: Thu, 15 Mar 2018 09:08:30 +0200 Subject: Fix apkPath for gradle 4.0+ This change keeps the compatibility with old gradle. It is needed for projects that must use the old gradle version. src/tools/androiddeployqt/main.cpp was moved from qttools into qtbase in 5.11. So re-apply c03f5673 in qttools here. Task-number: QTBUG-69755 Change-Id: I2399d445f8208766e4185d717bb51f1317fdcc00 Reviewed-by: Volker Krause (cherry picked from commit e2f41931129d77dd9e92c812d965d7252673661a) Reviewed-by: Vikas Pachdha Reviewed-by: Liang Qi --- src/tools/androiddeployqt/main.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/tools/androiddeployqt/main.cpp b/src/tools/androiddeployqt/main.cpp index f00188396d..57714fc687 100644 --- a/src/tools/androiddeployqt/main.cpp +++ b/src/tools/androiddeployqt/main.cpp @@ -2328,10 +2328,15 @@ enum PackageType { QString apkPath(const Options &options, PackageType pt) { QString path(options.outputDirectory); - if (options.gradle) - path += QLatin1String("/build/outputs/apk/") + QDir(options.outputDirectory).dirName() + QLatin1Char('-'); - else + if (options.gradle) { + path += QLatin1String("/build/outputs/apk/"); + QString buildType(options.releasePackage ? QLatin1String("release/") : QLatin1String("debug/")); + if (QDir(path + buildType).exists()) + path += buildType; + path += QDir(options.outputDirectory).dirName() + QLatin1Char('-'); + } else { path += QLatin1String("/bin/QtApp-"); + } if (options.releasePackage) { path += QLatin1String("release-"); if (pt == UnsignedAPK) -- cgit v1.2.3 From 04671a80db32bd7fce470c50934cf60f2e8ffa70 Mon Sep 17 00:00:00 2001 From: Gabriel de Dietrich Date: Fri, 15 Jun 2018 23:15:10 +0200 Subject: macOS: Force light theme on macOS 10.14+ MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Until we can properly fix QPalette and QMacStyle, we should disable dark appearance in Qt applications. Disable by setting NSApp.appearance to Aqua, unless dark mode support has been requested via Info.plist or environment variable. Read the NSRequiresAquaSystemAppearance Info.plist key, don’t set NSApp.appearance if its value is false. Also check the QT_MAC_REQUIRES_AQUA_SYSTEM_APPEARANCE environment variable and apply similar logic. You then enable dark mode support by setting: QT_MAC_REQUIRES_AQUA_SYSTEM_APPEARANCE=0 which is slightly awkward, but matches Info.plist behavior. Task-number: QTBUG-68891 Change-Id: I86dc6cf3dee951d46c953396c57d2c31f2e4afcc Reviewed-by: Morten Johan Sørvig --- src/plugins/platforms/cocoa/qcocoaintegration.mm | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/src/plugins/platforms/cocoa/qcocoaintegration.mm b/src/plugins/platforms/cocoa/qcocoaintegration.mm index 55b3805df3..79f7ebda54 100644 --- a/src/plugins/platforms/cocoa/qcocoaintegration.mm +++ b/src/plugins/platforms/cocoa/qcocoaintegration.mm @@ -70,6 +70,12 @@ #include +#if !QT_MACOS_PLATFORM_SDK_EQUAL_OR_ABOVE(__MAC_10_14) +@interface NSApplication (MojaveForwardDeclarations) +@property (strong) NSAppearance *appearance NS_AVAILABLE_MAC(10_14); +@end +#endif + static void initResources() { Q_INIT_RESOURCE(qcocoaresources); @@ -131,6 +137,21 @@ QCocoaIntegration::QCocoaIntegration(const QStringList ¶mList) NSApplication *cocoaApplication = [QNSApplication sharedApplication]; qt_redirectNSApplicationSendEvent(); + if (__builtin_available(macOS 10.14, *)) { + // Disable dark appearance, unless the Info.plist or environment requests that it should be enabled + bool plistEnablesDarkAppearance = [[[NSBundle mainBundle] objectForInfoDictionaryKey: + @"NSRequiresAquaSystemAppearance"] boolValue]; + + bool hasEnvironmentRequiresAquaAppearance; + int environmentRequiresAquaAppearance = qEnvironmentVariableIntValue( + "QT_MAC_REQUIRES_AQUA_SYSTEM_APPEARANCE", &hasEnvironmentRequiresAquaAppearance); + bool environmentEnablesDarkAppearance = hasEnvironmentRequiresAquaAppearance + && environmentRequiresAquaAppearance == 0; + + if (!(plistEnablesDarkAppearance || environmentEnablesDarkAppearance)) + NSApp.appearance = [NSAppearance appearanceNamed:NSAppearanceNameAqua]; + } + if (qEnvironmentVariableIsEmpty("QT_MAC_DISABLE_FOREGROUND_APPLICATION_TRANSFORM")) { // Applications launched from plain executables (without an app // bundle) are "background" applications that does not take keybaord -- cgit v1.2.3 From 65a1d41a092e78f7ab142c4c62689e1ca40ba10c Mon Sep 17 00:00:00 2001 From: Eskil Abrahamsen Blomfeldt Date: Tue, 7 Aug 2018 08:43:09 +0200 Subject: Fix potential crash when showing line/paragraph separators When showing line and paragraph separators at an offset from the start of the string, the end of string pointer would be incorrectly set, and we would read past the end of the string. If any part of this memory happened to match the line or paragraph separator, then we would overwrite it and have a crash. I couldn't find any reliable way to test this, since the crash depends on the contents of the memory after the string allocated by the algorithm. But with an overflow of 100 000 characters, I found that it crashed every time I ran the test. [ChangeLog][QtGui][Text] Fixed potential crash when using QTextOption::ShowLineAndParagraphSeparators. Task-number: QTBUG-69661 Change-Id: I17d1996b883560bacdc7ce114c8aeb2b0108faea Reviewed-by: JiDe Zhang Reviewed-by: Michal Lazo Reviewed-by: Konstantin Ritt --- src/gui/text/qtextengine.cpp | 2 +- tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index 5e38311fa1..6751c077ac 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -2053,7 +2053,7 @@ void QTextEngine::itemize() const layoutData->string.detach(); string = reinterpret_cast(layoutData->string.unicode()); uc = string + offset; - e = uc + length; + e = string + length; *const_cast(uc) = 0x21B5; // visual line separator } break; diff --git a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp index 4e3d1da8fe..9c477589f9 100644 --- a/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp +++ b/tests/auto/gui/text/qtextlayout/tst_qtextlayout.cpp @@ -137,6 +137,7 @@ private slots: void nbspWithFormat(); void noModificationOfInputString(); void superscriptCrash_qtbug53911(); + void showLineAndParagraphSeparatorsCrash(); private: QFont testFont; @@ -2199,6 +2200,23 @@ void tst_QTextLayout::noModificationOfInputString() } } +void tst_QTextLayout::showLineAndParagraphSeparatorsCrash() +{ + QString s = QString(100000, QChar('a')) + QChar(QChar::LineSeparator); + { + QTextLayout layout; + layout.setText(s); + + QTextOption option; + option.setFlags(QTextOption::ShowLineAndParagraphSeparators); + layout.setTextOption(option); + + layout.beginLayout(); + layout.createLine(); + layout.endLayout(); + } +} + void tst_QTextLayout::superscriptCrash_qtbug53911() { static int fontSizes = 64; -- cgit v1.2.3 From 9742ee681b6c877f518013a3af1ce1aa0a328d2c Mon Sep 17 00:00:00 2001 From: Oswald Buddenhagen Date: Thu, 26 Apr 2018 18:56:00 +0200 Subject: configure: fix passing of -L and -F to configure tests the global flags are deprecated in favor of per-library paths, but they obviously should still work. but apparently no-one cares, because there isn't even a bug report about it ... amends 90eee08b3. Change-Id: I85aee41ca11de1715d1c750ae8e663093e012fb7 Reviewed-by: Joerg Bornemann --- mkspecs/features/qt_configure.prf | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mkspecs/features/qt_configure.prf b/mkspecs/features/qt_configure.prf index 58888856da..4039bba431 100644 --- a/mkspecs/features/qt_configure.prf +++ b/mkspecs/features/qt_configure.prf @@ -960,9 +960,9 @@ defineTest(qtConfTest_compile) { # add compiler flags, these are set for the target and should not be applied to host tests !isEmpty(EXTRA_DEFINES): \ qmake_args += $$system_quote(DEFINES += $$val_escape(EXTRA_DEFINES)) - !isEmpty(EXTRA_LIBDIR) \ + !isEmpty(EXTRA_LIBDIR): \ qmake_args += $$system_quote(QMAKE_LIBDIR += $$val_escape(EXTRA_LIBDIR)) - !isEmpty(EXTRA_FRAMEWORKPATH) \ + !isEmpty(EXTRA_FRAMEWORKPATH): \ qmake_args += $$system_quote(QMAKE_FRAMEWORKPATH += $$val_escape(EXTRA_FRAMEWORKPATH)) !isEmpty(EXTRA_INCLUDEPATH): \ qmake_args += $$system_quote(INCLUDEPATH += $$val_escape(EXTRA_INCLUDEPATH)) -- cgit v1.2.3 From e9a8facc96ce6d3b8df4832032ca4df9fac6e9d7 Mon Sep 17 00:00:00 2001 From: Takao Fujiwara Date: Thu, 9 Aug 2018 16:37:21 +0900 Subject: IBus: connect to ibus-daemon when it restarts in Flatpak IBus clients cannot access the IBus socket path in Flatpak and need to watch the D-Bus disconnection. Change-Id: Ida1a5ce4fe112c1c4f8855ec886e74f2cbdcc8a0 Reviewed-by: Lars Knoll --- .../ibus/qibusplatforminputcontext.cpp | 49 +++++++++++++++++----- .../ibus/qibusplatforminputcontext.h | 2 + 2 files changed, 40 insertions(+), 11 deletions(-) diff --git a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp index 19f0afbf50..0e587965ca 100644 --- a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp +++ b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.cpp @@ -93,6 +93,7 @@ public: QIBusProxy *bus; QIBusProxyPortal *portalBus; // bus and portalBus are alternative. QIBusInputContextProxy *context; + QDBusServiceWatcher serviceWatcher; bool usePortal; // return value of shouldConnectIbusPortal bool valid; @@ -107,20 +108,25 @@ public: QIBusPlatformInputContext::QIBusPlatformInputContext () : d(new QIBusPlatformInputContextPrivate()) { - QString socketPath = QIBusPlatformInputContextPrivate::getSocketPath(); - QFile file(socketPath); - if (file.open(QFile::ReadOnly)) { + if (!d->usePortal) { + QString socketPath = QIBusPlatformInputContextPrivate::getSocketPath(); + QFile file(socketPath); + if (file.open(QFile::ReadOnly)) { #ifndef QT_NO_FILESYSTEMWATCHER - // If KDE session save is used or restart ibus-daemon, - // the applications could run before ibus-daemon runs. - // We watch the getSocketPath() to get the launching ibus-daemon. - m_socketWatcher.addPath(socketPath); - connect(&m_socketWatcher, SIGNAL(fileChanged(QString)), this, SLOT(socketChanged(QString))); + qCDebug(qtQpaInputMethods) << "socketWatcher.addPath" << socketPath; + // If KDE session save is used or restart ibus-daemon, + // the applications could run before ibus-daemon runs. + // We watch the getSocketPath() to get the launching ibus-daemon. + m_socketWatcher.addPath(socketPath); + connect(&m_socketWatcher, SIGNAL(fileChanged(QString)), this, SLOT(socketChanged(QString))); #endif + } + m_timer.setSingleShot(true); + connect(&m_timer, SIGNAL(timeout()), this, SLOT(connectToBus())); } - m_timer.setSingleShot(true); - connect(&m_timer, SIGNAL(timeout()), this, SLOT(connectToBus())); + QObject::connect(&d->serviceWatcher, SIGNAL(serviceRegistered(QString)), this, SLOT(busRegistered(QString))); + QObject::connect(&d->serviceWatcher, SIGNAL(serviceUnregistered(QString)), this, SLOT(busUnregistered(QString))); connectToContextSignals(); @@ -534,6 +540,22 @@ void QIBusPlatformInputContext::socketChanged(const QString &str) m_timer.start(100); } +void QIBusPlatformInputContext::busRegistered(const QString &str) +{ + qCDebug(qtQpaInputMethods) << "busRegistered"; + Q_UNUSED (str); + if (d->usePortal) { + connectToBus(); + } +} + +void QIBusPlatformInputContext::busUnregistered(const QString &str) +{ + qCDebug(qtQpaInputMethods) << "busUnregistered"; + Q_UNUSED (str); + d->busConnected = false; +} + // When getSocketPath() is modified, the bus is not established yet // so use m_timer. void QIBusPlatformInputContext::connectToBus() @@ -543,7 +565,7 @@ void QIBusPlatformInputContext::connectToBus() connectToContextSignals(); #ifndef QT_NO_FILESYSTEMWATCHER - if (m_socketWatcher.files().size() == 0) + if (!d->usePortal && m_socketWatcher.files().size() == 0) m_socketWatcher.addPath(QIBusPlatformInputContextPrivate::getSocketPath()); #endif } @@ -652,6 +674,11 @@ void QIBusPlatformInputContextPrivate::createBusProxy() ic = bus->CreateInputContext(QLatin1String("QIBusInputContext")); } + + serviceWatcher.removeWatchedService(ibusService); + serviceWatcher.setConnection(*connection); + serviceWatcher.addWatchedService(ibusService); + if (!ic.isValid()) { qWarning("QIBusPlatformInputContext: CreateInputContext failed."); return; diff --git a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h index 9b92b2e1f9..f37552b937 100644 --- a/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h +++ b/src/plugins/platforminputcontexts/ibus/qibusplatforminputcontext.h @@ -108,6 +108,8 @@ public Q_SLOTS: void showPreeditText(); void filterEventFinished(QDBusPendingCallWatcher *call); void socketChanged(const QString &str); + void busRegistered(const QString &str); + void busUnregistered(const QString &str); void connectToBus(); void globalEngineChanged(const QString &engine_name); -- cgit v1.2.3 From 6854fa75f78ec202f1e5dce5bd8adec31d1dbc7e Mon Sep 17 00:00:00 2001 From: Sune Vuorela Date: Fri, 3 Aug 2018 19:01:44 +0200 Subject: Glib dispatcher: use default priority for timers For some reason, the GLib event dispatcher was lowering the priority for timers compared to other events like for example socket events. the IDLE priority is for "Do this later when you are not busy", and that is wrong for generic timer events. See also https://bugs.kde.org/show_bug.cgi?id=230184 Task-number: QTBUG-48344 Change-Id: Id337a8f0c7fad3ebd5e5fa49d7831a0001ea9010 Reviewed-by: Thiago Macieira Reviewed-by: David Faure Reviewed-by: Allan Sandfeld Jensen --- src/corelib/kernel/qeventdispatcher_glib.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/corelib/kernel/qeventdispatcher_glib.cpp b/src/corelib/kernel/qeventdispatcher_glib.cpp index 8cefa7a118..4c780a9294 100644 --- a/src/corelib/kernel/qeventdispatcher_glib.cpp +++ b/src/corelib/kernel/qeventdispatcher_glib.cpp @@ -345,7 +345,6 @@ QEventDispatcherGlibPrivate::QEventDispatcherGlibPrivate(GMainContext *context) sizeof(GIdleTimerSource))); idleTimerSource->timerSource = timerSource; g_source_set_can_recurse(&idleTimerSource->source, true); - g_source_set_priority(&idleTimerSource->source, G_PRIORITY_DEFAULT_IDLE); g_source_attach(&idleTimerSource->source, mainContext); } -- cgit v1.2.3 From 6256729a6da532079505edfe4c56a6ef29cd8ab8 Mon Sep 17 00:00:00 2001 From: Allan Sandfeld Jensen Date: Mon, 13 Aug 2018 15:29:16 +0200 Subject: Fix possible heap corruption in QXmlStream The value of 'tos' at the check might already be on the last element, so triggering stack expansion on the second last element is too late. Change-Id: Ib3ab2662d4d27a71effe9e988b9e172923af2908 Reviewed-by: Richard J. Moore Reviewed-by: Thiago Macieira --- src/corelib/serialization/qxmlstream_p.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/serialization/qxmlstream_p.h b/src/corelib/serialization/qxmlstream_p.h index 4157fbbd0e..f8b1ede943 100644 --- a/src/corelib/serialization/qxmlstream_p.h +++ b/src/corelib/serialization/qxmlstream_p.h @@ -1250,7 +1250,7 @@ bool QXmlStreamReaderPrivate::parse() state_stack[tos] = 0; return true; } else if (act > 0) { - if (++tos == stack_size-1) + if (++tos >= stack_size-1) reallocateStack(); Value &val = sym_stack[tos]; -- cgit v1.2.3 From 833b9997fd8c93132186d6538770f0c415f73d53 Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Fri, 27 Jul 2018 12:25:12 +0200 Subject: xcb: make sure we have a valid m_qimage in backing store MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This patch amends a62f1d03560937a306c7586669a46cd9575e9464. If the initial backing store resize request is called with QSize(0, 0), we end up with QXcbBackingStoreImage holding a default contructed QImage / m_qimage. This happens because of the logic in QXcbBackingStoreImage::create(), where if we detect that the requested segmentSize == 0, we do not allocate any memory, and thus don't create a valid image in m_qimage. On subsequent call to QXcbBackingStore::resize() we would only check if QXcbBackingStoreImage object has been created, but not if it is in a valid state. This obviously would cause problems. This patch re-factors the logic to handle better resize to QSize(0, 0). And make the code cleaner by: - merging ::create and ::resize as semantically it is always resize(). - dropping unnecessary argument passing. Task-number: QTBUG-69581 Change-Id: Ied337beb449dea8259fcf6b7d29f0a5bd553019d Reviewed-by: Błażej Szczygieł Reviewed-by: Shawn Rutledge --- src/plugins/platforms/xcb/qxcbbackingstore.cpp | 111 ++++++++++++++----------- 1 file changed, 61 insertions(+), 50 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbbackingstore.cpp b/src/plugins/platforms/xcb/qxcbbackingstore.cpp index b81cb8efa1..8ae9d9899e 100644 --- a/src/plugins/platforms/xcb/qxcbbackingstore.cpp +++ b/src/plugins/platforms/xcb/qxcbbackingstore.cpp @@ -100,9 +100,7 @@ public: private: void createShmSegment(size_t segmentSize); - void destroyShmSegment(size_t segmentSize); - - void create(const QSize &size, const xcb_format_t *fmt, QImage::Format format); + void destroyShmSegment(); void destroy(bool destroyShm); void ensureGC(xcb_drawable_t dst); @@ -142,6 +140,9 @@ private: bool m_hasAlpha = false; bool m_clientSideScroll = false; + + const xcb_format_t *m_xcb_format = nullptr; + QImage::Format m_qimage_format = QImage::Format_Invalid; }; class QXcbGraphicsBuffer : public QPlatformGraphicsBuffer @@ -183,58 +184,66 @@ QXcbBackingStoreImage::QXcbBackingStoreImage(QXcbBackingStore *backingStore, con : QXcbObject(backingStore->connection()) , m_backingStore(backingStore) { - QXcbWindow *window = static_cast(backingStore->window()->handle()); - const xcb_format_t *fmt = connection()->formatForDepth(window->depth()); - Q_ASSERT(fmt); + auto window = static_cast(m_backingStore->window()->handle()); + m_xcb_format = connection()->formatForDepth(window->depth()); + Q_ASSERT(m_xcb_format); + + m_qimage_format = window->imageFormat(); + m_hasAlpha = QImage::toPixelFormat(m_qimage_format).alphaUsage() == QPixelFormat::UsesAlpha; + if (!m_hasAlpha) + m_qimage_format = qt_maybeAlphaVersionWithSameDepth(m_qimage_format); memset(&m_shm_info, 0, sizeof m_shm_info); - QImage::Format format = window->imageFormat(); - m_hasAlpha = QImage::toPixelFormat(format).alphaUsage() == QPixelFormat::UsesAlpha; - if (!m_hasAlpha) - create(size, fmt, qt_maybeAlphaVersionWithSameDepth(format)); - else - create(size, fmt, format); + resize(size); } void QXcbBackingStoreImage::resize(const QSize &size) { - xcb_format_t fmt; - fmt.depth = m_xcb_image->depth; - fmt.bits_per_pixel = m_xcb_image->bpp; - fmt.scanline_pad = m_xcb_image->scanline_pad; - memset(fmt.pad0, 0, sizeof(fmt.pad0)); destroy(false); - create(size, &fmt, m_qimage.format()); -} -void QXcbBackingStoreImage::create(const QSize &size, const xcb_format_t *fmt, QImage::Format format) -{ + auto byteOrder = QSysInfo::ByteOrder == QSysInfo::BigEndian ? XCB_IMAGE_ORDER_MSB_FIRST + : XCB_IMAGE_ORDER_LSB_FIRST; m_xcb_image = xcb_image_create(size.width(), size.height(), XCB_IMAGE_FORMAT_Z_PIXMAP, - fmt->scanline_pad, - fmt->depth, fmt->bits_per_pixel, 0, - QSysInfo::ByteOrder == QSysInfo::BigEndian ? XCB_IMAGE_ORDER_MSB_FIRST : XCB_IMAGE_ORDER_LSB_FIRST, + m_xcb_format->scanline_pad, + m_xcb_format->depth, + m_xcb_format->bits_per_pixel, + 0, byteOrder, XCB_IMAGE_ORDER_MSB_FIRST, 0, ~0, 0); const size_t segmentSize = imageDataSize(m_xcb_image); - if (!segmentSize) - return; if (connection()->hasShm()) { - if (m_shm_info.shmaddr && (m_segmentSize < segmentSize || m_segmentSize / 2 >= segmentSize)) - destroyShmSegment(m_segmentSize); - if (!m_shm_info.shmaddr) { - qCDebug(lcQpaXcb) << "creating shared memory" << segmentSize << "for" - << size << "depth" << fmt->depth << "bits" << fmt->bits_per_pixel; - createShmSegment(segmentSize); + if (segmentSize == 0) { + if (m_segmentSize > 0) { + destroyShmSegment(); + qCDebug(lcQpaXcb) << "[" << m_backingStore->window() + << "] destroyed SHM segment due to resize to" << size; + } + } else { + // Destroy shared memory segment if it is double (or more) of what we actually + // need with new window size. Or if the new size is bigger than what we currently + // have allocated. + if (m_shm_info.shmaddr && (m_segmentSize < segmentSize || m_segmentSize / 2 >= segmentSize)) + destroyShmSegment(); + if (!m_shm_info.shmaddr) { + qCDebug(lcQpaXcb) << "[" << m_backingStore->window() + << "] creating shared memory" << segmentSize << "bytes for" + << size << "depth" << m_xcb_format->depth << "bits" + << m_xcb_format->bits_per_pixel; + createShmSegment(segmentSize); + } } } - m_xcb_image->data = m_shm_info.shmaddr ? m_shm_info.shmaddr : (uint8_t *)malloc(segmentSize); + if (segmentSize == 0) + return; - m_qimage = QImage( (uchar*) m_xcb_image->data, m_xcb_image->width, m_xcb_image->height, m_xcb_image->stride, format); + m_xcb_image->data = m_shm_info.shmaddr ? m_shm_info.shmaddr : (uint8_t *)malloc(segmentSize); + m_qimage = QImage(static_cast(m_xcb_image->data), m_xcb_image->width, + m_xcb_image->height, m_xcb_image->stride, m_qimage_format); m_graphics_buffer = new QXcbGraphicsBuffer(&m_qimage); m_xcb_pixmap = xcb_generate_id(xcb_connection()); @@ -248,17 +257,18 @@ void QXcbBackingStoreImage::create(const QSize &size, const xcb_format_t *fmt, Q void QXcbBackingStoreImage::destroy(bool destroyShm) { - if (m_xcb_image->data) { - if (m_shm_info.shmaddr) { - if (destroyShm) - destroyShmSegment(m_segmentSize); - } else { - free(m_xcb_image->data); + if (m_xcb_image) { + if (m_xcb_image->data) { + if (m_shm_info.shmaddr) { + if (destroyShm) + destroyShmSegment(); + } else { + free(m_xcb_image->data); + } } + xcb_image_destroy(m_xcb_image); } - xcb_image_destroy(m_xcb_image); - if (m_gc) { xcb_free_gc(xcb_connection(), m_gc); m_gc = 0; @@ -268,8 +278,12 @@ void QXcbBackingStoreImage::destroy(bool destroyShm) delete m_graphics_buffer; m_graphics_buffer = nullptr; - xcb_free_pixmap(xcb_connection(), m_xcb_pixmap); - m_xcb_pixmap = 0; + if (m_xcb_pixmap) { + xcb_free_pixmap(xcb_connection(), m_xcb_pixmap); + m_xcb_pixmap = 0; + } + + m_qimage = QImage(); } void QXcbBackingStoreImage::flushScrolledRegion(bool clientSideScroll) @@ -412,11 +426,8 @@ bool QXcbBackingStoreImage::createSystemVShmSegment(QXcbConnection *c, size_t se return true; } -void QXcbBackingStoreImage::destroyShmSegment(size_t segmentSize) +void QXcbBackingStoreImage::destroyShmSegment() { -#ifndef XCB_USE_SHM_FD - Q_UNUSED(segmentSize) -#endif auto cookie = xcb_shm_detach_checked(xcb_connection(), m_shm_info.shmseg); xcb_generic_error_t *error = xcb_request_check(xcb_connection(), cookie); if (error) @@ -425,9 +436,9 @@ void QXcbBackingStoreImage::destroyShmSegment(size_t segmentSize) #ifdef XCB_USE_SHM_FD if (connection()->hasShmFd()) { - if (munmap(m_shm_info.shmaddr, segmentSize) == -1) { + if (munmap(m_shm_info.shmaddr, m_segmentSize) == -1) { qCWarning(lcQpaXcb, "munmap() failed (%d: %s) for %p with size %zu", - errno, strerror(errno), m_shm_info.shmaddr, segmentSize); + errno, strerror(errno), m_shm_info.shmaddr, m_segmentSize); } } else #endif -- cgit v1.2.3 From edbac716911e49a6b0f81b328e65756f95cb1f0a Mon Sep 17 00:00:00 2001 From: Johan Klokkhammer Helsing Date: Fri, 9 Mar 2018 12:48:16 +0100 Subject: Skip all qfocusevent test on platforms that don't support window activation Task-number: QTBUG-66846 Change-Id: Ia8b69ede9154822f78ca28e0a2470b8bfb2abef0 Reviewed-by: Shawn Rutledge --- tests/auto/other/qfocusevent/qfocusevent.pro | 2 +- tests/auto/other/qfocusevent/tst_qfocusevent.cpp | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/tests/auto/other/qfocusevent/qfocusevent.pro b/tests/auto/other/qfocusevent/qfocusevent.pro index 5f799291c6..95445f30fa 100644 --- a/tests/auto/other/qfocusevent/qfocusevent.pro +++ b/tests/auto/other/qfocusevent/qfocusevent.pro @@ -1,4 +1,4 @@ CONFIG += testcase TARGET = tst_qfocusevent -QT += widgets testlib +QT += widgets testlib gui-private SOURCES += tst_qfocusevent.cpp diff --git a/tests/auto/other/qfocusevent/tst_qfocusevent.cpp b/tests/auto/other/qfocusevent/tst_qfocusevent.cpp index e82327bbb1..ceac02279e 100644 --- a/tests/auto/other/qfocusevent/tst_qfocusevent.cpp +++ b/tests/auto/other/qfocusevent/tst_qfocusevent.cpp @@ -38,6 +38,9 @@ #include #include +#include +#include + QT_FORWARD_DECLARE_CLASS(QWidget) class FocusLineEdit : public QLineEdit @@ -92,13 +95,16 @@ private slots: void checkReason_ActiveWindow(); private: - QWidget* testFocusWidget; + QWidget* testFocusWidget = nullptr; FocusLineEdit* childFocusWidgetOne; FocusLineEdit* childFocusWidgetTwo; }; void tst_QFocusEvent::initTestCase() { + if (!QGuiApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::WindowActivation)) + QSKIP("QWindow::requestActivate() is not supported on this platform."); + testFocusWidget = new QWidget( 0 ); childFocusWidgetOne = new FocusLineEdit( testFocusWidget ); childFocusWidgetOne->setGeometry( 10, 10, 180, 20 ); -- cgit v1.2.3 From 43f5377fad3f462a033d836fd71a6eb356462c11 Mon Sep 17 00:00:00 2001 From: Alexander Volkov Date: Wed, 18 Jul 2018 17:51:11 +0300 Subject: Make QMessageBox window with the detailed text closable QMessageBox window ignores QCloseEvent if it was created with Ok button and the detailed text was set. But it can be closed if it contains only one button. Make it closable if there are two buttons and one of them is the "Show Details..." button. [ChangeLog][QtWidgets][QMessageBox] A message box with two buttons, one of which is the "Show Details..." button, can be closed by clicking the X button on the window's title bar. Task-number: QTBUG-69526 Change-Id: Iba09e38561eb3898dc2aecfd38d8519d512a71c1 Reviewed-by: Richard Moe Gustavsen --- src/widgets/dialogs/qmessagebox.cpp | 10 ++++++++++ tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp | 6 ++++++ 2 files changed, 16 insertions(+) diff --git a/src/widgets/dialogs/qmessagebox.cpp b/src/widgets/dialogs/qmessagebox.cpp index 52ca88891e..6de952a1d3 100644 --- a/src/widgets/dialogs/qmessagebox.cpp +++ b/src/widgets/dialogs/qmessagebox.cpp @@ -1022,6 +1022,16 @@ void QMessageBoxPrivate::detectEscapeButton() return; } + // If there are two buttons and one of them is the "Show Details..." + // button, then make the other one the escape button + if (buttons.count() == 2 && detailsButton) { + auto idx = buttons.indexOf(detailsButton); + if (idx != -1) { + detectedEscapeButton = buttons.at(1 - idx); + return; + } + } + // if the message box has one RejectRole button, make it the escape button for (auto *button : buttons) { if (buttonBox->buttonRole(button) == QDialogButtonBox::RejectRole) { diff --git a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp index a5058f4b6c..70f5c40bcc 100644 --- a/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp +++ b/tests/auto/widgets/dialogs/qmessagebox/tst_qmessagebox.cpp @@ -329,6 +329,12 @@ void tst_QMessageBox::escapeButton() closeHelper.start(ExecCloseHelper::CloseWindow, &msgBox2); msgBox2.exec(); QVERIFY(msgBox2.clickedButton() == msgBox2.button(QMessageBox::No)); // auto detected (one No button only) + + QMessageBox msgBox3; + msgBox3.setDetailedText("Details"); + closeHelper.start(ExecCloseHelper::CloseWindow, &msgBox3); + msgBox3.exec(); + QVERIFY(msgBox3.clickedButton() == msgBox3.button(QMessageBox::Ok)); // auto detected } void tst_QMessageBox::statics() -- cgit v1.2.3 From f2862b4d5def2c07b8b018532ab74a12b129db2c Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 22 May 2018 13:00:38 +0200 Subject: VNC plugin: explicitly cast int to uint16_t before calling htons Otherwise there is a -Werror=narrowing error on big-endian architectures (where htons does nothing). Task-number: QTBUG-68390 Change-Id: Idb204a81aaedb9f4fde1d5fae406da36c7a1953e Reviewed-by: Thiago Macieira (cherry-picked from b206d1c8082a9e01ad3755d311a4cf683ec35161) --- src/plugins/platforms/vnc/qvnc.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/vnc/qvnc.cpp b/src/plugins/platforms/vnc/qvnc.cpp index 44fc1c6101..ffe00de2b1 100644 --- a/src/plugins/platforms/vnc/qvnc.cpp +++ b/src/plugins/platforms/vnc/qvnc.cpp @@ -552,9 +552,9 @@ void QVncClientCursor::write(QVncClient *client) const { const quint16 tmp[6] = { htons(0), htons(1), - htons(hotspot.x()), htons(hotspot.y()), - htons(cursor.width()), - htons(cursor.height()) }; + htons(uint16_t(hotspot.x())), htons(uint16_t(hotspot.y())), + htons(uint16_t(cursor.width())), + htons(uint16_t(cursor.height())) }; socket->write((char*)tmp, sizeof(tmp)); const qint32 encoding = qToBigEndian(-239); -- cgit v1.2.3 From 8dd40e9b0931d2698ff2ee3a655aab8b4947dae8 Mon Sep 17 00:00:00 2001 From: Erik Verbruggen Date: Thu, 9 Aug 2018 11:34:27 +0200 Subject: [macOS] Fix lower bound when searching for previous transitions The lower bound shouldn't be the smallest (positive) value representable by a double, but the *lowest* (finite) value. Task-number: QTBUG-69862 Change-Id: Ia66610e3c0f8d9643c329714607f5af573206fd8 Reviewed-by: Edward Welbourne --- src/corelib/tools/qtimezoneprivate_mac.mm | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/corelib/tools/qtimezoneprivate_mac.mm b/src/corelib/tools/qtimezoneprivate_mac.mm index fa0dd87cfc..d3c4fbe5da 100644 --- a/src/corelib/tools/qtimezoneprivate_mac.mm +++ b/src/corelib/tools/qtimezoneprivate_mac.mm @@ -227,7 +227,7 @@ QTimeZonePrivate::Data QMacTimeZonePrivate::nextTransition(qint64 afterMSecsSinc QTimeZonePrivate::Data QMacTimeZonePrivate::previousTransition(qint64 beforeMSecsSinceEpoch) const { // The native API only lets us search forward, so we need to find an early-enough start: - const NSTimeInterval lowerBound = std::numeric_limits::min(); + const NSTimeInterval lowerBound = std::numeric_limits::lowest(); const qint64 endSecs = beforeMSecsSinceEpoch / 1000; const int year = 366 * 24 * 3600; // a (long) year, in seconds NSTimeInterval prevSecs = endSecs; // sentinel for later check -- cgit v1.2.3 From 8f1851013363ae22d311881abcb1186949068270 Mon Sep 17 00:00:00 2001 From: Shawn Rutledge Date: Tue, 14 Aug 2018 07:19:02 +0200 Subject: Silence warning about comparing signed and unsigned qxcbimage.cpp:72:26: error: comparison between signed and unsigned integer expressions [-Werror=sign-compare] Task-number: QTBUG-69923 Change-Id: Icdb4ce8cb7ce5b48d7ee3839166eb1c7c9520c78 Reviewed-by: Thiago Macieira --- src/plugins/platforms/xcb/qxcbimage.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbimage.cpp b/src/plugins/platforms/xcb/qxcbimage.cpp index e18a08755b..44c7d22344 100644 --- a/src/plugins/platforms/xcb/qxcbimage.cpp +++ b/src/plugins/platforms/xcb/qxcbimage.cpp @@ -69,7 +69,7 @@ QImage::Format imageFormatForMasks(int depth, int bits_per_pixel, int red_mask, if (red_mask == 0xff && blue_mask == 0xff0000) return QImage::Format_RGBA8888_Premultiplied; #else - if (red_mask == 0xff000000 && blue_mask == 0xff00) + if (unsigned(red_mask) == unsigned(0xff000000) && blue_mask == 0xff00) return QImage::Format_RGBA8888_Premultiplied; #endif if (red_mask == 0x3ff && blue_mask == 0x3ff00000) @@ -90,7 +90,7 @@ QImage::Format imageFormatForMasks(int depth, int bits_per_pixel, int red_mask, if (red_mask == 0xff && blue_mask == 0xff0000) return QImage::Format_RGBX8888; #else - if (red_mask == 0xff000000 && blue_mask == 0xff00) + if (unsigned(red_mask) == unsigned(0xff000000) && blue_mask == 0xff00) return QImage::Format_RGBX8888; #endif break; -- cgit v1.2.3 From 48eb08d2555992964fd3dda8a29f9e8c8feb80eb Mon Sep 17 00:00:00 2001 From: Kevin Funk Date: Mon, 9 Jul 2018 23:40:15 +0200 Subject: tests: Fix top-level CMakeLists.txt Problem: CMake Error in CMakeLists.txt: A logical block opening on the line .../qtbase/tests/auto/cmake/CMakeLists.txt:149 (if) is not closed. Broken by change 02ed1b36daebed5f3997bb676cf5e818c0db9d3c Change-Id: I6c04721edbccaa9fcdb53af92d33dfa87eeaebb8 Reviewed-by: Rolf Eike Beer Reviewed-by: Simon Hausmann Reviewed-by: Kai Koehne --- tests/auto/cmake/CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/cmake/CMakeLists.txt b/tests/auto/cmake/CMakeLists.txt index ec75ec7caf..7f685b0338 100644 --- a/tests/auto/cmake/CMakeLists.txt +++ b/tests/auto/cmake/CMakeLists.txt @@ -153,3 +153,4 @@ if (NOT CMAKE_VERSION VERSION_LESS 3.8) # /usr/bin/ld: CMakeFiles/mywidget.dir/moc_mywidget.cpp.o: previous definition here # Reason: SKIP_* properties were added in CMake 3.8 only expect_pass(test_QTBUG-63422) +endif() -- cgit v1.2.3 From d47c287d70fa7ef5a04c61b1518c988de939f07f Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Wed, 15 Aug 2018 15:27:26 +0200 Subject: Document xkbcommon version Task-number: QTBUG-69276 Change-Id: I0023ce210205def958b9e18f3d3c3a63576fc871 Reviewed-by: Gatis Paeglis --- src/3rdparty/xkbcommon/qt_attribution.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/3rdparty/xkbcommon/qt_attribution.json b/src/3rdparty/xkbcommon/qt_attribution.json index 8ee0df1b22..4be9b42917 100644 --- a/src/3rdparty/xkbcommon/qt_attribution.json +++ b/src/3rdparty/xkbcommon/qt_attribution.json @@ -6,6 +6,7 @@ "Description": "xkbcommon is a keymap compiler and support library which processes a reduced subset of keymaps as defined by the XKB specification.", "Homepage": "http://xkbcommon.org/", + "Version": "0.4.1", "License": "MIT Licenses (with no-advertisement clause)", "LicenseId": "MIT", "LicenseFile": "COPYING", -- cgit v1.2.3 From a0ebd98f58b2d92c34fafbc620f024caa36bf0ad Mon Sep 17 00:00:00 2001 From: Paolo Angelelli Date: Fri, 10 Aug 2018 14:40:10 +0200 Subject: Normalize path segments in QHttpNetworkRequest::uri MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Task-number: QTBUG-69659 Change-Id: I184cc460d2e3736d042893a38aa1c11b7d443f88 Reviewed-by: Jesus Fernandez Reviewed-by: Timur Pocheptsov Reviewed-by: Mårten Nordheim Reviewed-by: Thiago Macieira --- src/network/access/qhttpnetworkrequest.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/network/access/qhttpnetworkrequest.cpp b/src/network/access/qhttpnetworkrequest.cpp index cf4be3df95..8de9760710 100644 --- a/src/network/access/qhttpnetworkrequest.cpp +++ b/src/network/access/qhttpnetworkrequest.cpp @@ -133,6 +133,8 @@ QByteArray QHttpNetworkRequest::uri(bool throughProxy) const QUrl copy = d->url; if (copy.path().isEmpty()) copy.setPath(QStringLiteral("/")); + else + format |= QUrl::NormalizePathSegments; QByteArray uri = copy.toEncoded(format); return uri; } -- cgit v1.2.3