diff options
Diffstat (limited to 'src')
54 files changed, 450 insertions, 253 deletions
diff --git a/src/3rdparty/forkfd/forkfd.c b/src/3rdparty/forkfd/forkfd.c index 8d08f403ec..86e109358c 100644 --- a/src/3rdparty/forkfd/forkfd.c +++ b/src/3rdparty/forkfd/forkfd.c @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2014 Intel Corporation +** Copyright (C) 2015 Intel Corporation ** Copyright (C) 2015 Klarälvdalens Datakonsult AB, a KDAB Group company, info@kdab.com ** ** Permission is hereby granted, free of charge, to any person obtaining a copy @@ -31,6 +31,8 @@ #include "forkfd.h" #include <sys/types.h> +#include <sys/time.h> +#include <sys/resource.h> #include <sys/wait.h> #include <assert.h> #include <errno.h> @@ -38,6 +40,7 @@ #include <signal.h> #include <stdlib.h> #include <string.h> +#include <time.h> #include <unistd.h> #ifdef __linux__ @@ -79,6 +82,12 @@ ret = call; \ } while (ret == -1 && errno == EINTR) +struct pipe_payload +{ + struct forkfd_info info; + struct rusage rusage; +}; + typedef struct process_info { ffd_atomic_int pid; @@ -179,33 +188,43 @@ static int isChildReady(pid_t pid, siginfo_t *info) } #endif -static int tryReaping(pid_t pid, siginfo_t *info) +static int tryReaping(pid_t pid, struct pipe_payload *payload) { /* reap the child */ #ifdef HAVE_WAITID if (waitid_works) { // we have waitid(2), which fills in siginfo_t for us - info->si_pid = 0; - return waitid(P_PID, pid, info, WEXITED | WNOHANG) == 0 && info->si_pid == pid; + siginfo_t info; + info.si_pid = 0; + int ret = waitid(P_PID, pid, &info, WEXITED | WNOHANG) == 0 && info.si_pid == pid; + if (!ret) + return ret; + + payload->info.code = info.si_code; + payload->info.status = info.si_status; +# ifdef __linux__ + payload->rusage.ru_utime.tv_sec = info.si_utime / CLOCKS_PER_SEC; + payload->rusage.ru_utime.tv_usec = info.si_utime % CLOCKS_PER_SEC; + payload->rusage.ru_stime.tv_sec = info.si_stime / CLOCKS_PER_SEC; + payload->rusage.ru_stime.tv_usec = info.si_stime % CLOCKS_PER_SEC; +# endif + return 1; } #endif - int status; if (waitpid(pid, &status, WNOHANG) <= 0) return 0; // child did not change state - info->si_signo = SIGCHLD; - info->si_pid = pid; if (WIFEXITED(status)) { - info->si_code = CLD_EXITED; - info->si_status = WEXITSTATUS(status); + payload->info.code = CLD_EXITED; + payload->info.status = WEXITSTATUS(status); } else if (WIFSIGNALED(status)) { - info->si_code = CLD_KILLED; + payload->info.code = CLD_KILLED; # ifdef WCOREDUMP if (WCOREDUMP(status)) - info->si_code = CLD_DUMPED; + payload->info.code = CLD_DUMPED; # endif - info->si_status = WTERMSIG(status); + payload->info.status = WTERMSIG(status); } return 1; @@ -220,10 +239,11 @@ static void freeInfo(Header *header, ProcessInfo *entry) assert(header->busyCount >= 0); } -static void notifyAndFreeInfo(Header *header, ProcessInfo *entry, siginfo_t *info) +static void notifyAndFreeInfo(Header *header, ProcessInfo *entry, + const struct pipe_payload *payload) { ssize_t ret; - EINTR_LOOP(ret, write(entry->deathPipe, info, sizeof(*info))); + EINTR_LOOP(ret, write(entry->deathPipe, payload, sizeof(*payload))); EINTR_LOOP(ret, close(entry->deathPipe)); freeInfo(header, entry); @@ -243,9 +263,11 @@ static void sigchld_handler(int signum) /* is this one of our children? */ BigArray *array; siginfo_t info; + struct pipe_payload payload; int i; memset(&info, 0, sizeof info); + memset(&payload, 0, sizeof payload); #ifdef HAVE_WAITID if (!waitid_works) @@ -275,8 +297,8 @@ search_next_child: FFD_ATOMIC_ACQUIRE, FFD_ATOMIC_RELAXED)) { /* this is our child, send notification and free up this entry */ /* ### FIXME: what if tryReaping returns false? */ - if (tryReaping(pid, &info)) - notifyAndFreeInfo(&children.header, &children.entries[i], &info); + if (tryReaping(pid, &payload)) + notifyAndFreeInfo(&children.header, &children.entries[i], &payload); goto search_next_child; } } @@ -290,8 +312,8 @@ search_next_child: FFD_ATOMIC_ACQUIRE, FFD_ATOMIC_RELAXED)) { /* this is our child, send notification and free up this entry */ /* ### FIXME: what if tryReaping returns false? */ - if (tryReaping(pid, &info)) - notifyAndFreeInfo(&array->header, &array->entries[i], &info); + if (tryReaping(pid, &payload)) + notifyAndFreeInfo(&array->header, &array->entries[i], &payload); goto search_next_child; } } @@ -321,9 +343,9 @@ search_arrays: continue; } #endif - if (tryReaping(pid, &info)) { + if (tryReaping(pid, &payload)) { /* this is our child, send notification and free up this entry */ - notifyAndFreeInfo(&children.header, &children.entries[i], &info); + notifyAndFreeInfo(&children.header, &children.entries[i], &payload); } } @@ -344,9 +366,9 @@ search_arrays: continue; } #endif - if (tryReaping(pid, &info)) { + if (tryReaping(pid, &payload)) { /* this is our child, send notification and free up this entry */ - notifyAndFreeInfo(&array->header, &array->entries[i], &info); + notifyAndFreeInfo(&array->header, &array->entries[i], &payload); } } @@ -626,7 +648,7 @@ int spawnfd(int flags, pid_t *ppid, const char *path, const posix_spawn_file_act { Header *header; ProcessInfo *info; - siginfo_t si; + struct pipe_payload payload; pid_t pid; int death_pipe[2]; int ret = -1; @@ -664,8 +686,8 @@ int spawnfd(int flags, pid_t *ppid, const char *path, const posix_spawn_file_act ffd_atomic_store(&info->pid, pid, FFD_ATOMIC_RELEASE); /* check if the child has already exited */ - if (tryReaping(pid, &si)) - notifyAndFreeInfo(header, info, &si); + if (tryReaping(pid, &payload)) + notifyAndFreeInfo(header, info, &payload); ret = death_pipe[0]; return ret; @@ -682,3 +704,28 @@ out: return -1; } #endif // _POSIX_SPAWN && !FORKFD_NO_SPAWNFD + + +int forkfd_wait(int ffd, forkfd_info *info, struct rusage *rusage) +{ + struct pipe_payload payload; + int ret; + + ret = read(ffd, &payload, sizeof(payload)); + if (ret == -1) + return ret; /* pass errno, probably EINTR, EBADF or EWOULDBLOCK */ + + assert(ret == sizeof(payload)); + if (info) + *info = payload.info; + if (rusage) + *rusage = payload.rusage; + + return 0; /* success */ +} + + +int forkfd_close(int ffd) +{ + return close(ffd); +} diff --git a/src/3rdparty/forkfd/forkfd.h b/src/3rdparty/forkfd/forkfd.h index b3ffe2bff3..dcb36f9f33 100644 --- a/src/3rdparty/forkfd/forkfd.h +++ b/src/3rdparty/forkfd/forkfd.h @@ -1,6 +1,6 @@ /**************************************************************************** ** -** Copyright (C) 2014 Intel Corporation +** Copyright (C) 2015 Intel Corporation ** ** Permission is hereby granted, free of charge, to any person obtaining a copy ** of this software and associated documentation files (the "Software"), to deal @@ -26,6 +26,7 @@ #define FORKFD_H #include <fcntl.h> +#include <stdint.h> #include <unistd.h> // to get the POSIX flags #ifdef _POSIX_SPAWN @@ -41,7 +42,14 @@ extern "C" { #define FFD_CHILD_PROCESS (-2) +struct forkfd_info { + int32_t code; + int32_t status; +}; + int forkfd(int flags, pid_t *ppid); +int forkfd_wait(int ffd, forkfd_info *info, struct rusage *rusage); +int forkfd_close(int ffd); #ifdef _POSIX_SPAWN /* only for spawnfd: */ diff --git a/src/corelib/arch/qatomic_armv6.h b/src/corelib/arch/qatomic_armv6.h index b14ab3d636..b2ea85ada2 100644 --- a/src/corelib/arch/qatomic_armv6.h +++ b/src/corelib/arch/qatomic_armv6.h @@ -90,7 +90,10 @@ private: template <typename T> struct QAtomicOps : QBasicAtomicOps<sizeof(T)> { - typedef T Type; + // this is GCC or GCC-like, so we can use extensions: + // force the alignment to be the size of the type, as on some ABIs the alignment + // of 64-bit types is 32-bit. We need proper alignment for LDREX / STREX. + typedef __attribute__((__aligned__(sizeof(T)))) T Type; }; #ifndef Q_CC_RVCT diff --git a/src/corelib/doc/src/containers.qdoc b/src/corelib/doc/src/containers.qdoc index 1979c45e17..f8d0d3eb05 100644 --- a/src/corelib/doc/src/containers.qdoc +++ b/src/corelib/doc/src/containers.qdoc @@ -601,6 +601,13 @@ container. It only affects the copy, which is probably not what you want. + An alternative to Qt's \c foreach loop is the range-based \c for that is + part of C++ 11 and newer. However, keep in mind that the range-based + \c for might force a Qt container to \l{Implicit Sharing}{detach}, whereas + \c foreach would not. But using \c foreach always copies the container, + which is usually not cheap for STL containers. If in doubt, prefer + \c foreach for Qt containers, and range based \c for for STL ones. + In addition to \c foreach, Qt also provides a \c forever pseudo-keyword for infinite loops: diff --git a/src/corelib/global/global.pri b/src/corelib/global/global.pri index bc11c77d88..6a8104bee2 100644 --- a/src/corelib/global/global.pri +++ b/src/corelib/global/global.pri @@ -41,7 +41,7 @@ LIBS_PRIVATE += $$QMAKE_LIBS_EXECINFO if(linux*|hurd*):!cross_compile:!static:!*-armcc* { QMAKE_LFLAGS += -Wl,-e,qt_core_boilerplate prog=$$quote(if (/program interpreter: (.*)]/) { print $1; }) - DEFINES += ELF_INTERPRETER=\\\"$$system(readelf -l /bin/ls | perl -n -e \'$$prog\')\\\" + DEFINES += ELF_INTERPRETER=\\\"$$system(LC_ALL=C readelf -l /bin/ls | perl -n -e \'$$prog\')\\\" } slog2 { diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index 060af29b03..c582b1f238 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -97,7 +97,7 @@ /* Intel C++ disguising as Visual C++: the `using' keyword avoids warnings */ # if defined(__INTEL_COMPILER) # define Q_DECL_VARIABLE_DEPRECATED -# define Q_CC_INTEL +# define Q_CC_INTEL __INTEL_COMPILER # endif /* only defined for MSVC since that's the only compiler that actually optimizes for this */ @@ -564,6 +564,16 @@ # endif # define Q_COMPILER_UDL # endif +# ifdef _MSC_VER +# if _MSC_VER == 1700 +// <initializer_list> is missing with MSVC 2012 (it's present in 2010, 2013 and up) +# undef Q_COMPILER_INITIALIZER_LISTS +# endif +# if _MSC_VER < 1900 +// ICC disables unicode string support when compatibility mode with MSVC 2013 or lower is active +# undef Q_COMPILER_UNICODE_STRINGS +# endif +# endif # endif #endif @@ -890,7 +900,8 @@ # define Q_COMPILER_RANGE_FOR # define Q_COMPILER_REF_QUALIFIERS # define Q_COMPILER_THREAD_LOCAL -# define Q_COMPILER_THREADSAFE_STATICS +// Broken, see QTBUG-47224 and https://connect.microsoft.com/VisualStudio/feedback/details/1549785 +//# define Q_COMPILER_THREADSAFE_STATICS # define Q_COMPILER_UDL # define Q_COMPILER_UNICODE_STRINGS // Uniform initialization is not working yet -- build errors with QUuid diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 85d97c7b06..f335794fed 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -2262,7 +2262,8 @@ static bool readEtcRedHatRelease(QUnixOSVersion &v) int releaseIndex = line.indexOf(keyword); v.productType = QString::fromLatin1(line.mid(0, releaseIndex)).remove(QLatin1Char(' ')); int spaceIndex = line.indexOf(' ', releaseIndex + strlen(keyword)); - v.productVersion = QString::fromLatin1(line.mid(releaseIndex + strlen(keyword), spaceIndex > -1 ? spaceIndex - releaseIndex - strlen(keyword) : -1)); + v.productVersion = QString::fromLatin1(line.mid(releaseIndex + strlen(keyword), + spaceIndex > -1 ? spaceIndex - releaseIndex - int(strlen(keyword)) : -1)); return true; } diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index 2912e68580..0cfcc4e659 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -650,11 +650,9 @@ void qt_core_boilerplate() "Copyright (C) 2015 The Qt Company Ltd.\n" "Contact: http://www.qt.io/licensing/\n" "\n" - "Build date: %s\n" "Installation prefix: %s\n" "Library path: %s\n" "Include path: %s\n", - qt_configure_installation + 12, qt_configure_prefix_path_str + 12, qt_configure_strs + qt_configure_str_offsets[QT_PREPEND_NAMESPACE(QLibraryInfo)::LibrariesPath - 1], qt_configure_strs + qt_configure_str_offsets[QT_PREPEND_NAMESPACE(QLibraryInfo)::HeadersPath - 1]); diff --git a/src/corelib/global/qlogging.cpp b/src/corelib/global/qlogging.cpp index 88882bbe8f..fca8656f9b 100644 --- a/src/corelib/global/qlogging.cpp +++ b/src/corelib/global/qlogging.cpp @@ -87,6 +87,10 @@ # endif #endif +#if defined(QT_USE_SLOG2) +extern char *__progname; +#endif + #if defined(Q_OS_LINUX) && (defined(__GLIBC__) || __has_include(<sys/syscall.h>)) # include <sys/syscall.h> static long qt_gettid() @@ -1173,8 +1177,6 @@ void QMessagePattern::setPattern(const QString &pattern) #define QT_LOG_CODE 9000 #endif -extern char *__progname; - static void slog2_default_handler(QtMsgType msgType, const char *message) { if (slog2_set_default_buffer((slog2_buffer_t)-1) == 0) { @@ -1357,8 +1359,9 @@ QString qFormatLogMessage(QtMsgType type, const QMessageLogContext &context, con } else if (pattern->timeFormat == QLatin1String("boot")) { // just print the milliseconds since the elapsed timer reference // like the Linux kernel does - pattern->timer.elapsed(); - uint ms = pattern->timer.msecsSinceReference(); + QElapsedTimer now; + now.start(); + uint ms = now.msecsSinceReference(); message.append(QString::asprintf("%6d.%03d", uint(ms / 1000), uint(ms % 1000))); } else if (pattern->timeFormat.isEmpty()) { message.append(QDateTime::currentDateTime().toString(Qt::ISODate)); diff --git a/src/corelib/io/io.pri b/src/corelib/io/io.pri index 207de2a85b..f496d037d8 100644 --- a/src/corelib/io/io.pri +++ b/src/corelib/io/io.pri @@ -147,6 +147,7 @@ win32 { SOURCES += io/qsettings_mac.cpp OBJECTIVE_SOURCES += io/qurl_mac.mm } + freebsd: LIBS_PRIVATE += -lutil # qlockfile_unix.cpp requires this mac { osx { OBJECTIVE_SOURCES += io/qfilesystemwatcher_fsevents.mm diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp index 2ae865a534..e1d9858a66 100644 --- a/src/corelib/io/qdir.cpp +++ b/src/corelib/io/qdir.cpp @@ -1503,11 +1503,19 @@ bool QDir::removeRecursively() while (di.hasNext()) { di.next(); const QFileInfo& fi = di.fileInfo(); + const QString &filePath = di.filePath(); bool ok; - if (fi.isDir() && !fi.isSymLink()) - ok = QDir(di.filePath()).removeRecursively(); // recursive - else - ok = QFile::remove(di.filePath()); + if (fi.isDir() && !fi.isSymLink()) { + ok = QDir(filePath).removeRecursively(); // recursive + } else { + ok = QFile::remove(filePath); + if (!ok) { // Read-only files prevent directory deletion on Windows, retry with Write permission. + const QFile::Permissions permissions = QFile::permissions(filePath); + if (!(permissions & QFile::WriteUser)) + ok = QFile::setPermissions(filePath, permissions | QFile::WriteUser) + && QFile::remove(filePath); + } + } if (!ok) success = false; } diff --git a/src/corelib/io/qloggingregistry.cpp b/src/corelib/io/qloggingregistry.cpp index 85e73db652..ed775d62e0 100644 --- a/src/corelib/io/qloggingregistry.cpp +++ b/src/corelib/io/qloggingregistry.cpp @@ -210,20 +210,23 @@ void QLoggingSettingsParser::setContent(QTextStream &stream) if (_section == QLatin1String("Rules")) { int equalPos = line.indexOf(QLatin1Char('=')); - if ((equalPos != -1) - && (line.lastIndexOf(QLatin1Char('=')) == equalPos)) { - const QStringRef pattern = line.leftRef(equalPos); - const QStringRef valueStr = line.midRef(equalPos + 1); - int value = -1; - if (valueStr == QLatin1String("true")) - value = 1; - else if (valueStr == QLatin1String("false")) - value = 0; - QLoggingRule rule(pattern, (value == 1)); - if (rule.flags != 0 && (value != -1)) - _rules.append(rule); - else + if (equalPos != -1) { + if (line.lastIndexOf(QLatin1Char('=')) == equalPos) { + const QStringRef pattern = line.leftRef(equalPos); + const QStringRef valueStr = line.midRef(equalPos + 1); + int value = -1; + if (valueStr == QLatin1String("true")) + value = 1; + else if (valueStr == QLatin1String("false")) + value = 0; + QLoggingRule rule(pattern, (value == 1)); + if (rule.flags != 0 && (value != -1)) + _rules.append(rule); + else + warnMsg("Ignoring malformed logging rule: '%s'", line.toUtf8().constData()); + } else { warnMsg("Ignoring malformed logging rule: '%s'", line.toUtf8().constData()); + } } } } diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index 0d6ef9e60f..4c3432d6b6 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -1075,20 +1075,17 @@ bool QProcessPrivate::waitForDeadChild() return true; // child has already exited // read the process information from our fd - siginfo_t info; - qint64 ret = qt_safe_read(forkfd, &info, sizeof info); - Q_ASSERT(ret == sizeof info); - Q_UNUSED(ret); + forkfd_info info; + int ret; + EINTR_LOOP(ret, forkfd_wait(forkfd, &info, Q_NULLPTR)); - Q_ASSERT(info.si_pid == pid_t(pid)); - - exitCode = info.si_status; - crashed = info.si_code != CLD_EXITED; + exitCode = info.status; + crashed = info.code != CLD_EXITED; delete deathNotifier; deathNotifier = 0; - qt_safe_close(forkfd); + EINTR_LOOP(ret, forkfd_close(forkfd)); forkfd = -1; // Child is dead, don't try to kill it anymore #if defined QPROCESS_DEBUG diff --git a/src/corelib/io/qsavefile.cpp b/src/corelib/io/qsavefile.cpp index ffa6ad1c55..5a325f8e2c 100644 --- a/src/corelib/io/qsavefile.cpp +++ b/src/corelib/io/qsavefile.cpp @@ -215,7 +215,8 @@ bool QSaveFile::open(OpenMode mode) d->finalFileName = existingFile.filePath(); } - d->fileEngine = new QTemporaryFileEngine(d->finalFileName, 0666); + d->fileEngine = new QTemporaryFileEngine; + static_cast<QTemporaryFileEngine *>(d->fileEngine)->initialize(d->finalFileName, 0666); // Same as in QFile: QIODevice provides the buffering, so there's no need to request it from the file engine. if (!d->fileEngine->open(mode | QIODevice::Unbuffered)) { QFileDevice::FileError err = d->fileEngine->error(); diff --git a/src/corelib/io/qtemporaryfile.cpp b/src/corelib/io/qtemporaryfile.cpp index bdf4392275..e8e8d8c878 100644 --- a/src/corelib/io/qtemporaryfile.cpp +++ b/src/corelib/io/qtemporaryfile.cpp @@ -409,14 +409,24 @@ QTemporaryFilePrivate::~QTemporaryFilePrivate() QAbstractFileEngine *QTemporaryFilePrivate::engine() const { if (!fileEngine) { - if (fileName.isEmpty()) - fileEngine = new QTemporaryFileEngine(templateName, 0600); - else - fileEngine = new QTemporaryFileEngine(fileName, 0600, false); + fileEngine = new QTemporaryFileEngine; + resetFileEngine(); } return fileEngine; } +void QTemporaryFilePrivate::resetFileEngine() const +{ + if (!fileEngine) + return; + + QTemporaryFileEngine *tef = static_cast<QTemporaryFileEngine *>(fileEngine); + if (fileName.isEmpty()) + tef->initialize(templateName, 0600); + else + tef->initialize(fileName, 0600, false); +} + QString QTemporaryFilePrivate::defaultTemplateName() { QString baseName; @@ -769,6 +779,13 @@ bool QTemporaryFile::open(OpenMode flags) } } + // reset the engine state so it creates a new, unique file name from the template; + // equivalent to: + // delete d->fileEngine; + // d->fileEngine = 0; + // d->engine(); + d->resetFileEngine(); + if (QFile::open(flags)) { d->fileName = d->fileEngine->fileName(QAbstractFileEngine::DefaultName); return true; diff --git a/src/corelib/io/qtemporaryfile_p.h b/src/corelib/io/qtemporaryfile_p.h index 341ae9bd3f..8002990270 100644 --- a/src/corelib/io/qtemporaryfile_p.h +++ b/src/corelib/io/qtemporaryfile_p.h @@ -64,6 +64,7 @@ protected: ~QTemporaryFilePrivate(); QAbstractFileEngine *engine() const; + void resetFileEngine() const; bool autoRemove; QString templateName; @@ -77,22 +78,17 @@ class QTemporaryFileEngine : public QFSFileEngine { Q_DECLARE_PRIVATE(QFSFileEngine) public: - - QTemporaryFileEngine(const QString &file, - quint32 fileMode, - bool fileIsTemplate = true) : - QFSFileEngine(), - fileMode(fileMode), - filePathIsTemplate(fileIsTemplate), - filePathWasTemplate(fileIsTemplate) + void initialize(const QString &file, quint32 mode, bool nameIsTemplate = true) { Q_D(QFSFileEngine); + Q_ASSERT(!isReallyOpen()); + fileMode = mode; + filePathIsTemplate = filePathWasTemplate = nameIsTemplate; d->fileEntry = QFileSystemEntry(file); if (!filePathIsTemplate) QFSFileEngine::setFileName(file); } - ~QTemporaryFileEngine(); bool isReallyOpen() const; diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 66481d4c87..08c0473cf0 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -392,7 +392,7 @@ static bool quitLockRefEnabled = true; // GUI apps or when using MinGW due to its globbing. static inline bool isArgvModified(int argc, char **argv) { - if (__argc != argc) + if (__argc != argc || !__argv /* wmain() */) return true; if (__argv == argv) return false; diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp index ccb8341d0a..e8ff8a7936 100644 --- a/src/corelib/kernel/qeventdispatcher_win.cpp +++ b/src/corelib/kernel/qeventdispatcher_win.cpp @@ -560,6 +560,17 @@ static HWND qt_create_internal_window(const QEventDispatcherWin32 *eventDispatch return wnd; } +static void calculateNextTimeout(WinTimerInfo *t, quint64 currentTime) +{ + uint interval = t->interval; + if ((interval >= 20000u && t->timerType != Qt::PreciseTimer) || t->timerType == Qt::VeryCoarseTimer) { + // round the interval, VeryCoarseTimers only have full second accuracy + interval = ((interval + 500)) / 1000 * 1000; + } + t->interval = interval; + t->timeout = currentTime + interval; +} + void QEventDispatcherWin32Private::registerTimer(WinTimerInfo *t) { Q_ASSERT(internalHwnd); @@ -567,6 +578,7 @@ void QEventDispatcherWin32Private::registerTimer(WinTimerInfo *t) Q_Q(QEventDispatcherWin32); int ok = 0; + calculateNextTimeout(t, qt_msectime()); uint interval = t->interval; if (interval == 0u) { // optimization for single-shot-zero-timer @@ -575,17 +587,13 @@ void QEventDispatcherWin32Private::registerTimer(WinTimerInfo *t) } else if ((interval < 20u || t->timerType == Qt::PreciseTimer) && qtimeSetEvent) { ok = t->fastTimerId = qtimeSetEvent(interval, 1, qt_fast_timer_proc, (DWORD_PTR)t, TIME_CALLBACK_FUNCTION | TIME_PERIODIC | TIME_KILL_SYNCHRONOUS); - } else if (interval >= 20000u || t->timerType == Qt::VeryCoarseTimer) { - // round the interval, VeryCoarseTimers only have full second accuracy - interval = ((interval + 500)) / 1000 * 1000; } + if (ok == 0) { // user normal timers for (Very)CoarseTimers, or if no more multimedia timers available ok = SetTimer(internalHwnd, t->timerId, interval, 0); } - t->timeout = qt_msectime() + interval; - if (ok == 0) qErrnoWarning("QEventDispatcherWin32::registerTimer: Failed to create a timer"); } @@ -610,6 +618,9 @@ void QEventDispatcherWin32Private::sendTimerEvent(int timerId) // send event, but don't allow it to recurse t->inTimerEvent = true; + // recalculate next emission + calculateNextTimeout(t, qt_msectime()); + QTimerEvent e(t->timerId); QCoreApplication::sendEvent(t->obj, &e); diff --git a/src/corelib/kernel/qeventdispatcher_win_p.h b/src/corelib/kernel/qeventdispatcher_win_p.h index 6b4fb18f46..e59e29f1ff 100644 --- a/src/corelib/kernel/qeventdispatcher_win_p.h +++ b/src/corelib/kernel/qeventdispatcher_win_p.h @@ -58,7 +58,7 @@ class QEventDispatcherWin32Private; // forward declaration LRESULT QT_WIN_CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp); -int qt_msectime(); +quint64 qt_msectime(); class Q_CORE_EXPORT QEventDispatcherWin32 : public QAbstractEventDispatcher { diff --git a/src/corelib/kernel/qeventdispatcher_winrt_p.h b/src/corelib/kernel/qeventdispatcher_winrt_p.h index e39746aeef..fd3d259c96 100644 --- a/src/corelib/kernel/qeventdispatcher_winrt_p.h +++ b/src/corelib/kernel/qeventdispatcher_winrt_p.h @@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE -int qt_msectime(); +quint64 qt_msectime(); class QEventDispatcherWinRTPrivate; diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index 60cd3ab94a..90ee7d8f95 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -1879,13 +1879,14 @@ const char *QMetaMethod::typeName() const way in the function declaration: \code + // In the class MainWindow declaration #ifndef Q_MOC_RUN - // define the tag text - # define THISISTESTTAG + // define the tag text as empty, so the compiler doesn't see it + # define MY_CUSTOM_TAG #endif ... private slots: - THISISTESTTAG void testFunc(); + MY_CUSTOM_TAG void testFunc(); \endcode and the information can be accessed by using: @@ -1895,12 +1896,14 @@ const char *QMetaMethod::typeName() const win.show(); int functionIndex = win.metaObject()->indexOfSlot("testFunc()"); - QMetaMethod mm = metaObject()->method(functionIndex); - qDebug() << mm.tag(); // prints THISISTESTTAG + QMetaMethod mm = win.metaObject()->method(functionIndex); + qDebug() << mm.tag(); // prints MY_CUSTOM_TAG \endcode For the moment, \c moc will extract and record all tags, but it will not - handle any of them specially. + handle any of them specially. You can use the tags to annotate your methods + differently, and treat them according to the specific needs of your + application. \note Since Qt 5.0, \c moc expands preprocessor macros, so it is necessary to surround the definition with \c #ifndef \c Q_MOC_RUN, as shown in the @@ -1960,8 +1963,9 @@ int QMetaMethod::revision() const Returns the access specification of this method (private, protected, or public). - Signals are always protected, meaning that you can only emit them - from the class or from a subclass. + \note Signals are always public, but you should regard that as an + implementation detail. It is almost always a bad idea to emit a signal from + outside its class. \sa methodType() */ diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index c63dd79f02..e6458382f2 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -909,14 +909,7 @@ QObject::~QObject() } if (!d->isWidget && d->isSignalConnected(0)) { - QT_TRY { - emit destroyed(this); - } QT_CATCH(...) { - // all the signal/slots connections are still in place - if we don't - // quit now, we will crash pretty soon. - qWarning("Detected an unexpected exception in ~QObject while emitting destroyed()."); - QT_RETHROW; - } + emit destroyed(this); } if (d->declarativeData) { diff --git a/src/corelib/tools/qelapsedtimer_win.cpp b/src/corelib/tools/qelapsedtimer_win.cpp index eab2f8ef6c..b80c23cf8f 100644 --- a/src/corelib/tools/qelapsedtimer_win.cpp +++ b/src/corelib/tools/qelapsedtimer_win.cpp @@ -117,7 +117,7 @@ static quint64 getTickCount() #endif // Q_OS_WINRT } -int qt_msectime() +quint64 qt_msectime() { return ticksToNanoseconds(getTickCount()) / 1000000; } diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 26ec81c103..ef87a8e3a5 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -273,9 +273,9 @@ static inline __m128i mergeQuestionMarks(__m128i chunk) // that they are doing the right thing. Inverting the arguments in the // instruction does cause a bunch of test failures. - const int mode = _SIDD_UWORD_OPS | _SIDD_CMP_RANGES | _SIDD_UNIT_MASK; const __m128i rangeMatch = _mm_cvtsi32_si128(0xffff0100); - const __m128i offLimitMask = _mm_cmpestrm(rangeMatch, 2, chunk, 8, mode); + const __m128i offLimitMask = _mm_cmpestrm(rangeMatch, 2, chunk, 8, + _SIDD_UWORD_OPS | _SIDD_CMP_RANGES | _SIDD_UNIT_MASK); // replace the non-Latin 1 characters in the chunk with question marks chunk = _mm_blendv_epi8(chunk, questionMark, offLimitMask); diff --git a/src/gui/doc/snippets/code/src_gui_qopenglshaderprogram.cpp b/src/gui/doc/snippets/code/src_gui_qopenglshaderprogram.cpp index ab8ee67929..368a5085d4 100644 --- a/src/gui/doc/snippets/code/src_gui_qopenglshaderprogram.cpp +++ b/src/gui/doc/snippets/code/src_gui_qopenglshaderprogram.cpp @@ -43,7 +43,7 @@ QOpenGLShader shader(QOpenGLShader::Vertex); shader.compileSourceCode(code); QOpenGLShaderProgram program(context); -program.addShader(shader); +program.addShader(&shader); program.link(); program.bind(); diff --git a/src/gui/image/qimage_conversions.cpp b/src/gui/image/qimage_conversions.cpp index e0ca2c5331..02f32aa34b 100644 --- a/src/gui/image/qimage_conversions.cpp +++ b/src/gui/image/qimage_conversions.cpp @@ -1103,7 +1103,7 @@ static bool mask_alpha_converter_rgbx_inplace(QImageData *data, Qt::ImageConvers } rgb_data += pad; } - data->format = DestFormat; + data->format = QImage::Format_RGBX8888; return true; #endif } diff --git a/src/gui/image/qjpeghandler.cpp b/src/gui/image/qjpeghandler.cpp index c0fda647aa..e29f9783a6 100644 --- a/src/gui/image/qjpeghandler.cpp +++ b/src/gui/image/qjpeghandler.cpp @@ -710,6 +710,7 @@ public: enum State { Ready, ReadHeader, + ReadingEnd, Error }; @@ -958,7 +959,7 @@ bool QJpegHandlerPrivate::read(QImage *image) for (int i = 0; i < readTexts.size()-1; i+=2) image->setText(readTexts.at(i), readTexts.at(i+1)); - state = Ready; + state = ReadingEnd; return true; } @@ -1006,7 +1007,7 @@ bool QJpegHandler::canRead() const if(d->state == QJpegHandlerPrivate::Ready && !canRead(device())) return false; - if (d->state != QJpegHandlerPrivate::Error) { + if (d->state != QJpegHandlerPrivate::Error && d->state != QJpegHandlerPrivate::ReadingEnd) { setFormat("jpeg"); return true; } diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index b56a9da255..2a451453d0 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -1889,7 +1889,7 @@ void QGuiApplicationPrivate::processKeyEvent(QWindowSystemInterfacePrivate::KeyE #if !defined(Q_OS_OSX) // On OS X the shortcut override is checked earlier, see: QWindowSystemInterface::handleKeyEvent() const bool checkShortcut = e->keyType == QEvent::KeyPress && window != 0; - if (checkShortcut && QWindowSystemInterface::tryHandleShortcutEvent(window, e->timestamp, e->key, e->modifiers, e->unicode)) + if (checkShortcut && QWindowSystemInterface::tryHandleShortcutEvent(window, e->timestamp, e->key, e->modifiers, e->unicode, e->repeat, e->repeatCount)) return; #endif // Q_OS_OSX diff --git a/src/gui/opengl/qopengltexture.cpp b/src/gui/opengl/qopengltexture.cpp index baa702a982..5edaddcd6a 100644 --- a/src/gui/opengl/qopengltexture.cpp +++ b/src/gui/opengl/qopengltexture.cpp @@ -1112,6 +1112,7 @@ void QOpenGLTexturePrivate::setData(int mipLevel, int layer, QOpenGLTexture::Cub mipLevelSize(mipLevel, dimensions[0]), 1, sourceFormat, sourceType, data, options); + break; case QOpenGLTexture::Target2D: Q_UNUSED(layer); @@ -1210,6 +1211,7 @@ void QOpenGLTexturePrivate::setCompressedData(int mipLevel, int layer, QOpenGLTe mipLevelSize(mipLevel, dimensions[0]), 1, format, dataSize, data, options); + break; case QOpenGLTexture::Target2D: Q_UNUSED(layer); diff --git a/src/gui/opengl/qopengltexturehelper.cpp b/src/gui/opengl/qopengltexturehelper.cpp index 440fdad081..bf8b514449 100644 --- a/src/gui/opengl/qopengltexturehelper.cpp +++ b/src/gui/opengl/qopengltexturehelper.cpp @@ -101,6 +101,8 @@ QOpenGLTextureHelper::QOpenGLTextureHelper(QOpenGLContext *context) // Use our own DSA emulation TextureParameteri = &QOpenGLTextureHelper::qt_TextureParameteri; TextureParameteriv = &QOpenGLTextureHelper::qt_TextureParameteriv; + TextureParameterf = &QOpenGLTextureHelper::qt_TextureParameterf; + TextureParameterfv = &QOpenGLTextureHelper::qt_TextureParameterfv; GenerateTextureMipmap = &QOpenGLTextureHelper::qt_GenerateTextureMipmap; TextureStorage3D = &QOpenGLTextureHelper::qt_TextureStorage3D; TextureStorage2D = &QOpenGLTextureHelper::qt_TextureStorage2D; diff --git a/src/gui/text/qtextengine.cpp b/src/gui/text/qtextengine.cpp index e87711ef99..d2174c5e06 100644 --- a/src/gui/text/qtextengine.cpp +++ b/src/gui/text/qtextengine.cpp @@ -1256,7 +1256,7 @@ int QTextEngine::shapeTextWithHarfbuzzNG(const QScriptItem &si, const ushort *st // scaling the advances for this particular version if (actualFontEngine->fontDef.stretch != 100 && QSysInfo::MacintoshVersion != QSysInfo::MV_10_6) { - QFixed stretch = QFixed(actualFontEngine->fontDef.stretch) / QFixed(100); + QFixed stretch = QFixed(int(actualFontEngine->fontDef.stretch)) / QFixed(100); for (uint i = 0; i < num_glyphs; ++i) g.advances[i] *= stretch; } diff --git a/src/network/access/qnetworkaccessmanager.cpp b/src/network/access/qnetworkaccessmanager.cpp index bcd82d1433..e6fb1a09a0 100644 --- a/src/network/access/qnetworkaccessmanager.cpp +++ b/src/network/access/qnetworkaccessmanager.cpp @@ -472,11 +472,11 @@ QNetworkAccessManager::QNetworkAccessManager(QObject *parent) // the QNetworkSession's signals connect(&d->networkConfigurationManager, SIGNAL(onlineStateChanged(bool)), SLOT(_q_onlineStateChanged(bool))); - // we would need all active configurations to check for - // d->networkConfigurationManager.isOnline(), which is asynchronous - // and potentially expensive. We can just check the configuration here - d->online = (d->networkConfiguration.state() & QNetworkConfiguration::Active); } + // we would need all active configurations to check for + // d->networkConfigurationManager.isOnline(), which is asynchronous + // and potentially expensive. We can just check the configuration here + d->online = (d->networkConfiguration.state() & QNetworkConfiguration::Active); #endif } @@ -946,6 +946,7 @@ QNetworkConfiguration QNetworkAccessManager::activeConfiguration() const void QNetworkAccessManager::setNetworkAccessible(QNetworkAccessManager::NetworkAccessibility accessible) { Q_D(QNetworkAccessManager); + d->defaultAccessControl = false; if (d->networkAccessible != accessible) { NetworkAccessibility previous = networkAccessible(); @@ -964,7 +965,6 @@ void QNetworkAccessManager::setNetworkAccessible(QNetworkAccessManager::NetworkA QNetworkAccessManager::NetworkAccessibility QNetworkAccessManager::networkAccessible() const { Q_D(const QNetworkAccessManager); - if (d->networkSessionRequired) { QSharedPointer<QNetworkSession> networkSession(d->getNetworkSession()); if (networkSession) { @@ -975,7 +975,13 @@ QNetworkAccessManager::NetworkAccessibility QNetworkAccessManager::networkAccess return NotAccessible; } else { // Network accessibility is either disabled or unknown. - return (d->networkAccessible == NotAccessible) ? NotAccessible : UnknownAccessibility; + if (d->defaultAccessControl) { + if (d->online) + return d->networkAccessible; + else + return NotAccessible; + } + return (d->networkAccessible); } } else { if (d->online) @@ -1568,7 +1574,7 @@ void QNetworkAccessManagerPrivate::createSession(const QNetworkConfiguration &co if (!networkSessionStrongRef) { online = false; - if (networkAccessible == QNetworkAccessManager::NotAccessible) + if (networkAccessible == QNetworkAccessManager::NotAccessible || !online) emit q->networkAccessibleChanged(QNetworkAccessManager::NotAccessible); else emit q->networkAccessibleChanged(QNetworkAccessManager::UnknownAccessibility); @@ -1616,11 +1622,14 @@ void QNetworkAccessManagerPrivate::_q_networkSessionStateChanged(QNetworkSession if (online) { if (state != QNetworkSession::Connected && state != QNetworkSession::Roaming) { online = false; - emit q->networkAccessibleChanged(QNetworkAccessManager::NotAccessible); + networkAccessible = QNetworkAccessManager::NotAccessible; + emit q->networkAccessibleChanged(networkAccessible); } } else { if (state == QNetworkSession::Connected || state == QNetworkSession::Roaming) { online = true; + if (defaultAccessControl) + networkAccessible = QNetworkAccessManager::Accessible; emit q->networkAccessibleChanged(networkAccessible); } } diff --git a/src/network/access/qnetworkaccessmanager_p.h b/src/network/access/qnetworkaccessmanager_p.h index f513324461..c715da00c1 100644 --- a/src/network/access/qnetworkaccessmanager_p.h +++ b/src/network/access/qnetworkaccessmanager_p.h @@ -84,6 +84,7 @@ public: initializeSession(true), #endif cookieJarCreated(false), + defaultAccessControl(true), authenticationManager(QSharedPointer<QNetworkAccessAuthenticationManager>::create()) { } ~QNetworkAccessManagerPrivate(); @@ -164,6 +165,7 @@ public: #endif bool cookieJarCreated; + bool defaultAccessControl; // The cache with authorization data: QSharedPointer<QNetworkAccessAuthenticationManager> authenticationManager; diff --git a/src/network/ssl/qsslellipticcurve.h b/src/network/ssl/qsslellipticcurve.h index a4dc4517ff..5716e3447d 100644 --- a/src/network/ssl/qsslellipticcurve.h +++ b/src/network/ssl/qsslellipticcurve.h @@ -71,10 +71,8 @@ public: private: int id; - friend Q_DECL_CONSTEXPR bool operator==(QSslEllipticCurve lhs, QSslEllipticCurve rhs) Q_DECL_NOTHROW - { return lhs.id == rhs.id; } - friend Q_DECL_CONSTEXPR uint qHash(QSslEllipticCurve curve, uint seed) Q_DECL_NOTHROW - { return qHash(curve.id, seed); } + friend Q_DECL_CONSTEXPR bool operator==(QSslEllipticCurve lhs, QSslEllipticCurve rhs) Q_DECL_NOTHROW; + friend Q_DECL_CONSTEXPR uint qHash(QSslEllipticCurve curve, uint seed) Q_DECL_NOTHROW; friend class QSslSocketPrivate; friend class QSslSocketBackendPrivate; @@ -82,6 +80,12 @@ private: Q_DECLARE_TYPEINFO(QSslEllipticCurve, Q_PRIMITIVE_TYPE); +Q_DECL_CONSTEXPR inline uint qHash(QSslEllipticCurve curve, uint seed) Q_DECL_NOTHROW +{ return qHash(curve.id, seed); } + +Q_DECL_CONSTEXPR inline bool operator==(QSslEllipticCurve lhs, QSslEllipticCurve rhs) Q_DECL_NOTHROW +{ return lhs.id == rhs.id; } + Q_DECL_CONSTEXPR inline bool operator!=(QSslEllipticCurve lhs, QSslEllipticCurve rhs) Q_DECL_NOTHROW { return !operator==(lhs, rhs); } diff --git a/src/network/ssl/qsslsocket_mac.cpp b/src/network/ssl/qsslsocket_mac.cpp index 497cbf4c9b..b83e56c29e 100644 --- a/src/network/ssl/qsslsocket_mac.cpp +++ b/src/network/ssl/qsslsocket_mac.cpp @@ -33,6 +33,7 @@ #include "qsslsocket.h" +#include "qssl_p.h" #include "qsslsocket_mac_p.h" #include "qasn1element_p.h" #include "qsslcertificate_p.h" @@ -93,7 +94,7 @@ static OSStatus _q_SSLRead(QTcpSocket *plainSocket, char *data, size_t *dataLeng const qint64 bytes = plainSocket->read(data, *dataLength); #ifdef QSSLSOCKET_DEBUG - qDebug() << Q_FUNC_INFO << plainSocket << "read" << bytes; + qCDebug(lcSsl) << plainSocket << "read" << bytes; #endif if (bytes < 0) { *dataLength = 0; @@ -114,7 +115,7 @@ static OSStatus _q_SSLWrite(QTcpSocket *plainSocket, const char *data, size_t *d const qint64 bytes = plainSocket->write(data, *dataLength); #ifdef QSSLSOCKET_DEBUG - qDebug() << Q_FUNC_INFO << plainSocket << "write" << bytes; + qCDebug(lcSsl) << plainSocket << "write" << bytes; #endif if (bytes < 0) { *dataLength = 0; @@ -166,7 +167,7 @@ void QSslSocketPrivate::ensureInitialized() if (!s_loadRootCertsOnDemand) setDefaultCaCertificates(systemCaCertificates()); } else { - qWarning() << Q_FUNC_INFO << "SSLCreateContext failed"; + qCWarning(lcSsl) << "SSLCreateContext failed"; s_loadedCiphersAndCerts = false; } @@ -225,7 +226,7 @@ QList<QSslCertificate> QSslSocketPrivate::systemCaCertificates() } } else { // no detailed error handling here - qWarning("could not retrieve system CA certificates"); + qCWarning(lcSsl) << "SecTrustSettingsCopyCertificates failed:" << status; } #endif return systemCerts; @@ -244,7 +245,7 @@ QSslSocketBackendPrivate::~QSslSocketBackendPrivate() void QSslSocketBackendPrivate::continueHandshake() { #ifdef QSSLSOCKET_DEBUG - qDebug() << Q_FUNC_INFO << plainSocket << "connection encrypted"; + qCDebug(lcSsl) << plainSocket << "connection encrypted"; #endif Q_Q(QSslSocket); connectionEncrypted = true; @@ -291,8 +292,7 @@ QSsl::SslProtocol QSslSocketBackendPrivate::sessionProtocol() const SSLProtocol protocol = kSSLProtocolUnknown; const OSStatus err = SSLGetNegotiatedProtocolVersion(context, &protocol); if (err != noErr) { - qWarning() << Q_FUNC_INFO << "SSLGetNegotiatedProtocolVersion failed:" - << int(err); + qCWarning(lcSsl) << "SSLGetNegotiatedProtocolVersion failed:" << err; return QSsl::UnknownProtocol; } @@ -356,9 +356,12 @@ void QSslSocketBackendPrivate::transmit() const size_t nextDataBlockSize = writeBuffer.nextDataBlockSize(); size_t writtenBytes = 0; const OSStatus err = SSLWrite(context, writeBuffer.readPointer(), nextDataBlockSize, &writtenBytes); +#ifdef QSSLSOCKET_DEBUG + qCDebug(lcSsl) << plainSocket << "SSLWrite returned" << err; +#endif if (err != noErr && err != errSSLWouldBlock) { - qWarning() << Q_FUNC_INFO << "SSL write failed with error:" << int(err); - setError("SSL write failed", QAbstractSocket::SslInternalError); + setError(QStringLiteral("SSLWrite failed: %1").arg(err), + QAbstractSocket::SslInternalError); break; } @@ -387,9 +390,17 @@ void QSslSocketBackendPrivate::transmit() size_t readBytes = 0; data.resize(4096); const OSStatus err = SSLRead(context, data.data(), data.size(), &readBytes); - if (err != noErr && err != errSSLWouldBlock) { - qWarning() << Q_FUNC_INFO << "SSLRead failed with:" << int(err); - setError("SSL read failed", QAbstractSocket::SslInternalError); +#ifdef QSSLSOCKET_DEBUG + qCDebug(lcSsl) << plainSocket << "SSLRead returned" << err; +#endif + if (err == errSSLClosedGraceful) { + shutdown = true; // the other side shut down, make sure we do not send shutdown ourselves + setError(QSslSocket::tr("The TLS/SSL connection has been closed"), + QAbstractSocket::RemoteHostClosedError); + break; + } else if (err != noErr && err != errSSLWouldBlock) { + setError(QStringLiteral("SSLRead failed: %1").arg(err), + QAbstractSocket::SslInternalError); break; } @@ -596,7 +607,7 @@ QSslCipher QSslSocketBackendPrivate::QSslCipher_from_SSLCipherSuite(SSLCipherSui } else if (ciph.d->name.startsWith("ECDH-") || ciph.d->name.startsWith("ECDHE-")) { ciph.d->keyExchangeMethod = QLatin1String("ECDH"); } else { - qWarning() << Q_FUNC_INFO << "Unknown Kx" << ciph.d->name; + qCWarning(lcSsl) << "Unknown Kx" << ciph.d->name; } if (bits.size() == 2 || bits.size() == 3) { @@ -606,7 +617,7 @@ QSslCipher QSslSocketBackendPrivate::QSslCipher_from_SSLCipherSuite(SSLCipherSui } else if (ciph.d->name.contains("-RSA-")) { ciph.d->authenticationMethod = QLatin1String("RSA"); } else { - qWarning() << Q_FUNC_INFO << "Unknown Au" << ciph.d->name; + qCWarning(lcSsl) << "Unknown Au" << ciph.d->name; } if (ciph.d->name.contains("RC4-")) { @@ -628,7 +639,7 @@ QSslCipher QSslSocketBackendPrivate::QSslCipher_from_SSLCipherSuite(SSLCipherSui } else if (ciph.d->name.contains("NULL-")) { ciph.d->encryptionMethod = QLatin1String("NULL"); } else { - qWarning() << Q_FUNC_INFO << "Unknown Enc" << ciph.d->name; + qCWarning(lcSsl) << "Unknown Enc" << ciph.d->name; } } return ciph; @@ -647,7 +658,6 @@ bool QSslSocketBackendPrivate::initSslContext() context = SSLCreateContext(Q_NULLPTR, side, kSSLStreamType); if (!context) { - qWarning() << Q_FUNC_INFO << "SSLCreateContext failed"; setError("SSLCreateContext failed", QAbstractSocket::SslInternalError); return false; } @@ -655,9 +665,9 @@ bool QSslSocketBackendPrivate::initSslContext() const OSStatus err = SSLSetIOFuncs(context, reinterpret_cast<SSLReadFunc>(&_q_SSLRead), reinterpret_cast<SSLWriteFunc>(&_q_SSLWrite)); if (err != noErr) { - qWarning() << Q_FUNC_INFO << "SSLSetIOFuncs failed with error " << int(err); destroySslContext(); - setError("SSLSetIOFuncs failed", QAbstractSocket::SslInternalError); + setError(QStringLiteral("SSLSetIOFuncs failed: %1").arg(err), + QAbstractSocket::SslInternalError); return false; } @@ -675,7 +685,6 @@ bool QSslSocketBackendPrivate::initSslContext() } if (!setSessionProtocol()) { - qWarning() << Q_FUNC_INFO << "failed to set protocol version"; destroySslContext(); setError("Failed to set protocol version", QAbstractSocket::SslInternalError); return false; @@ -688,7 +697,6 @@ bool QSslSocketBackendPrivate::initSslContext() // But for OS X versions below 10.8 we have to do it explicitly: const OSStatus err = SSLSetEnableCertVerify(context, false); if (err != noErr) { - qWarning() << Q_FUNC_INFO << "SSLSetEnableCertVerify failed:" << int(err); destroySslContext(); setError(QStringLiteral("SSLSetEnableCertVerify failed: %1").arg(err), QSslSocket::SslInternalError); @@ -711,7 +719,6 @@ bool QSslSocketBackendPrivate::initSslContext() err = SSLSetSessionOption(context, kSSLSessionOptionBreakOnCertRequested, true); if (err != noErr) { - qWarning() << Q_FUNC_INFO << "SSLSetSessionOption failed:" << int(err); destroySslContext(); setError(QStringLiteral("SSLSetSessionOption failed: %1").arg(err), QSslSocket::SslInternalError); @@ -729,7 +736,6 @@ bool QSslSocketBackendPrivate::initSslContext() } if (err != noErr) { - qWarning() << Q_FUNC_INFO << "failed to set SSL context option in server mode"; destroySslContext(); setError(QStringLiteral("failed to set SSL context option in server mode: %1").arg(err), QAbstractSocket::SslInternalError); @@ -781,7 +787,7 @@ bool QSslSocketBackendPrivate::setSessionCertificate(QString &errorDescription, OSStatus err = SecPKCS12Import(pkcs12, options, &items); if (err != noErr) { #ifdef QSSLSOCKET_DEBUG - qWarning() << Q_FUNC_INFO << plainSocket + qCWarning(lcSsl) << plainSocket << QStringLiteral("SecPKCS12Import failed: %1").arg(err); #endif errorCode = QAbstractSocket::SslInvalidUserDataError; @@ -791,7 +797,7 @@ bool QSslSocketBackendPrivate::setSessionCertificate(QString &errorDescription, if (!CFArrayGetCount(items)) { #ifdef QSSLSOCKET_DEBUG - qWarning() << Q_FUNC_INFO << plainSocket << "SecPKCS12Import returned no items"; + qCWarning(lcSsl) << plainSocket << "SecPKCS12Import returned no items"; #endif errorCode = QAbstractSocket::SslInvalidUserDataError; errorDescription = QStringLiteral("SecPKCS12Import returned no items"); @@ -802,7 +808,7 @@ bool QSslSocketBackendPrivate::setSessionCertificate(QString &errorDescription, SecIdentityRef identity = (SecIdentityRef)CFDictionaryGetValue(import, kSecImportItemIdentity); if (!identity) { #ifdef QSSLSOCKET_DEBUG - qWarning() << Q_FUNC_INFO << plainSocket << "SecPKCS12Import returned no identity"; + qCWarning(lcSsl) << plainSocket << "SecPKCS12Import returned no identity"; #endif errorCode = QAbstractSocket::SslInvalidUserDataError; errorDescription = QStringLiteral("SecPKCS12Import returned no identity"); @@ -827,7 +833,7 @@ bool QSslSocketBackendPrivate::setSessionCertificate(QString &errorDescription, err = SSLSetCertificate(context, certs); if (err != noErr) { #ifdef QSSLSOCKET_DEBUG - qWarning() << Q_FUNC_INFO << plainSocket + qCWarning(lcSsl) << plainSocket << QStringLiteral("Cannot set certificate and key: %1").arg(err); #endif errorCode = QAbstractSocket::SslInvalidUserDataError; @@ -851,41 +857,41 @@ bool QSslSocketBackendPrivate::setSessionProtocol() // return errSSLIllegalParam; // where MINIMUM_STREAM_VERSION is SSL_Version_3_0, MAXIMUM_STREAM_VERSION is TLS_Version_1_2. if (configuration.protocol == QSsl::SslV2) { - qDebug() << Q_FUNC_INFO << "protocol QSsl::SslV2 is disabled"; + qCDebug(lcSsl) << "protocol QSsl::SslV2 is disabled"; return false; } if (configuration.protocol == QSsl::SslV3) { #ifdef QSSLSOCKET_DEBUG - qDebug() << Q_FUNC_INFO << plainSocket << "requesting : SSLv3"; + qCDebug(lcSsl) << plainSocket << "requesting : SSLv3"; #endif err = SSLSetProtocolVersionMin(context, kSSLProtocol3); if (err == noErr) err = SSLSetProtocolVersionMax(context, kSSLProtocol3); } else if (configuration.protocol == QSsl::TlsV1_0) { #ifdef QSSLSOCKET_DEBUG - qDebug() << Q_FUNC_INFO << plainSocket << "requesting : TLSv1.0"; + qCDebug(lcSsl) << plainSocket << "requesting : TLSv1.0"; #endif err = SSLSetProtocolVersionMin(context, kTLSProtocol1); if (err == noErr) err = SSLSetProtocolVersionMax(context, kTLSProtocol1); } else if (configuration.protocol == QSsl::TlsV1_1) { #ifdef QSSLSOCKET_DEBUG - qDebug() << Q_FUNC_INFO << plainSocket << "requesting : TLSv1.1"; + qCDebug(lcSsl) << plainSocket << "requesting : TLSv1.1"; #endif err = SSLSetProtocolVersionMin(context, kTLSProtocol11); if (err == noErr) err = SSLSetProtocolVersionMax(context, kTLSProtocol11); } else if (configuration.protocol == QSsl::TlsV1_2) { #ifdef QSSLSOCKET_DEBUG - qDebug() << Q_FUNC_INFO << plainSocket << "requesting : TLSv1.2"; + qCDebug(lcSsl) << plainSocket << "requesting : TLSv1.2"; #endif err = SSLSetProtocolVersionMin(context, kTLSProtocol12); if (err == noErr) err = SSLSetProtocolVersionMax(context, kTLSProtocol12); } else if (configuration.protocol == QSsl::AnyProtocol) { #ifdef QSSLSOCKET_DEBUG - qDebug() << Q_FUNC_INFO << plainSocket << "requesting : any"; + qCDebug(lcSsl) << plainSocket << "requesting : any"; #endif // kSSLProtocol3, since kSSLProtocol2 is disabled: err = SSLSetProtocolVersionMin(context, kSSLProtocol3); @@ -893,41 +899,43 @@ bool QSslSocketBackendPrivate::setSessionProtocol() err = SSLSetProtocolVersionMax(context, kTLSProtocol12); } else if (configuration.protocol == QSsl::TlsV1SslV3) { #ifdef QSSLSOCKET_DEBUG - qDebug() << Q_FUNC_INFO << plainSocket << "requesting : SSLv3 - TLSv1.2"; + qCDebug(lcSsl) << plainSocket << "requesting : SSLv3 - TLSv1.2"; #endif err = SSLSetProtocolVersionMin(context, kSSLProtocol3); if (err == noErr) err = SSLSetProtocolVersionMax(context, kTLSProtocol12); } else if (configuration.protocol == QSsl::SecureProtocols) { #ifdef QSSLSOCKET_DEBUG - qDebug() << Q_FUNC_INFO << plainSocket << "requesting : TLSv1 - TLSv1.2"; + qCDebug(lcSsl) << plainSocket << "requesting : TLSv1 - TLSv1.2"; #endif err = SSLSetProtocolVersionMin(context, kTLSProtocol1); if (err == noErr) err = SSLSetProtocolVersionMax(context, kTLSProtocol12); } else if (configuration.protocol == QSsl::TlsV1_0OrLater) { #ifdef QSSLSOCKET_DEBUG - qDebug() << Q_FUNC_INFO << plainSocket << "requesting : TLSv1 - TLSv1.2"; + qCDebug(lcSsl) << plainSocket << "requesting : TLSv1 - TLSv1.2"; #endif err = SSLSetProtocolVersionMin(context, kTLSProtocol1); if (err == noErr) err = SSLSetProtocolVersionMax(context, kTLSProtocol12); } else if (configuration.protocol == QSsl::TlsV1_1OrLater) { #ifdef QSSLSOCKET_DEBUG - qDebug() << Q_FUNC_INFO << plainSocket << "requesting : TLSv1.1 - TLSv1.2"; + qCDebug(lcSsl) << plainSocket << "requesting : TLSv1.1 - TLSv1.2"; #endif err = SSLSetProtocolVersionMin(context, kTLSProtocol11); if (err == noErr) err = SSLSetProtocolVersionMax(context, kTLSProtocol12); } else if (configuration.protocol == QSsl::TlsV1_2OrLater) { #ifdef QSSLSOCKET_DEBUG - qDebug() << Q_FUNC_INFO << plainSocket << "requesting : TLSv1.2"; + qCDebug(lcSsl) << plainSocket << "requesting : TLSv1.2"; #endif err = SSLSetProtocolVersionMin(context, kTLSProtocol12); if (err == noErr) err = SSLSetProtocolVersionMax(context, kTLSProtocol12); } else { - qDebug() << Q_FUNC_INFO << "no protocol version found in the configuration"; +#ifdef QSSLSOCKET_DEBUG + qCDebug(lcSsl) << plainSocket << "no protocol version found in the configuration"; +#endif return false; } @@ -997,7 +1005,8 @@ bool QSslSocketBackendPrivate::verifyPeerTrust() if (err != noErr) { // We can not ignore this, it's not even about trust verification // probably ... - setError("SecTrustEvaluate failed", QAbstractSocket::SslHandshakeFailedError); + setError(QStringLiteral("SecTrustEvaluate failed: %1").arg(err), + QAbstractSocket::SslHandshakeFailedError); plainSocket->disconnectFromHost(); return false; } @@ -1132,7 +1141,7 @@ bool QSslSocketBackendPrivate::startHandshake() OSStatus err = SSLHandshake(context); #ifdef QSSLSOCKET_DEBUG - qDebug() << Q_FUNC_INFO << plainSocket << "SSLHandhake returned" << err; + qCDebug(lcSsl) << plainSocket << "SSLHandhake returned" << err; #endif if (err == errSSLWouldBlock) { @@ -1153,7 +1162,6 @@ bool QSslSocketBackendPrivate::startHandshake() // setSessionCertificate does not fail if we have no certificate. // Failure means a real error (invalid certificate, no private key, etc). if (!setSessionCertificate(errorDescription, errorCode)) { - qWarning() << Q_FUNC_INFO << "Failed to provide a client certificate"; setError(errorDescription, errorCode); return false; } else { @@ -1169,7 +1177,7 @@ bool QSslSocketBackendPrivate::startHandshake() return startHandshake(); } - setError(QStringLiteral("Error during SSL handshake: %1").arg(err), + setError(QStringLiteral("SSLHandshake failed: %1").arg(err), QAbstractSocket::SslHandshakeFailedError); plainSocket->disconnectFromHost(); return false; @@ -1177,7 +1185,7 @@ bool QSslSocketBackendPrivate::startHandshake() // Connection aborted during handshake phase. if (q->state() != QAbstractSocket::ConnectedState) { - qDebug() << Q_FUNC_INFO << "connection aborted"; + qCDebug(lcSsl) << "connection aborted"; return false; } diff --git a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp index 16cb94dded..06751de0ef 100644 --- a/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp +++ b/src/platformsupport/input/evdevkeyboard/qevdevkeyboardhandler.cpp @@ -379,17 +379,20 @@ QEvdevKeyboardHandler::KeycodeAction QEvdevKeyboardHandler::processKeycode(quint } if (!skip) { - qCDebug(qLcEvdevKeyMap, "Processing: uni=%04x, qt=%08x, qtmod=%08x", unicode, qtcode & ~modmask, (qtcode & modmask)); - //If NumLockOff and keypad key pressed remap event sent - if (!m_locks[1] && - (qtcode & Qt::KeypadModifier) && + // Up until now qtcode contained both the key and modifiers. Split it. + Qt::KeyboardModifiers qtmods = Qt::KeyboardModifiers(qtcode & modmask); + qtcode &= ~modmask; + + qCDebug(qLcEvdevKeyMap, "Processing: uni=%04x, qt=%08x, qtmod=%08x", unicode, qtcode, int(qtmods)); + + // If NumLockOff and keypad key pressed remap event sent + if (!m_locks[1] && (qtmods & Qt::KeypadModifier) && keycode >= 71 && keycode <= 83 && keycode != 74 && keycode != 78) { unicode = 0xffff; - int oldMask = (qtcode & modmask); switch (keycode) { case 71: //7 --> Home qtcode = Qt::Key_Home; @@ -425,11 +428,14 @@ QEvdevKeyboardHandler::KeycodeAction QEvdevKeyboardHandler::processKeycode(quint qtcode = Qt::Key_Delete; break; } - qtcode ^= oldMask; } - // send the result to the server - processKeyEvent(keycode, unicode, qtcode & ~modmask, Qt::KeyboardModifiers(qtcode & modmask), pressed, autorepeat); + // Map SHIFT + Tab to SHIFT + Backtab, QShortcutMap knows about this translation + if (qtcode == Qt::Key_Tab && (qtmods & Qt::ShiftModifier) == Qt::ShiftModifier) + qtcode = Qt::Key_Backtab; + + // Generate the QPA event. + processKeyEvent(keycode, unicode, qtcode, qtmods, pressed, autorepeat); } } return result; diff --git a/src/plugins/platforms/cocoa/qcocoaapplication.mm b/src/plugins/platforms/cocoa/qcocoaapplication.mm index 227ab05c25..d9919f1120 100644 --- a/src/plugins/platforms/cocoa/qcocoaapplication.mm +++ b/src/plugins/platforms/cocoa/qcocoaapplication.mm @@ -79,12 +79,12 @@ QT_USE_NAMESPACE - (void)QT_MANGLE_NAMESPACE(qt_setDockMenu):(NSMenu *)newMenu { - [[QCocoaApplicationDelegate sharedDelegate] setDockMenu:newMenu]; + [[QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) sharedDelegate] setDockMenu:newMenu]; } - (QT_MANGLE_NAMESPACE(QCocoaMenuLoader) *)QT_MANGLE_NAMESPACE(qt_qcocoamenuLoader) { - return [[QCocoaApplicationDelegate sharedDelegate] menuLoader]; + return [[QT_MANGLE_NAMESPACE(QCocoaApplicationDelegate) sharedDelegate] menuLoader]; } - (int)QT_MANGLE_NAMESPACE(qt_validModesForFontPanel):(NSFontPanel *)fontPanel @@ -147,9 +147,9 @@ static const QByteArray q_macLocalEventType = QByteArrayLiteral("mac_generic_NSE @end -@implementation QNSApplication +@implementation QT_MANGLE_NAMESPACE(QNSApplication) -- (void)qt_sendEvent_original:(NSEvent *)event +- (void)QT_MANGLE_NAMESPACE(qt_sendEvent_original):(NSEvent *)event { Q_UNUSED(event); // This method will only be used as a signature @@ -157,14 +157,14 @@ static const QByteArray q_macLocalEventType = QByteArrayLiteral("mac_generic_NSE // containing the original [NSApplication sendEvent:] implementation } -- (void)qt_sendEvent_replacement:(NSEvent *)event +- (void)QT_MANGLE_NAMESPACE(qt_sendEvent_replacement):(NSEvent *)event { // This method (or its implementation to be precise) will // be called instead of sendEvent if redirection occurs. // 'self' will then be an instance of NSApplication // (and not QNSApplication) if (![NSApp QT_MANGLE_NAMESPACE(qt_filterEvent):event]) - [self qt_sendEvent_original:event]; + [self QT_MANGLE_NAMESPACE(qt_sendEvent_original):event]; } - (void)sendEvent:(NSEvent *)event @@ -187,7 +187,7 @@ void qt_redirectNSApplicationSendEvent() // can be unloaded. return; - if ([NSApp isMemberOfClass:[QNSApplication class]]) { + if ([NSApp isMemberOfClass:[QT_MANGLE_NAMESPACE(QNSApplication) class]]) { // No need to change implementation since Qt // already controls a subclass of NSApplication return; @@ -200,9 +200,9 @@ void qt_redirectNSApplicationSendEvent() qt_cocoa_change_implementation( [NSApplication class], @selector(sendEvent:), - [QNSApplication class], - @selector(qt_sendEvent_replacement:), - @selector(qt_sendEvent_original:)); + [QT_MANGLE_NAMESPACE(QNSApplication) class], + @selector(QT_MANGLE_NAMESPACE(qt_sendEvent_replacement):), + @selector(QT_MANGLE_NAMESPACE(qt_sendEvent_original):)); } void qt_resetNSApplicationSendEvent() diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 3caed80e38..4309702fd5 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -1436,7 +1436,7 @@ static QTabletEvent::TabletDevice wacomTabletDevice(NSEvent *theEvent) if (eventType == QEvent::KeyPress) { if (m_composingText.isEmpty()) - m_sendKeyEvent = !QWindowSystemInterface::tryHandleShortcutEvent(focusWindow, timestamp, keyCode, modifiers, text); + m_sendKeyEvent = !QWindowSystemInterface::tryHandleShortcutEvent(focusWindow, timestamp, keyCode, modifiers, text, [nsevent isARepeat], 1); QObject *fo = QGuiApplication::focusObject(); if (m_sendKeyEvent && fo) { diff --git a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp index a544b9d81e..1c5b114efd 100644 --- a/src/plugins/platforms/windows/qwindowsfontdatabase.cpp +++ b/src/plugins/platforms/windows/qwindowsfontdatabase.cpp @@ -1169,23 +1169,19 @@ QT_WARNING_POP CustomFontFileLoader fontFileLoader; fontFileLoader.addKey(this, fontData); - IDWriteFactory *factory = 0; - HRESULT hres = DWriteCreateFactory(DWRITE_FACTORY_TYPE_SHARED, - __uuidof(IDWriteFactory), - reinterpret_cast<IUnknown **>(&factory)); - if (FAILED(hres)) { - qErrnoWarning(hres, "%s: DWriteCreateFactory failed", __FUNCTION__); + QSharedPointer<QWindowsFontEngineData> fontEngineData = sharedFontData(); + if (!initDirectWrite(fontEngineData.data())) return 0; - } IDWriteFontFile *fontFile = 0; void *key = this; - hres = factory->CreateCustomFontFileReference(&key, sizeof(void *), - fontFileLoader.loader(), &fontFile); + HRESULT hres = fontEngineData->directWriteFactory->CreateCustomFontFileReference(&key, + sizeof(void *), + fontFileLoader.loader(), + &fontFile); if (FAILED(hres)) { qErrnoWarning(hres, "%s: CreateCustomFontFileReference failed", __FUNCTION__); - factory->Release(); return 0; } @@ -1196,30 +1192,31 @@ QT_WARNING_POP fontFile->Analyze(&isSupportedFontType, &fontFileType, &fontFaceType, &numberOfFaces); if (!isSupportedFontType) { fontFile->Release(); - factory->Release(); return 0; } IDWriteFontFace *directWriteFontFace = 0; - hres = factory->CreateFontFace(fontFaceType, 1, &fontFile, 0, DWRITE_FONT_SIMULATIONS_NONE, - &directWriteFontFace); + hres = fontEngineData->directWriteFactory->CreateFontFace(fontFaceType, + 1, + &fontFile, + 0, + DWRITE_FONT_SIMULATIONS_NONE, + &directWriteFontFace); if (FAILED(hres)) { qErrnoWarning(hres, "%s: CreateFontFace failed", __FUNCTION__); fontFile->Release(); - factory->Release(); return 0; } fontFile->Release(); fontEngine = new QWindowsFontEngineDirectWrite(directWriteFontFace, pixelSize, - sharedFontData()); + fontEngineData); // Get font family from font data fontEngine->fontDef.family = font.familyName(); directWriteFontFace->Release(); - factory->Release(); } #endif diff --git a/src/plugins/platforms/windows/qwindowsmime.cpp b/src/plugins/platforms/windows/qwindowsmime.cpp index d8ccccdf45..f86ab9fee3 100644 --- a/src/plugins/platforms/windows/qwindowsmime.cpp +++ b/src/plugins/platforms/windows/qwindowsmime.cpp @@ -995,6 +995,7 @@ QVector<FORMATETC> QWindowsMimeImage::formatsForMime(const QString &mimeType, co if (!image.isNull() && image.hasAlphaChannel()) formatetcs += setCf(CF_DIBV5); formatetcs += setCf(CF_DIB); + formatetcs += setCf(CF_PNG); // QTBUG-86848, Paste into GIMP queries for PNG. } return formatetcs; } @@ -1025,13 +1026,15 @@ bool QWindowsMimeImage::canConvertFromMime(const FORMATETC &formatetc, const QMi return false; // QTBUG-11463, deny CF_DIB support for images with alpha to prevent loss of // transparency in conversion. - return cf == CF_DIBV5 || (cf == CF_DIB && !image.hasAlphaChannel()); + return cf == CF_DIBV5 + || (cf == CF_DIB && !image.hasAlphaChannel()) + || cf == int(CF_PNG); } bool QWindowsMimeImage::convertFromMime(const FORMATETC &formatetc, const QMimeData *mimeData, STGMEDIUM * pmedium) const { int cf = getCf(formatetc); - if ((cf == CF_DIB || cf == CF_DIBV5) && mimeData->hasImage()) { + if ((cf == CF_DIB || cf == CF_DIBV5 || cf == int(CF_PNG)) && mimeData->hasImage()) { QImage img = qvariant_cast<QImage>(mimeData->imageData()); if (img.isNull()) return false; @@ -1042,6 +1045,12 @@ bool QWindowsMimeImage::convertFromMime(const FORMATETC &formatetc, const QMimeD const QByteArray ba = writeDib(img); if (!ba.isEmpty()) return setData(ba, pmedium); + } else if (cf == int(CF_PNG)) { + QBuffer buffer(&ba); + const bool written = buffer.open(QIODevice::WriteOnly) && img.save(&buffer, "PNG"); + buffer.close(); + if (written) + return setData(ba, pmedium); } else { QDataStream s(&ba, QIODevice::WriteOnly); s.setByteOrder(QDataStream::LittleEndian);// Intel byte order #### diff --git a/src/plugins/platforms/windows/qwindowsopengltester.cpp b/src/plugins/platforms/windows/qwindowsopengltester.cpp index 244fc72332..52e83395d1 100644 --- a/src/plugins/platforms/windows/qwindowsopengltester.cpp +++ b/src/plugins/platforms/windows/qwindowsopengltester.cpp @@ -224,7 +224,7 @@ QWindowsOpenGLTester::Renderers QWindowsOpenGLTester::detectSupportedRenderers(c #elif defined(Q_OS_WINCE) return QWindowsOpenGLTester::Gles; #else - QOpenGLConfig::Gpu qgpu = QOpenGLConfig::Gpu::fromDevice(gpu.deviceId, gpu.vendorId, gpu.driverVersion, gpu.description); + QOpenGLConfig::Gpu qgpu = QOpenGLConfig::Gpu::fromDevice(gpu.vendorId, gpu.deviceId, gpu.driverVersion, gpu.description); SupportedRenderersCache *srCache = supportedRenderersCache(); SupportedRenderersCache::const_iterator it = srCache->find(qgpu); if (it != srCache->cend()) diff --git a/src/plugins/platforms/xcb/qxcbconnection.cpp b/src/plugins/platforms/xcb/qxcbconnection.cpp index f324942c8b..1fe46ff290 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.cpp +++ b/src/plugins/platforms/xcb/qxcbconnection.cpp @@ -454,6 +454,7 @@ QXcbConnection::QXcbConnection(QXcbNativeInterface *nativeInterface, bool canGra , has_xkb(false) , m_buttons(0) , m_focusWindow(0) + , m_clientLeader(0) , m_systemTrayTracker(0) , m_glIntegration(Q_NULLPTR) , m_xiGrab(false) @@ -1336,6 +1337,58 @@ xcb_window_t QXcbConnection::rootWindow() return s ? s->root() : 0; } +xcb_window_t QXcbConnection::clientLeader() +{ + if (m_clientLeader == 0) { + m_clientLeader = xcb_generate_id(xcb_connection()); + QXcbScreen *screen = primaryScreen(); + Q_XCB_CALL(xcb_create_window(xcb_connection(), + XCB_COPY_FROM_PARENT, + m_clientLeader, + screen->root(), + 0, 0, 1, 1, + 0, + XCB_WINDOW_CLASS_INPUT_OUTPUT, + screen->screen()->root_visual, + 0, 0)); +#ifndef QT_NO_DEBUG + QByteArray ba("Qt client leader window"); + Q_XCB_CALL(xcb_change_property(xcb_connection(), + XCB_PROP_MODE_REPLACE, + m_clientLeader, + atom(QXcbAtom::_NET_WM_NAME), + atom(QXcbAtom::UTF8_STRING), + 8, + ba.length(), + ba.constData())); +#endif + Q_XCB_CALL(xcb_change_property(xcb_connection(), + XCB_PROP_MODE_REPLACE, + m_clientLeader, + atom(QXcbAtom::WM_CLIENT_LEADER), + XCB_ATOM_WINDOW, + 32, + 1, + &m_clientLeader)); + +#if !defined(QT_NO_SESSIONMANAGER) && defined(XCB_USE_SM) + // If we are session managed, inform the window manager about it + QByteArray session = qGuiApp->sessionId().toLatin1(); + if (!session.isEmpty()) { + Q_XCB_CALL(xcb_change_property(xcb_connection(), + XCB_PROP_MODE_REPLACE, + m_clientLeader, + atom(QXcbAtom::SM_CLIENT_ID), + XCB_ATOM_STRING, + 8, + session.length(), + session.constData())); + } +#endif + } + return m_clientLeader; +} + #ifdef XCB_USE_XLIB void *QXcbConnection::xlib_display() const { @@ -1578,6 +1631,7 @@ static const char * xcb_atomnames = { "_KDE_NET_WM_WINDOW_TYPE_OVERRIDE\0" "_KDE_NET_WM_FRAME_STRUT\0" + "_NET_FRAME_EXTENTS\0" "_NET_STARTUP_INFO\0" "_NET_STARTUP_INFO_BEGIN\0" diff --git a/src/plugins/platforms/xcb/qxcbconnection.h b/src/plugins/platforms/xcb/qxcbconnection.h index 90603ac9bc..7016b99425 100644 --- a/src/plugins/platforms/xcb/qxcbconnection.h +++ b/src/plugins/platforms/xcb/qxcbconnection.h @@ -194,6 +194,7 @@ namespace QXcbAtom { _KDE_NET_WM_WINDOW_TYPE_OVERRIDE, _KDE_NET_WM_FRAME_STRUT, + _NET_FRAME_EXTENTS, _NET_STARTUP_INFO, _NET_STARTUP_INFO_BEGIN, @@ -402,6 +403,7 @@ public: QXcbWMSupport *wmSupport() const { return m_wmSupport.data(); } xcb_window_t rootWindow(); + xcb_window_t clientLeader(); bool hasDefaultVisualId() const { return m_defaultVisualId != UINT_MAX; } xcb_visualid_t defaultVisualId() const { return m_defaultVisualId; } @@ -641,6 +643,7 @@ private: QXcbWindow *m_focusWindow; + xcb_window_t m_clientLeader; QByteArray m_startupId; QXcbSystemTrayTracker *m_systemTrayTracker; QXcbGlIntegration *m_glIntegration; diff --git a/src/plugins/platforms/xcb/qxcbscreen.cpp b/src/plugins/platforms/xcb/qxcbscreen.cpp index 040cea1cb2..c7f811491c 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.cpp +++ b/src/plugins/platforms/xcb/qxcbscreen.cpp @@ -170,38 +170,6 @@ QXcbScreen::QXcbScreen(QXcbConnection *connection, QXcbVirtualDesktop *virtualDe else m_syncRequestSupported = true; - m_clientLeader = xcb_generate_id(xcb_connection()); - Q_XCB_CALL2(xcb_create_window(xcb_connection(), - XCB_COPY_FROM_PARENT, - m_clientLeader, - screen()->root, - 0, 0, 1, 1, - 0, - XCB_WINDOW_CLASS_INPUT_OUTPUT, - screen()->root_visual, - 0, 0), connection); -#ifndef QT_NO_DEBUG - QByteArray ba("Qt client leader window for screen "); - ba += m_outputName.toUtf8(); - Q_XCB_CALL2(xcb_change_property(xcb_connection(), - XCB_PROP_MODE_REPLACE, - m_clientLeader, - atom(QXcbAtom::_NET_WM_NAME), - atom(QXcbAtom::UTF8_STRING), - 8, - ba.length(), - ba.constData()), connection); -#endif - - Q_XCB_CALL2(xcb_change_property(xcb_connection(), - XCB_PROP_MODE_REPLACE, - m_clientLeader, - atom(QXcbAtom::WM_CLIENT_LEADER), - XCB_ATOM_WINDOW, - 32, - 1, - &m_clientLeader), connection); - xcb_depth_iterator_t depth_iterator = xcb_screen_allowed_depths_iterator(screen()); diff --git a/src/plugins/platforms/xcb/qxcbscreen.h b/src/plugins/platforms/xcb/qxcbscreen.h index 44519470e9..ccc30c0b84 100644 --- a/src/plugins/platforms/xcb/qxcbscreen.h +++ b/src/plugins/platforms/xcb/qxcbscreen.h @@ -116,8 +116,6 @@ public: xcb_randr_crtc_t crtc() const { return m_crtc; } xcb_randr_mode_t mode() const { return m_mode; } - xcb_window_t clientLeader() const { return m_clientLeader; } - void windowShown(QXcbWindow *window); QString windowManagerName() const { return m_windowManagerName; } bool syncRequestSupported() const { return m_syncRequestSupported; } @@ -173,7 +171,6 @@ private: Qt::ScreenOrientation m_orientation; QString m_windowManagerName; bool m_syncRequestSupported; - xcb_window_t m_clientLeader; QMap<xcb_visualid_t, xcb_visualtype_t> m_visuals; QMap<xcb_visualid_t, quint8> m_visualDepths; QXcbCursor *m_cursor; diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index 05d7292430..fb2fca43fa 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -623,7 +623,7 @@ void QXcbWindow::create() xcb_set_wm_hints(xcb_connection(), m_window, &hints); - xcb_window_t leader = platformScreen->clientLeader(); + xcb_window_t leader = connection()->clientLeader(); Q_XCB_CALL(xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, atom(QXcbAtom::WM_CLIENT_LEADER), XCB_ATOM_WINDOW, 32, 1, &leader)); @@ -746,6 +746,22 @@ void QXcbWindow::setGeometry(const QRect &rect) QMargins QXcbWindow::frameMargins() const { if (m_dirtyFrameMargins) { + if (connection()->wmSupport()->isSupportedByWM(atom(QXcbAtom::_NET_FRAME_EXTENTS))) { + xcb_get_property_cookie_t cookie = xcb_get_property(xcb_connection(), false, m_window, + atom(QXcbAtom::_NET_FRAME_EXTENTS), XCB_ATOM_CARDINAL, 0, 4); + QScopedPointer<xcb_get_property_reply_t, QScopedPointerPodDeleter> reply( + xcb_get_property_reply(xcb_connection(), cookie, NULL)); + if (reply && reply->type == XCB_ATOM_CARDINAL && reply->format == 32 && reply->value_len == 4) { + quint32 *data = (quint32 *)xcb_get_property_value(reply.data()); + // _NET_FRAME_EXTENTS format is left, right, top, bottom + m_frameMargins = QMargins(data[0], data[2], data[1], data[3]); + m_dirtyFrameMargins = false; + return m_frameMargins; + } + } + + // _NET_FRAME_EXTENTS property is not available, so + // walk up the window tree to get the frame parent xcb_window_t window = m_window; xcb_window_t parent = m_window; @@ -859,7 +875,7 @@ void QXcbWindow::show() // Default to client leader if there is no transient parent, else modal dialogs can // be hidden by their parents. if (!transientXcbParent) - transientXcbParent = xcbScreen()->clientLeader(); + transientXcbParent = connection()->clientLeader(); if (transientXcbParent) { // ICCCM 4.1.2.6 Q_XCB_CALL(xcb_change_property(xcb_connection(), XCB_PROP_MODE_REPLACE, m_window, XCB_ATOM_WM_TRANSIENT_FOR, XCB_ATOM_WINDOW, 32, @@ -2446,6 +2462,8 @@ void QXcbWindow::handlePropertyNotifyEvent(const xcb_property_notify_event_t *ev m_windowState = newState; } return; + } else if (event->atom == atom(QXcbAtom::_NET_FRAME_EXTENTS)) { + m_dirtyFrameMargins = true; } else if (event->atom == atom(QXcbAtom::_NET_WORKAREA) && xcbScreen() && event->window == xcbScreen()->root()) { xcbScreen()->updateGeometry(event->time); } diff --git a/src/tools/rcc/rcc.cpp b/src/tools/rcc/rcc.cpp index 9e4fe04e12..6f00168b72 100644 --- a/src/tools/rcc/rcc.cpp +++ b/src/tools/rcc/rcc.cpp @@ -693,7 +693,8 @@ QStringList RCCResourceLibrary::dataFiles() const RCCFileInfo *child = it.value(); if (child->m_flags & RCCFileInfo::Directory) pending.push(child); - ret.append(child->m_fileInfo.filePath()); + else + ret.append(child->m_fileInfo.filePath()); } } return ret; diff --git a/src/widgets/doc/src/graphicsview.qdoc b/src/widgets/doc/src/graphicsview.qdoc index 6895466977..6f3bc68f98 100644 --- a/src/widgets/doc/src/graphicsview.qdoc +++ b/src/widgets/doc/src/graphicsview.qdoc @@ -493,9 +493,6 @@ but Graphics View currently doesn't support the Qt::Sheet and Qt::Drawer flags that are common on OS X. - The capabilities of QGraphicsWidget are expected to grow depending - on community feedback. - \section3 QGraphicsLayout QGraphicsLayout is part of a second-generation layout framework diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp index 1fdbe0fc18..0259ce216b 100644 --- a/src/widgets/graphicsview/qgraphicsitem.cpp +++ b/src/widgets/graphicsview/qgraphicsitem.cpp @@ -428,7 +428,7 @@ \note If both this flag and ItemClipsChildrenToShape are set, the clip will be enforced. This is equivalent to just setting ItemClipsChildrenToShape. - . + This flag was introduced in Qt 5.4. */ diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 9ea5fd6018..c3fed921f9 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -289,8 +289,15 @@ QWidgetPrivate::QWidgetPrivate(int version) return; } +#ifdef QT_BUILD_INTERNAL + // Don't check the version parameter in internal builds. + // This allows incompatible versions to be loaded, possibly for testing. + Q_UNUSED(version); +#else if (version != QObjectPrivateVersion) - qFatal("Cannot mix incompatible Qt libraries"); + qFatal("Cannot mix incompatible Qt library (version 0x%x) with this library (version 0x%x)", + version, QObjectPrivateVersion); +#endif isWidget = true; memset(high_attributes, 0, sizeof(high_attributes)); diff --git a/src/widgets/styles/qwindowsvistastyle.cpp b/src/widgets/styles/qwindowsvistastyle.cpp index daa8ab12a9..b8ed82fee3 100644 --- a/src/widgets/styles/qwindowsvistastyle.cpp +++ b/src/widgets/styles/qwindowsvistastyle.cpp @@ -396,7 +396,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt case PE_IndicatorBranch: { - XPThemeData theme(0, painter, QWindowsXPStylePrivate::TreeViewTheme); + XPThemeData theme(widget, painter, QWindowsXPStylePrivate::TreeViewTheme); static int decoration_size = 0; if (d->initTreeViewTheming() && theme.isValid() && !decoration_size) { XPThemeData themeSize = theme; @@ -657,6 +657,8 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt newStyle = !qobject_cast<const QTableView*>(view); selectionBehavior = view->selectionBehavior(); selectionMode = view->selectionMode(); + } else if (!widget) { + newStyle = !QStyleHelper::hasAncestor(option->styleObject, QAccessible::MenuItem) ; } if (newStyle && (vopt = qstyleoption_cast<const QStyleOptionViewItem *>(option))) { @@ -710,7 +712,7 @@ void QWindowsVistaStyle::drawPrimitive(PrimitiveElement element, const QStyleOpt state = LISS_HOT; QPainter pixmapPainter(&pixmap); - XPThemeData theme(0, &pixmapPainter, + XPThemeData theme(widget, &pixmapPainter, QWindowsXPStylePrivate::TreeViewTheme, LVP_LISTITEM, state, QRect(0, 0, sectionSize.width(), sectionSize.height())); if (d->initTreeViewTheming() && theme.isValid()) { diff --git a/src/widgets/styles/qwindowsxpstyle.cpp b/src/widgets/styles/qwindowsxpstyle.cpp index 54271c5ce8..7776773b87 100644 --- a/src/widgets/styles/qwindowsxpstyle.cpp +++ b/src/widgets/styles/qwindowsxpstyle.cpp @@ -1224,7 +1224,7 @@ void QWindowsXPStyle::polish(QWidget *widget) if (!d->hasInitColors) { // Get text color for group box labels COLORREF cref; - XPThemeData theme(0, 0, QWindowsXPStylePrivate::ButtonTheme, 0, 0); + XPThemeData theme(widget, 0, QWindowsXPStylePrivate::ButtonTheme, 0, 0); QWindowsXPStylePrivate::pGetThemeColor(theme.handle(), BP_GROUPBOX, GBS_NORMAL, TMT_TEXTCOLOR, &cref); d->groupBoxTextColor = qRgb(GetRValue(cref), GetGValue(cref), GetBValue(cref)); QWindowsXPStylePrivate::pGetThemeColor(theme.handle(), BP_GROUPBOX, GBS_DISABLED, TMT_TEXTCOLOR, &cref); @@ -1540,7 +1540,7 @@ case PE_Frame: return; themeNumber = QWindowsXPStylePrivate::ListViewTheme; partId = LVP_LISTGROUP; - XPThemeData theme(0, 0, themeNumber, partId, 0); + XPThemeData theme(widget, 0, themeNumber, partId, 0); if (!(flags & State_Enabled)) stateId = ETS_DISABLED; diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 232ba6698e..2958d662c7 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -2093,8 +2093,10 @@ void QComboBoxPrivate::setCurrentIndex(const QModelIndex &mi) const QString newText = itemText(normalized); if (lineEdit->text() != newText) { lineEdit->setText(newText); +#ifndef QT_NO_COMPLETER if (lineEdit->completer()) lineEdit->completer()->setCompletionPrefix(newText); +#endif } updateLineEditGeometry(); } diff --git a/src/widgets/widgets/qdial.cpp b/src/widgets/widgets/qdial.cpp index b6ec54997b..3f081e3a83 100644 --- a/src/widgets/widgets/qdial.cpp +++ b/src/widgets/widgets/qdial.cpp @@ -202,9 +202,8 @@ int QDialPrivate::valueFromPoint(const QPoint &p) const to draw every one, QDial will skip notches to try and draw a uniform set (e.g. by drawing every second or third notch). - Like the slider, the dial makes the QAbstractSlider functions - setValue(), addLine(), subtractLine(), addPage() and - subtractPage() available as slots. + Like the slider, the dial makes the QAbstractSlider function setValue() + available as a slot. The dial's keyboard interface is fairly simple: The \uicontrol{left}/\uicontrol{up} and \uicontrol{right}/\uicontrol{down} arrow keys adjust |