diff options
Diffstat (limited to 'src')
92 files changed, 709 insertions, 600 deletions
diff --git a/src/corelib/Qt5CTestMacros.cmake b/src/corelib/Qt5CTestMacros.cmake index 126a348b47..71097aadbf 100644 --- a/src/corelib/Qt5CTestMacros.cmake +++ b/src/corelib/Qt5CTestMacros.cmake @@ -8,6 +8,14 @@ # # We mean it. +message("CMAKE_VERSION: ${CMAKE_VERSION}") +message("CMAKE_PREFIX_PATH: ${CMAKE_PREFIX_PATH}") +message("CMAKE_MODULES_UNDER_TEST: ${CMAKE_MODULES_UNDER_TEST}") +foreach(_mod ${CMAKE_MODULES_UNDER_TEST}) + message("CMAKE_${_mod}_MODULE_MAJOR_VERSION: ${CMAKE_${_mod}_MODULE_MAJOR_VERSION}") + message("CMAKE_${_mod}_MODULE_MINOR_VERSION: ${CMAKE_${_mod}_MODULE_MINOR_VERSION}") + message("CMAKE_${_mod}_MODULE_PATCH_VERSION: ${CMAKE_${_mod}_MODULE_PATCH_VERSION}") +endforeach() set(BUILD_OPTIONS_LIST) diff --git a/src/corelib/doc/snippets/code/src_corelib_io_qsettings.cpp b/src/corelib/doc/snippets/code/src_corelib_io_qsettings.cpp index ca3f8eb8d3..bdbd4a4be3 100644 --- a/src/corelib/doc/snippets/code/src_corelib_io_qsettings.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_io_qsettings.cpp @@ -186,7 +186,7 @@ settings.endArray(); //! [17] QSettings settings; -settings.setValue("fridge/color", Qt::white); +settings.setValue("fridge/color", QColor(Qt::white)); settings.setValue("fridge/size", QSize(32, 96)); settings.setValue("sofa", true); settings.setValue("tv", false); @@ -205,7 +205,7 @@ keys = settings.allKeys(); //! [19] QSettings settings; -settings.setValue("fridge/color", Qt::white); +settings.setValue("fridge/color", QColor(Qt::white)); settings.setValue("fridge/size", QSize(32, 96)); settings.setValue("sofa", true); settings.setValue("tv", false); @@ -224,7 +224,7 @@ keys = settings.childKeys(); //! [21] QSettings settings; -settings.setValue("fridge/color", Qt::white); +settings.setValue("fridge/color", QColor(Qt::white)); settings.setValue("fridge/size", QSize(32, 96)); settings.setValue("sofa", true); settings.setValue("tv", false); diff --git a/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp b/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp index 68df53e0da..6a2305cc85 100644 --- a/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_kernel_qobject.cpp @@ -367,23 +367,6 @@ public: }; //! [35] - -//! [36] -Q_PROPERTY(type name - READ getFunction - [WRITE setFunction] - [RESET resetFunction] - [NOTIFY notifySignal] - [REVISION int] - [DESIGNABLE bool] - [SCRIPTABLE bool] - [STORED bool] - [USER bool] - [CONSTANT] - [FINAL]) -//! [36] - - //! [37] Q_PROPERTY(QString title READ title WRITE setTitle USER true) //! [37] diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index fb96ad2732..27fc2d4038 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -467,7 +467,7 @@ # if __INTEL_COMPILER < 1200 # define Q_NO_TEMPLATE_FRIENDS # endif -# if defined(_CHAR16T) || __cplusplus >= 201103L +# if __cplusplus >= 201103L # define Q_COMPILER_VARIADIC_MACROS # if __INTEL_COMPILER >= 1200 # define Q_COMPILER_AUTO_TYPE diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp index 067154033c..ac347655bc 100644 --- a/src/corelib/global/qglobal.cpp +++ b/src/corelib/global/qglobal.cpp @@ -2068,11 +2068,11 @@ namespace { // version in portable code. However, it's impossible to do that if // _GNU_SOURCE is defined so we use C++ overloading to decide what to do // depending on the return type - static inline QString fromstrerror_helper(int, const QByteArray &buf) + static inline Q_DECL_UNUSED QString fromstrerror_helper(int, const QByteArray &buf) { return QString::fromLocal8Bit(buf); } - static inline QString fromstrerror_helper(const char *str, const QByteArray &) + static inline Q_DECL_UNUSED QString fromstrerror_helper(const char *str, const QByteArray &) { return QString::fromLocal8Bit(str); } diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index e7554e14f7..18f293bba5 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -494,6 +494,8 @@ QT_END_NAMESPACE # include <stdio.h> # include <stdlib.h> +#include "private/qcoreapplication_p.h" + extern const char qt_core_interpreter[] __attribute__((section(".interp"))) = ELF_INTERPRETER; @@ -516,8 +518,8 @@ void qt_core_boilerplate() QT_PREPEND_NAMESPACE(qDumpCPUFeatures)(); #ifdef QT_EVAL - extern void qt_core_eval_init(uint); - qt_core_eval_init(1); + extern void qt_core_eval_init(QCoreApplicationPrivate::Type); + qt_core_eval_init(QCoreApplicationPrivate::Tty); #endif exit(0); diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp index 2c9ed9da3d..e8904b0ab7 100644 --- a/src/corelib/io/qfilesystemengine_win.cpp +++ b/src/corelib/io/qfilesystemengine_win.cpp @@ -1049,7 +1049,8 @@ bool QFileSystemEngine::createDirectory(const QFileSystemEntry &entry, bool crea if (slash) { QString chunk = dirName.left(slash); if (!mkDir(chunk)) { - if (GetLastError() == ERROR_ALREADY_EXISTS) { + const DWORD lastError = GetLastError(); + if (lastError == ERROR_ALREADY_EXISTS || lastError == ERROR_ACCESS_DENIED) { bool existed = false; if (isDirPath(chunk, &existed) && existed) continue; diff --git a/src/corelib/io/qfilesystemwatcher_win.cpp b/src/corelib/io/qfilesystemwatcher_win.cpp index 6ac6a3fbd9..bb16df04ad 100644 --- a/src/corelib/io/qfilesystemwatcher_win.cpp +++ b/src/corelib/io/qfilesystemwatcher_win.cpp @@ -95,7 +95,7 @@ QStringList QWindowsFileSystemWatcherEngine::addPaths(const QStringList &paths, ) #endif normalPath.chop(1); - QFileInfo fileInfo(normalPath.toLower()); + QFileInfo fileInfo(normalPath); if (!fileInfo.exists()) continue; @@ -136,15 +136,16 @@ QStringList QWindowsFileSystemWatcherEngine::addPaths(const QStringList &paths, thread = *jt; QMutexLocker locker(&(thread->mutex)); - handle = thread->handleForDir.value(absolutePath); + handle = thread->handleForDir.value(QFileSystemWatcherPathKey(absolutePath)); if (handle.handle != INVALID_HANDLE_VALUE && handle.flags == flags) { // found a thread now insert... DEBUG() << "Found a thread" << thread; - QHash<QString, QWindowsFileSystemWatcherEngine::PathInfo> &h - = thread->pathInfoForHandle[handle.handle]; - if (!h.contains(fileInfo.absoluteFilePath())) { - thread->pathInfoForHandle[handle.handle].insert(fileInfo.absoluteFilePath(), pathInfo); + QWindowsFileSystemWatcherEngineThread::PathInfoHash &h = + thread->pathInfoForHandle[handle.handle]; + const QFileSystemWatcherPathKey key(fileInfo.absoluteFilePath()); + if (!h.contains(key)) { + thread->pathInfoForHandle[handle.handle].insert(key, pathInfo); if (isDir) directories->append(path); else @@ -177,9 +178,9 @@ QStringList QWindowsFileSystemWatcherEngine::addPaths(const QStringList &paths, DEBUG() << "Added handle" << handle.handle << "for" << absolutePath << "to watch" << fileInfo.absoluteFilePath() << "to existing thread " << thread; thread->handles.append(handle.handle); - thread->handleForDir.insert(absolutePath, handle); + thread->handleForDir.insert(QFileSystemWatcherPathKey(absolutePath), handle); - thread->pathInfoForHandle[handle.handle].insert(fileInfo.absoluteFilePath(), pathInfo); + thread->pathInfoForHandle[handle.handle].insert(QFileSystemWatcherPathKey(fileInfo.absoluteFilePath()), pathInfo); if (isDir) directories->append(path); else @@ -195,9 +196,9 @@ QStringList QWindowsFileSystemWatcherEngine::addPaths(const QStringList &paths, QWindowsFileSystemWatcherEngineThread *thread = new QWindowsFileSystemWatcherEngineThread(); DEBUG() << " ###Creating new thread" << thread << "(" << (threads.count()+1) << "threads)"; thread->handles.append(handle.handle); - thread->handleForDir.insert(absolutePath, handle); + thread->handleForDir.insert(QFileSystemWatcherPathKey(absolutePath), handle); - thread->pathInfoForHandle[handle.handle].insert(fileInfo.absoluteFilePath(), pathInfo); + thread->pathInfoForHandle[handle.handle].insert(QFileSystemWatcherPathKey(fileInfo.absoluteFilePath()), pathInfo); if (isDir) directories->append(path); else @@ -230,7 +231,7 @@ QStringList QWindowsFileSystemWatcherEngine::removePaths(const QStringList &path QString normalPath = path; if (normalPath.endsWith(QLatin1Char('/')) || normalPath.endsWith(QLatin1Char('\\'))) normalPath.chop(1); - QFileInfo fileInfo(normalPath.toLower()); + QFileInfo fileInfo(normalPath); DEBUG() << "removing" << normalPath; QString absolutePath = fileInfo.absoluteFilePath(); QList<QWindowsFileSystemWatcherEngineThread *>::iterator jt, end; @@ -242,16 +243,16 @@ QStringList QWindowsFileSystemWatcherEngine::removePaths(const QStringList &path QMutexLocker locker(&(thread->mutex)); - QWindowsFileSystemWatcherEngine::Handle handle = thread->handleForDir.value(absolutePath); + QWindowsFileSystemWatcherEngine::Handle handle = thread->handleForDir.value(QFileSystemWatcherPathKey(absolutePath)); if (handle.handle == INVALID_HANDLE_VALUE) { // perhaps path is a file? absolutePath = fileInfo.absolutePath(); - handle = thread->handleForDir.value(absolutePath); + handle = thread->handleForDir.value(QFileSystemWatcherPathKey(absolutePath)); } if (handle.handle != INVALID_HANDLE_VALUE) { - QHash<QString, QWindowsFileSystemWatcherEngine::PathInfo> &h = + QWindowsFileSystemWatcherEngineThread::PathInfoHash &h = thread->pathInfoForHandle[handle.handle]; - if (h.remove(fileInfo.absoluteFilePath())) { + if (h.remove(QFileSystemWatcherPathKey(fileInfo.absoluteFilePath()))) { // ### files->removeAll(path); directories->removeAll(path); @@ -264,7 +265,7 @@ QStringList QWindowsFileSystemWatcherEngine::removePaths(const QStringList &path Q_ASSERT(indexOfHandle != -1); thread->handles.remove(indexOfHandle); - thread->handleForDir.remove(absolutePath); + thread->handleForDir.remove(QFileSystemWatcherPathKey(absolutePath)); // h is now invalid it.remove(); @@ -326,7 +327,7 @@ QWindowsFileSystemWatcherEngineThread::~QWindowsFileSystemWatcherEngineThread() } } -static inline QString msgFindNextFailed(const QHash<QString, QWindowsFileSystemWatcherEngine::PathInfo> &pathInfos) +static inline QString msgFindNextFailed(const QWindowsFileSystemWatcherEngineThread::PathInfoHash &pathInfos) { QString result; QTextStream str(&result); @@ -366,7 +367,7 @@ void QWindowsFileSystemWatcherEngineThread::run() // for some reason, so we must check if the handle exist in the handles vector if (handles.contains(handle)) { DEBUG() << "thread" << this << "Acknowledged handle:" << at << handle; - QHash<QString, QWindowsFileSystemWatcherEngine::PathInfo> &h = pathInfoForHandle[handle]; + QWindowsFileSystemWatcherEngineThread::PathInfoHash &h = pathInfoForHandle[handle]; bool fakeRemove = false; if (!FindNextChangeNotification(handle)) { @@ -381,9 +382,9 @@ void QWindowsFileSystemWatcherEngineThread::run() qErrnoWarning(error, "%s", qPrintable(msgFindNextFailed(h))); } - QMutableHashIterator<QString, QWindowsFileSystemWatcherEngine::PathInfo> it(h); + QMutableHashIterator<QFileSystemWatcherPathKey, QWindowsFileSystemWatcherEngine::PathInfo> it(h); while (it.hasNext()) { - QHash<QString, QWindowsFileSystemWatcherEngine::PathInfo>::iterator x = it.next(); + QWindowsFileSystemWatcherEngineThread::PathInfoHash::iterator x = it.next(); QString absolutePath = x.value().absolutePath; QFileInfo fileInfo(x.value().path); DEBUG() << "checking" << x.key(); @@ -407,7 +408,7 @@ void QWindowsFileSystemWatcherEngineThread::run() Q_ASSERT(indexOfHandle != -1); handles.remove(indexOfHandle); - handleForDir.remove(absolutePath); + handleForDir.remove(QFileSystemWatcherPathKey(absolutePath)); // h is now invalid } } else if (x.value().isDir) { diff --git a/src/corelib/io/qfilesystemwatcher_win_p.h b/src/corelib/io/qfilesystemwatcher_win_p.h index 8937910d10..790fb954d9 100644 --- a/src/corelib/io/qfilesystemwatcher_win_p.h +++ b/src/corelib/io/qfilesystemwatcher_win_p.h @@ -128,11 +128,27 @@ private: }; +class QFileSystemWatcherPathKey : public QString +{ +public: + QFileSystemWatcherPathKey() {} + explicit QFileSystemWatcherPathKey(const QString &other) : QString(other) {} + QFileSystemWatcherPathKey(const QFileSystemWatcherPathKey &other) : QString(other) {} + bool operator==(const QFileSystemWatcherPathKey &other) const { return !compare(other, Qt::CaseInsensitive); } +}; + +Q_DECLARE_TYPEINFO(QFileSystemWatcherPathKey, Q_MOVABLE_TYPE); + +inline uint qHash(const QFileSystemWatcherPathKey &key) { return qHash(key.toCaseFolded()); } + class QWindowsFileSystemWatcherEngineThread : public QThread { Q_OBJECT public: + typedef QHash<QFileSystemWatcherPathKey, QWindowsFileSystemWatcherEngine::Handle> HandleForDirHash; + typedef QHash<QFileSystemWatcherPathKey, QWindowsFileSystemWatcherEngine::PathInfo> PathInfoHash; + QWindowsFileSystemWatcherEngineThread(); ~QWindowsFileSystemWatcherEngineThread(); void run(); @@ -143,9 +159,9 @@ public: QVector<Qt::HANDLE> handles; int msg; - QHash<QString, QWindowsFileSystemWatcherEngine::Handle> handleForDir; + HandleForDirHash handleForDir; - QHash<Qt::HANDLE, QHash<QString, QWindowsFileSystemWatcherEngine::PathInfo> > pathInfoForHandle; + QHash<Qt::HANDLE, PathInfoHash> pathInfoForHandle; Q_SIGNALS: void fileChanged(const QString &path, bool removed); diff --git a/src/corelib/io/qprocess_win.cpp b/src/corelib/io/qprocess_win.cpp index 7776852277..bcc3fe0b0d 100644 --- a/src/corelib/io/qprocess_win.cpp +++ b/src/corelib/io/qprocess_win.cpp @@ -641,7 +641,7 @@ bool QProcessPrivate::drainOutputPipes() readyReadEmitted |= stderrReader->waitForReadyRead(0); readOperationActive |= stderrReader->isReadOperationActive(); } - if (!readOperationActive) + if (!readOperationActive || !readyReadEmitted) break; Sleep(100); } diff --git a/src/corelib/io/qurl.h b/src/corelib/io/qurl.h index 98cf760dec..453e0be1d2 100644 --- a/src/corelib/io/qurl.h +++ b/src/corelib/io/qurl.h @@ -114,6 +114,10 @@ public: template<typename E1, typename E2> class QTypeInfo<QUrlTwoFlags<E1, E2> > : public QTypeInfoMerger<QUrlTwoFlags<E1, E2>, E1, E2> {}; +class QUrl; +// qHash is a friend, but we can't use default arguments for friends (§8.3.6.4) +Q_CORE_EXPORT uint qHash(const QUrl &url, uint seed = 0) Q_DECL_NOTHROW; + class Q_CORE_EXPORT QUrl { public: @@ -326,7 +330,7 @@ public: static QList<QUrl> fromStringList(const QStringList &uris, ParsingMode mode = TolerantMode); static void setIdnWhitelist(const QStringList &); - friend Q_CORE_EXPORT uint qHash(const QUrl &url, uint seed = 0) Q_DECL_NOTHROW; + friend Q_CORE_EXPORT uint qHash(const QUrl &url, uint seed) Q_DECL_NOTHROW; private: QUrlPrivate *d; diff --git a/src/corelib/io/qwinoverlappedionotifier.cpp b/src/corelib/io/qwinoverlappedionotifier.cpp index 8f4b8be9a3..914264e69e 100644 --- a/src/corelib/io/qwinoverlappedionotifier.cpp +++ b/src/corelib/io/qwinoverlappedionotifier.cpp @@ -83,7 +83,9 @@ class QWinIoCompletionPort : protected QThread { public: QWinIoCompletionPort() - : hPort(INVALID_HANDLE_VALUE) + : finishThreadKey(reinterpret_cast<ULONG_PTR>(this)), + drainQueueKey(reinterpret_cast<ULONG_PTR>(this + 1)), + hPort(INVALID_HANDLE_VALUE) { setObjectName(QLatin1String("I/O completion port thread")); HANDLE hIOCP = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 0); @@ -92,13 +94,19 @@ public: return; } hPort = hIOCP; + hQueueDrainedEvent = CreateEvent(NULL, TRUE, FALSE, NULL); + if (!hQueueDrainedEvent) { + qErrnoWarning("CreateEvent failed."); + return; + } } ~QWinIoCompletionPort() { - PostQueuedCompletionStatus(hPort, 0, 0, NULL); + PostQueuedCompletionStatus(hPort, 0, finishThreadKey, NULL); QThread::wait(); CloseHandle(hPort); + CloseHandle(hQueueDrainedEvent); } void registerNotifier(QWinOverlappedIoNotifier *notifier) @@ -122,29 +130,50 @@ public: mutex.unlock(); } + void drainQueue() + { + QMutexLocker locker(&drainQueueMutex); + ResetEvent(hQueueDrainedEvent); + PostQueuedCompletionStatus(hPort, 0, drainQueueKey, NULL); + WaitForSingleObject(hQueueDrainedEvent, INFINITE); + } + + using QThread::isRunning; + protected: void run() { DWORD dwBytesRead; ULONG_PTR pulCompletionKey; OVERLAPPED *overlapped; + DWORD msecs = INFINITE; forever { BOOL success = GetQueuedCompletionStatus(hPort, &dwBytesRead, &pulCompletionKey, &overlapped, - INFINITE); + msecs); DWORD errorCode = success ? ERROR_SUCCESS : GetLastError(); if (!success && !overlapped) { + if (!msecs) { + // Time out in drain mode. The completion status queue is empty. + msecs = INFINITE; + SetEvent(hQueueDrainedEvent); + continue; + } qErrnoWarning(errorCode, "GetQueuedCompletionStatus failed."); return; } - if (success && !(dwBytesRead || pulCompletionKey || overlapped)) { - // We've posted null values via PostQueuedCompletionStatus to end this thread. + if (pulCompletionKey == finishThreadKey) return; + if (pulCompletionKey == drainQueueKey) { + // Enter drain mode. + Q_ASSERT(msecs == INFINITE); + msecs = 0; + continue; } QWinOverlappedIoNotifier *notifier = reinterpret_cast<QWinOverlappedIoNotifier *>(pulCompletionKey); @@ -156,9 +185,13 @@ protected: } private: + const ULONG_PTR finishThreadKey; + const ULONG_PTR drainQueueKey; HANDLE hPort; QSet<QWinOverlappedIoNotifier *> notifiers; QMutex mutex; + QMutex drainQueueMutex; + HANDLE hQueueDrainedEvent; }; QWinIoCompletionPort *QWinOverlappedIoNotifier::iocp = 0; @@ -216,7 +249,14 @@ void QWinOverlappedIoNotifier::setEnabled(bool enabled) */ bool QWinOverlappedIoNotifier::waitForNotified(int msecs, OVERLAPPED *overlapped) { + if (!iocp->isRunning()) { + qWarning("Called QWinOverlappedIoNotifier::waitForNotified on inactive notifier."); + return false; + } + forever { + if (msecs == 0) + iocp->drainQueue(); DWORD result = WaitForSingleObject(hSemaphore, msecs == -1 ? INFINITE : DWORD(msecs)); if (result == WAIT_OBJECT_0) { ReleaseSemaphore(hSemaphore, 1, NULL); diff --git a/src/corelib/itemmodels/qabstractitemmodel.h b/src/corelib/itemmodels/qabstractitemmodel.h index 0284ab4830..ac98476492 100644 --- a/src/corelib/itemmodels/qabstractitemmodel.h +++ b/src/corelib/itemmodels/qabstractitemmodel.h @@ -98,6 +98,9 @@ Q_CORE_EXPORT QDebug operator<<(QDebug, const QModelIndex &); class QPersistentModelIndexData; +// qHash is a friend, but we can't use default arguments for friends (§8.3.6.4) +uint qHash(const QPersistentModelIndex &index, uint seed = 0); + class Q_CORE_EXPORT QPersistentModelIndex { public: @@ -133,7 +136,7 @@ public: bool isValid() const; private: QPersistentModelIndexData *d; - friend uint qHash(const QPersistentModelIndex &, uint seed = 0); + friend uint qHash(const QPersistentModelIndex &, uint seed); #ifndef QT_NO_DEBUG_STREAM friend Q_CORE_EXPORT QDebug operator<<(QDebug, const QPersistentModelIndex &); #endif diff --git a/src/corelib/kernel/qcore_unix.cpp b/src/corelib/kernel/qcore_unix.cpp index 98e697eb57..e4181b5c86 100644 --- a/src/corelib/kernel/qcore_unix.cpp +++ b/src/corelib/kernel/qcore_unix.cpp @@ -63,12 +63,8 @@ QT_BEGIN_NAMESPACE static inline bool time_update(struct timespec *tv, const struct timespec &start, const struct timespec &timeout) { - if (!QElapsedTimer::isMonotonic()) { - // we cannot recalculate the timeout without a monotonic clock as the time may have changed - return false; - } - - // clock source is monotonic, so we can recalculate how much timeout is left + // clock source is (hopefully) monotonic, so we can recalculate how much timeout is left; + // if it isn't monotonic, we'll simply hope that it hasn't jumped, because we have no alternative struct timespec now = qt_gettime(); *tv = timeout + start - now; return tv->tv_sec >= 0; diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index c9f4ab23ec..386ee9cbda 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -381,7 +381,7 @@ QCoreApplicationPrivate::QCoreApplicationPrivate(int &aargc, char **aargv, uint , origArgc(aargc) , origArgv(new char *[aargc]) #endif - , application_type(0) + , application_type(QCoreApplicationPrivate::Tty) #ifndef QT_NO_QOBJECT , in_exec(false) , aboutToQuitEmitted(false) @@ -724,7 +724,7 @@ void QCoreApplication::init() #endif #ifdef QT_EVAL - extern void qt_core_eval_init(uint); + extern void qt_core_eval_init(QCoreApplicationPrivate::Type); qt_core_eval_init(d->application_type); #endif @@ -1451,7 +1451,7 @@ void QCoreApplicationPrivate::sendPostedEvents(QObject *receiver, int event_type // first, we diddle the event so that we can deliver // it, and that no one will try to touch it later. pe.event->posted = false; - QScopedPointer<QEvent> e(pe.event); + QEvent *e = pe.event; QObject * r = pe.receiver; --r->d_func()->postedEvents; @@ -1469,8 +1469,10 @@ void QCoreApplicationPrivate::sendPostedEvents(QObject *receiver, int event_type }; MutexUnlocker unlocker(locker); + QScopedPointer<QEvent> event_deleter(e); // will delete the event (with the mutex unlocked) + // after all that work, it's time to deliver the event. - QCoreApplication::sendEvent(r, e.data()); + QCoreApplication::sendEvent(r, e); // careful when adding anything below this point - the // sendEvent() call might invalidate any invariants this diff --git a/src/corelib/kernel/qcoreapplication_p.h b/src/corelib/kernel/qcoreapplication_p.h index 563a3b2093..6a3bea9c9e 100644 --- a/src/corelib/kernel/qcoreapplication_p.h +++ b/src/corelib/kernel/qcoreapplication_p.h @@ -135,7 +135,7 @@ public: static bool isTranslatorInstalled(QTranslator *translator); #endif - uint application_type; + QCoreApplicationPrivate::Type application_type; QString cachedApplicationDirPath; QString cachedApplicationFilePath; diff --git a/src/corelib/kernel/qeventdispatcher_blackberry.cpp b/src/corelib/kernel/qeventdispatcher_blackberry.cpp index 4cf1db18b4..d9e38b68b2 100644 --- a/src/corelib/kernel/qeventdispatcher_blackberry.cpp +++ b/src/corelib/kernel/qeventdispatcher_blackberry.cpp @@ -43,6 +43,7 @@ #include "qsocketnotifier.h" #include "qdebug.h" #include "qelapsedtimer.h" +#include "private/qthread_p.h" #include <bps/bps.h> #include <bps/event.h> @@ -352,11 +353,16 @@ int QEventDispatcherBlackberry::select(int nfds, fd_set *readfds, fd_set *writef } } - // Wait for event or file to be ready event = 0; - const int result = bps_get_event(&event, timeoutLeft); - if (Q_UNLIKELY(result != BPS_SUCCESS)) - qWarning("QEventDispatcherBlackberry bps_get_event failed"); + { // We need to increase loop level in this scope, + // because bps_get_event can also invoke callbacks + QScopedLoopLevelCounter loopLevelCounter(d->threadData); + + // Wait for event or file to be ready + const int result = bps_get_event(&event, timeoutLeft); + if (Q_UNLIKELY(result != BPS_SUCCESS)) + qWarning("QEventDispatcherBlackberry: bps_get_event failed"); + } if (!event) // In case of !event, we break out of the loop to let Qt process the timers break; // (since timeout has expired) and socket notifiers that are now ready. diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h index 35cb589843..005199080d 100644 --- a/src/corelib/kernel/qmetatype.h +++ b/src/corelib/kernel/qmetatype.h @@ -1582,7 +1582,7 @@ int qRegisterNormalizedMetaType(const QT_PREPEND_NAMESPACE(QByteArray) &normaliz QtMetaTypePrivate::QMetaTypeFunctionHelper<T>::Create, QtMetaTypePrivate::QMetaTypeFunctionHelper<T>::Destruct, QtMetaTypePrivate::QMetaTypeFunctionHelper<T>::Construct, - sizeof(T), + int(sizeof(T)), flags, QtPrivate::MetaObjectForType<T>::value()); @@ -1753,8 +1753,8 @@ struct QMetaTypeId< SINGLE_ARG_TEMPLATE<T> > \ Q_ASSERT(tName); \ const int tNameLen = qstrlen(tName); \ QByteArray typeName; \ - typeName.reserve(sizeof(#SINGLE_ARG_TEMPLATE) + 1 + tNameLen + 1 + 1); \ - typeName.append(#SINGLE_ARG_TEMPLATE, sizeof(#SINGLE_ARG_TEMPLATE) - 1) \ + typeName.reserve(int(sizeof(#SINGLE_ARG_TEMPLATE)) + 1 + tNameLen + 1 + 1); \ + typeName.append(#SINGLE_ARG_TEMPLATE, int(sizeof(#SINGLE_ARG_TEMPLATE)) - 1) \ .append('<').append(tName, tNameLen); \ if (typeName.endsWith('>')) \ typeName.append(' '); \ @@ -1786,8 +1786,8 @@ struct QMetaTypeId< DOUBLE_ARG_TEMPLATE<T, U> > \ const int tNameLen = qstrlen(tName); \ const int uNameLen = qstrlen(uName); \ QByteArray typeName; \ - typeName.reserve(sizeof(#DOUBLE_ARG_TEMPLATE) + 1 + tNameLen + 1 + uNameLen + 1 + 1); \ - typeName.append(#DOUBLE_ARG_TEMPLATE, sizeof(#DOUBLE_ARG_TEMPLATE) - 1) \ + typeName.reserve(int(sizeof(#DOUBLE_ARG_TEMPLATE)) + 1 + tNameLen + 1 + uNameLen + 1 + 1); \ + typeName.append(#DOUBLE_ARG_TEMPLATE, int(sizeof(#DOUBLE_ARG_TEMPLATE)) - 1) \ .append('<').append(tName, tNameLen).append(',').append(uName, uNameLen); \ if (typeName.endsWith('>')) \ typeName.append(' '); \ diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 495ce7c948..997a65169d 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -3921,7 +3921,7 @@ QDebug operator<<(QDebug dbg, const QObject *o) { they have additional features accessible through the \l {Meta-Object System}. - \snippet code/src_corelib_kernel_qobject.cpp 36 + \snippet code/doc_src_properties.cpp 0 The property name and type and the \c READ function are required. The type can be any type supported by QVariant, or it can be a diff --git a/src/corelib/kernel/qtcore_eval.cpp b/src/corelib/kernel/qtcore_eval.cpp index e9ff786074..59656883f1 100644 --- a/src/corelib/kernel/qtcore_eval.cpp +++ b/src/corelib/kernel/qtcore_eval.cpp @@ -44,6 +44,7 @@ #include <qlibraryinfo.h> #include <qobject.h> #include <qcoreapplication.h> +#include <private/qcoreapplication_p.h> #include "stdio.h" #include "stdlib.h" @@ -52,7 +53,7 @@ QT_BEGIN_NAMESPACE #include "qconfig_eval.cpp" -static const char boilerplate_unsuported[] = +static const char boilerplate_supported_but_time_limited[] = "\nQt %1 Evaluation License\n" "Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies).\n" "This trial version may only be used for evaluation purposes\n" @@ -86,13 +87,19 @@ static const char will_shutdown_now[] = "timeout and will shut down.\n" "Contact http://qt.digia.com/contact-us for pricing and purchasing information.\n"; -static int qt_eval_is_supported() +enum EvaluationStatus { + EvaluationNotSupported = 0, + EvaluationSupportedButTimeLimited, + EvaluationSupported +}; + +static EvaluationStatus qt_eval_is_supported() { const volatile char *const license_key = qt_eval_key_data + 12; // fast fail if (!qt_eval_key_data[0] || !*license_key) - return -1; + return EvaluationNotSupported; // is this an unsupported evaluation? const volatile char *typecode = license_key; @@ -103,31 +110,33 @@ static int qt_eval_is_supported() if (!field && typecode[1] == '4' && typecode[2] == 'M') { if (typecode[0] == 'Q') - return 0; + return EvaluationSupportedButTimeLimited; else if (typecode[0] == 'R' || typecode[0] == 'Z') - return 1; + return EvaluationSupported; } - return -1; + return EvaluationNotSupported; } static int qt_eval_days_left() { - if (qt_eval_is_supported() < 0) - return -2; - QDate today = QDate::currentDate(); QDate build = QLibraryInfo::buildDate(); return qMax<qint64>(-1, today.daysTo(build) + 30); } +static bool qt_eval_is_expired() +{ + return qt_eval_days_left() < 0; +} + static QString qt_eval_string() { const char *msg; switch (qt_eval_is_supported()) { - case 0: - msg = boilerplate_unsuported; + case EvaluationSupportedButTimeLimited: + msg = boilerplate_supported_but_time_limited; break; - case 1: + case EvaluationSupported: msg = boilerplate_supported; break; default: @@ -153,7 +162,7 @@ public: QCoreFuriCuri() : QObject(), warn(-1), kill(-1) { - if (!qt_eval_is_supported()) { + if (qt_eval_is_supported() == EvaluationSupportedButTimeLimited) { warn = startTimer(WARN_TIMEOUT); kill = 0; } @@ -173,27 +182,20 @@ public: #if defined(QT_BUILD_CORE_LIB) || defined (QT_BOOTSTRAPPED) -void qt_core_eval_init(uint type) +void qt_core_eval_init(QCoreApplicationPrivate::Type type) { - if (!type) - return; // GUI app + if (type != QCoreApplicationPrivate::Tty) + return; - switch (qt_eval_days_left()) { - case -2: + if (!qt_eval_is_supported()) return; - case -1: + if (qt_eval_is_expired()) { fprintf(stderr, "%s\n", boilerplate_expired); - if (type == 0) { - // if we're a console app only. - exit(0); - } - - default: + exit(0); + } else { fprintf(stderr, "%s\n", qPrintable(qt_eval_string())); - if (type == 0) { - Q_UNUSED(new QCoreFuriCuri()); - } + Q_UNUSED(new QCoreFuriCuri()); } } #endif @@ -453,12 +455,7 @@ public: { setWindowTitle(QLatin1String(" ")); - QString str = qt_eval_string(); - if (expired) { - str = QLatin1String(boilerplate_expired); - } else { - str = qt_eval_string(); - } + QString str = expired ? QLatin1String(boilerplate_expired) : qt_eval_string(); str = str.trimmed(); QFrame *border = new QFrame(this); @@ -520,24 +517,22 @@ public: }; -void qt_gui_eval_init(uint) +void qt_gui_eval_init(QCoreApplicationPrivate::Type type) { - switch (qt_eval_days_left()) { - case -2: + Q_UNUSED(type); + + if (!qt_eval_is_supported()) return; - case -1: { + if (qt_eval_is_expired()) { EvalMessageBox box(true); box.exec(); ::exit(0); - } - - default: { + } else { EvalMessageBox *box = new EvalMessageBox(false); box->show(); Q_UNUSED(new QGuiFuriCuri()); } - } } static QString qt_eval_title_prefix() @@ -547,14 +542,14 @@ static QString qt_eval_title_prefix() QString qt_eval_adapt_window_title(const QString &title) { - if (qt_eval_days_left() == -2) + if (!qt_eval_is_supported()) return title; return qt_eval_title_prefix() + title; } void qt_eval_init_widget(QWidget *w) { - if (qt_eval_days_left() == -2) + if (!qt_eval_is_supported()) return; if (w->isTopLevel() && w->windowTitle().isEmpty() && w->windowType() != Qt::Desktop ) { w->setWindowTitle(QLatin1String(" ")); diff --git a/src/corelib/kernel/qvariant_p.h b/src/corelib/kernel/qvariant_p.h index 04b9d92f55..4ec049e20d 100644 --- a/src/corelib/kernel/qvariant_p.h +++ b/src/corelib/kernel/qvariant_p.h @@ -224,7 +224,7 @@ class QVariantIsNull public: static const bool Value = (sizeof(test<T>(0)) == sizeof(Yes)); }; -#elif defined(Q_CC_MSVC) && _MSC_VER >= 1400 // MSVC 2005, 2008 version: no decltype, but 'sealed' classes (>=2010 has decltype) +#elif defined(Q_CC_MSVC) && _MSC_VER >= 1400 && !defined(Q_CC_INTEL) // MSVC 2005, 2008 version: no decltype, but 'sealed' classes (>=2010 has decltype) template<typename T> class HasIsNullMethod { struct Yes { char unused[1]; }; diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index de09e5bbe0..37d28b0904 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -3873,7 +3873,7 @@ static inline __m128i mergeQuestionMarks(__m128i chunk) // SSE has no compare instruction for unsigned comparison. // The variables must be shiffted + 0x8000 to be compared const __m128i signedBitOffset = _mm_set1_epi16(0x8000); - const __m128i thresholdMask = _mm_set1_epi16(0xff + 0x8000); + const __m128i thresholdMask = _mm_set1_epi16(short(0xff + 0x8000)); const __m128i signedChunk = _mm_add_epi16(chunk, signedBitOffset); const __m128i offLimitMask = _mm_cmpgt_epi16(signedChunk, thresholdMask); diff --git a/src/corelib/xml/qxmlstream.cpp b/src/corelib/xml/qxmlstream.cpp index 372b1d91fe..d3579497eb 100644 --- a/src/corelib/xml/qxmlstream.cpp +++ b/src/corelib/xml/qxmlstream.cpp @@ -2038,7 +2038,7 @@ QStringRef QXmlStreamReader::dtdSystemId() const element's namespace declarations. Otherwise an empty vector is returned. - The QXmlStreamNamespaceDeclaration class is defined to be a QVector + The QXmlStreamNamespaceDeclarations class is defined to be a QVector of QXmlStreamNamespaceDeclaration. \sa addExtraNamespaceDeclaration(), addExtraNamespaceDeclarations() diff --git a/src/dbus/qdbusabstractadaptor.cpp b/src/dbus/qdbusabstractadaptor.cpp index 1dbc79d6ec..04accee037 100644 --- a/src/dbus/qdbusabstractadaptor.cpp +++ b/src/dbus/qdbusabstractadaptor.cpp @@ -279,7 +279,16 @@ void QDBusAdaptorConnector::polish() void QDBusAdaptorConnector::relaySlot(void **argv) { - relay(sender(), senderSignalIndex(), argv); + QObject *sndr = sender(); + if (Q_LIKELY(sndr)) { + relay(sndr, senderSignalIndex(), argv); + } else { + qWarning("QtDBus: cannot relay signals from parent %s(%p \"%s\") unless they are emitted in the object's thread %s(%p \"%s\"). " + "Current thread is %s(%p \"%s\").", + parent()->metaObject()->className(), parent(), qPrintable(parent()->objectName()), + parent()->thread()->metaObject()->className(), parent()->thread(), qPrintable(parent()->thread()->objectName()), + QThread::currentThread()->metaObject()->className(), QThread::currentThread(), qPrintable(QThread::currentThread()->objectName())); + } } void QDBusAdaptorConnector::relay(QObject *senderObj, int lastSignalIdx, void **argv) diff --git a/src/gui/image/qicon.cpp b/src/gui/image/qicon.cpp index f2f822331d..cb508ae6c7 100644 --- a/src/gui/image/qicon.cpp +++ b/src/gui/image/qicon.cpp @@ -181,7 +181,7 @@ void QPixmapIconEngine::paint(QPainter *painter, const QRect &rect, QIcon::Mode { QSize pixmapSize = rect.size() * qt_effective_device_pixel_ratio(0); QPixmap px = pixmap(pixmapSize, mode, state); - painter->drawPixmap(rect, pixmap(pixmapSize, mode, state)); + painter->drawPixmap(rect, px); } static inline int area(const QSize &s) { return s.width() * s.height(); } diff --git a/src/gui/image/qimagereader.cpp b/src/gui/image/qimagereader.cpp index 5dd51843fb..ec55cb85a3 100644 --- a/src/gui/image/qimagereader.cpp +++ b/src/gui/image/qimagereader.cpp @@ -311,7 +311,7 @@ static QImageIOHandler *createReadHandlerHelper(QIODevice *device, QImageIOPlugin *plugin = qobject_cast<QImageIOPlugin *>(l->instance(i)); if (plugin && plugin->capabilities(device, testFormat) & QImageIOPlugin::CanRead) { #ifdef QIMAGEREADER_DEBUG - qDebug() << "QImageReader::createReadHandler: the" << keys.at(i) << "plugin can read this format"; + qDebug() << "QImageReader::createReadHandler: the" << keyMap.keys().at(i) << "plugin can read this format"; #endif handler = plugin->create(device, testFormat); break; @@ -392,7 +392,7 @@ static QImageIOHandler *createReadHandlerHelper(QIODevice *device, if (plugin && plugin->capabilities(device, QByteArray()) & QImageIOPlugin::CanRead) { handler = plugin->create(device, testFormat); #ifdef QIMAGEREADER_DEBUG - qDebug() << "QImageReader::createReadHandler: the" << keys.at(i) << "plugin can read this data"; + qDebug() << "QImageReader::createReadHandler: the" << keyMap.keys().at(i) << "plugin can read this data"; #endif break; } diff --git a/src/gui/kernel/qevent.cpp b/src/gui/kernel/qevent.cpp index ba97db4d39..fa289bbf8b 100644 --- a/src/gui/kernel/qevent.cpp +++ b/src/gui/kernel/qevent.cpp @@ -4217,6 +4217,7 @@ void QTouchEvent::TouchPoint::setFlags(InfoFlags flags) QScrollPrepareEvent::QScrollPrepareEvent(const QPointF &startPos) : QEvent(QEvent::ScrollPrepare), m_target(0), m_startPos(startPos) { + Q_UNUSED(m_target); } /*! diff --git a/src/gui/kernel/qevent.h b/src/gui/kernel/qevent.h index 82276c5342..7142450322 100644 --- a/src/gui/kernel/qevent.h +++ b/src/gui/kernel/qevent.h @@ -860,14 +860,7 @@ public: void setContentPos(const QPointF &pos); private: -#ifdef Q_CC_CLANG -# pragma clang diagnostic push -# pragma clang diagnostic ignored "-Wunused-private-field" -#endif // Q_CC_CLANG QObject* m_target; // Qt 6 remove. -#ifdef Q_CC_CLANG -# pragma clang diagnostic pop -#endif // Q_CC_CLANG QPointF m_startPos; QSizeF m_viewportSize; QRectF m_contentPosRange; diff --git a/src/gui/kernel/qguiapplication.cpp b/src/gui/kernel/qguiapplication.cpp index 89664447c4..118b481fa3 100644 --- a/src/gui/kernel/qguiapplication.cpp +++ b/src/gui/kernel/qguiapplication.cpp @@ -787,11 +787,12 @@ static void init_platform(const QString &pluginArgument, const QString &platform QStringList keys = QPlatformIntegrationFactory::keys(platformPluginPath); QString fatalMessage - = QStringLiteral("Failed to find or load platform plugin \"%1\".\n").arg(name); - if (!keys.isEmpty()) - fatalMessage += QStringLiteral("Available platforms are: %1\n").arg( + = QStringLiteral("This application failed to start because it could not find or load the Qt platform plugin \"%1\".\n\n").arg(name); + if (!keys.isEmpty()) { + fatalMessage += QStringLiteral("Available platform plugins are: %1.\n\n").arg( keys.join(QStringLiteral(", "))); - fatalMessage += QStringLiteral("GUI applications require a platform plugin. Terminating."); + } + fatalMessage += QStringLiteral("Reinstalling the application may fix this problem."); #if defined(Q_OS_WIN) && !defined(Q_OS_WINCE) // Windows: Display message box unless it is a console application // or debug build showing an assert box. diff --git a/src/gui/kernel/qplatformsystemtrayicon_qpa.cpp b/src/gui/kernel/qplatformsystemtrayicon_qpa.cpp index 13de2c658a..b47b657361 100644 --- a/src/gui/kernel/qplatformsystemtrayicon_qpa.cpp +++ b/src/gui/kernel/qplatformsystemtrayicon_qpa.cpp @@ -51,7 +51,7 @@ QT_BEGIN_NAMESPACE \inmodule QtGui \brief The QPlatformSystemTrayIcon class abstracts the system tray icon and interaction. - \sa QSystemTray + \sa QSystemTrayIcon */ /*! diff --git a/src/gui/kernel/qsurfaceformat.cpp b/src/gui/kernel/qsurfaceformat.cpp index 25b603bb9c..9b8ed4a289 100644 --- a/src/gui/kernel/qsurfaceformat.cpp +++ b/src/gui/kernel/qsurfaceformat.cpp @@ -119,7 +119,7 @@ public: the size of the alpha buffer; the size of the depth and stencil buffers; and number of samples per pixel for multisampling. In addition, the format contains surface configuration parameters such as OpenGL profile and - version for rendering, whether or not enable stereo buffers, and swap + version for rendering, whether or not to enable stereo buffers, and swap behaviour. */ @@ -361,7 +361,7 @@ int QSurfaceFormat::depthBufferSize() const Set the swap \a behavior of the surface. The swap behavior specifies whether single, double, or triple - buffering is desired. The default, SwapBehavior::DefaultSwapBehavior, + buffering is desired. The default, DefaultSwapBehavior, gives the default swap behavior of the platform. */ void QSurfaceFormat::setSwapBehavior(SwapBehavior behavior) diff --git a/src/gui/kernel/qwindow.cpp b/src/gui/kernel/qwindow.cpp index eff057c4cb..392407d86d 100644 --- a/src/gui/kernel/qwindow.cpp +++ b/src/gui/kernel/qwindow.cpp @@ -933,7 +933,6 @@ bool QWindow::isActive() const /*! \property QWindow::contentOrientation \brief the orientation of the window's contents - \since 5.1 This is a hint to the window manager in case it needs to display additional content like popups, dialogs, status bars, or similar @@ -1190,7 +1189,6 @@ void QWindow::setHeight(int arg) /*! \property QWindow::minimumWidth \brief the minimum width of the window's geometry - \since 5.1 */ void QWindow::setMinimumWidth(int w) { @@ -1200,7 +1198,6 @@ void QWindow::setMinimumWidth(int w) /*! \property QWindow::minimumHeight \brief the minimum height of the window's geometry - \since 5.1 */ void QWindow::setMinimumHeight(int h) { @@ -1233,7 +1230,6 @@ void QWindow::setMaximumSize(const QSize &size) /*! \property QWindow::maximumWidth \brief the maximum width of the window's geometry - \since 5.1 */ void QWindow::setMaximumWidth(int w) { @@ -1243,7 +1239,6 @@ void QWindow::setMaximumWidth(int w) /*! \property QWindow::maximumHeight \brief the maximum height of the window's geometry - \since 5.1 */ void QWindow::setMaximumHeight(int h) { diff --git a/src/gui/kernel/qwindow.h b/src/gui/kernel/qwindow.h index efdfd497a6..ca261ff7ce 100644 --- a/src/gui/kernel/qwindow.h +++ b/src/gui/kernel/qwindow.h @@ -110,14 +110,14 @@ class Q_GUI_EXPORT QWindow : public QObject, public QSurface Q_PROPERTY(int y READ y WRITE setY NOTIFY yChanged) Q_PROPERTY(int width READ width WRITE setWidth NOTIFY widthChanged) Q_PROPERTY(int height READ height WRITE setHeight NOTIFY heightChanged) - Q_PROPERTY(int minimumWidth READ minimumWidth WRITE setMinimumWidth NOTIFY minimumWidthChanged REVISION 1) - Q_PROPERTY(int minimumHeight READ minimumHeight WRITE setMinimumHeight NOTIFY minimumHeightChanged REVISION 1) - Q_PROPERTY(int maximumWidth READ maximumWidth WRITE setMaximumWidth NOTIFY maximumWidthChanged REVISION 1) - Q_PROPERTY(int maximumHeight READ maximumHeight WRITE setMaximumHeight NOTIFY maximumHeightChanged REVISION 1) + Q_PROPERTY(int minimumWidth READ minimumWidth WRITE setMinimumWidth NOTIFY minimumWidthChanged) + Q_PROPERTY(int minimumHeight READ minimumHeight WRITE setMinimumHeight NOTIFY minimumHeightChanged) + Q_PROPERTY(int maximumWidth READ maximumWidth WRITE setMaximumWidth NOTIFY maximumWidthChanged) + Q_PROPERTY(int maximumHeight READ maximumHeight WRITE setMaximumHeight NOTIFY maximumHeightChanged) Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged) Q_PROPERTY(bool active READ isActive NOTIFY activeChanged REVISION 1) Q_PROPERTY(Visibility visibility READ visibility WRITE setVisibility NOTIFY visibilityChanged REVISION 1) - Q_PROPERTY(Qt::ScreenOrientation contentOrientation READ contentOrientation WRITE reportContentOrientationChange NOTIFY contentOrientationChanged REVISION 1) + Q_PROPERTY(Qt::ScreenOrientation contentOrientation READ contentOrientation WRITE reportContentOrientationChange NOTIFY contentOrientationChanged) Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged REVISION 1) public: @@ -286,12 +286,12 @@ public Q_SLOTS: void setWidth(int arg); void setHeight(int arg); - Q_REVISION(1) void setMinimumWidth(int w); - Q_REVISION(1) void setMinimumHeight(int h); - Q_REVISION(1) void setMaximumWidth(int w); - Q_REVISION(1) void setMaximumHeight(int h); + void setMinimumWidth(int w); + void setMinimumHeight(int h); + void setMaximumWidth(int w); + void setMaximumHeight(int h); - void alert(int msec); + Q_REVISION(1) void alert(int msec); Q_SIGNALS: void screenChanged(QScreen *screen); @@ -304,15 +304,15 @@ Q_SIGNALS: void widthChanged(int arg); void heightChanged(int arg); - Q_REVISION(1) void minimumWidthChanged(int arg); - Q_REVISION(1) void minimumHeightChanged(int arg); - Q_REVISION(1) void maximumWidthChanged(int arg); - Q_REVISION(1) void maximumHeightChanged(int arg); + void minimumWidthChanged(int arg); + void minimumHeightChanged(int arg); + void maximumWidthChanged(int arg); + void maximumHeightChanged(int arg); void visibleChanged(bool arg); Q_REVISION(1) void visibilityChanged(QWindow::Visibility visibility); Q_REVISION(1) void activeChanged(); - Q_REVISION(1) void contentOrientationChanged(Qt::ScreenOrientation orientation); + void contentOrientationChanged(Qt::ScreenOrientation orientation); void focusObjectChanged(QObject *object); diff --git a/src/gui/opengl/qopenglpaintengine.cpp b/src/gui/opengl/qopenglpaintengine.cpp index 0782e42531..78f5080caf 100644 --- a/src/gui/opengl/qopenglpaintengine.cpp +++ b/src/gui/opengl/qopenglpaintengine.cpp @@ -549,8 +549,10 @@ void QOpenGL2PaintEngineEx::beginNativePainting() #ifndef QT_OPENGL_ES_2 Q_ASSERT(QOpenGLContext::currentContext()); + const QOpenGLContext *ctx = d->ctx; const QSurfaceFormat &fmt = d->device->context()->format(); if (fmt.majorVersion() < 3 || (fmt.majorVersion() == 3 && fmt.minorVersion() < 1) + || (fmt.majorVersion() == 3 && fmt.minorVersion() == 1 && ctx->hasExtension(QByteArrayLiteral("GL_ARB_compatibility"))) || fmt.profile() == QSurfaceFormat::CompatibilityProfile) { // be nice to people who mix OpenGL 1.x code with QPainter commands @@ -1548,8 +1550,28 @@ namespace { bool QOpenGL2PaintEngineEx::shouldDrawCachedGlyphs(QFontEngine *fontEngine, const QTransform &t) const { - // Don't try to cache vastly transformed fonts - return t.type() < QTransform::TxProject && QPaintEngineEx::shouldDrawCachedGlyphs(fontEngine, t); + // The paint engine does not support projected cached glyph drawing + if (t.type() == QTransform::TxProject) + return false; + + // The font engine might not support filling the glyph cache + // with the given transform applied, in which case we need to + // fall back to the QPainterPath code-path. + if (!fontEngine->supportsTransformation(t)) { + // Except that drawing paths is slow, so for scales between + // 0.5 and 2.0 we leave the glyph cache untransformed and deal + // with the transform ourselves when painting, resulting in + // drawing 1x cached glyphs with a smooth-scale. + float det = t.determinant(); + if (det >= 0.25f && det <= 4.f) { + // Assuming the baseclass still agrees + return QPaintEngineEx::shouldDrawCachedGlyphs(fontEngine, t); + } + + return false; // Fall back to path-drawing + } + + return QPaintEngineEx::shouldDrawCachedGlyphs(fontEngine, t); } void QOpenGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyphType, @@ -1561,20 +1583,24 @@ void QOpenGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type void *cacheKey = ctx->shareGroup(); bool recreateVertexArrays = false; - QFontEngine *fe = staticTextItem->fontEngine(); - // We allow scaling, so that the glyph-cache will contain glyphs with the - // appropriate resolution in the case of displays with a device-pixel-ratio != 1. - QTransform transform = s->matrix.type() < QTransform::TxRotate ? - QTransform::fromScale(qAbs(s->matrix.m11()), qAbs(s->matrix.m22())) : - QTransform::fromScale( - QVector2D(s->matrix.m11(), s->matrix.m12()).length(), - QVector2D(s->matrix.m21(), s->matrix.m22()).length()); + QTransform glyphCacheTransform; + QFontEngine *fe = staticTextItem->fontEngine(); + if (fe->supportsTransformation(s->matrix)) { + // The font-engine supports rendering glyphs with the current transform, so we + // build a glyph-cache with the scale pre-applied, so that the cache contains + // glyphs with the appropriate resolution in the case of retina displays. + glyphCacheTransform = s->matrix.type() < QTransform::TxRotate ? + QTransform::fromScale(qAbs(s->matrix.m11()), qAbs(s->matrix.m22())) : + QTransform::fromScale( + QVector2D(s->matrix.m11(), s->matrix.m12()).length(), + QVector2D(s->matrix.m21(), s->matrix.m22()).length()); + } QOpenGLTextureGlyphCache *cache = - (QOpenGLTextureGlyphCache *) fe->glyphCache(cacheKey, glyphType, transform); + (QOpenGLTextureGlyphCache *) fe->glyphCache(cacheKey, glyphType, glyphCacheTransform); if (!cache || cache->cacheType() != glyphType || cache->contextGroup() == 0) { - cache = new QOpenGLTextureGlyphCache(glyphType, transform); + cache = new QOpenGLTextureGlyphCache(glyphType, glyphCacheTransform); fe->setGlyphCache(cacheKey, cache); recreateVertexArrays = true; } diff --git a/src/gui/opengl/qopenglvertexarrayobject.cpp b/src/gui/opengl/qopenglvertexarrayobject.cpp index e450fe708f..eb7a42f749 100644 --- a/src/gui/opengl/qopenglvertexarrayobject.cpp +++ b/src/gui/opengl/qopenglvertexarrayobject.cpp @@ -118,6 +118,9 @@ public: void destroy(); void bind(); void release(); + void _q_contextAboutToBeDestroyed(); + + Q_DECLARE_PUBLIC(QOpenGLVertexArrayObject) GLuint vao; @@ -141,12 +144,22 @@ public: bool QOpenGLVertexArrayObjectPrivate::create() { + if (vao) { + qWarning("QOpenGLVertexArrayObject::create() VAO is already created"); + return false; + } + + Q_Q(QOpenGLVertexArrayObject); + if (context) + QObject::disconnect(context, SIGNAL(aboutToBeDestroyed()), q, SLOT(_q_contextAboutToBeDestroyed())); + QOpenGLContext *ctx = QOpenGLContext::currentContext(); if (!ctx) { qWarning("QOpenGLVertexArrayObject::create() requires a valid current OpenGL context"); return false; } context = ctx; + QObject::connect(context, SIGNAL(aboutToBeDestroyed()), q, SLOT(_q_contextAboutToBeDestroyed())); #if defined(QT_OPENGL_ES_2) if (ctx->hasExtension("GL_OES_vertex_array_object")) { @@ -197,8 +210,16 @@ void QOpenGLVertexArrayObjectPrivate::destroy() case NotSupported: break; } - vao = 0; #endif + vao = 0; +} + +/*! + \internal +*/ +void QOpenGLVertexArrayObjectPrivate::_q_contextAboutToBeDestroyed() +{ + destroy(); } void QOpenGLVertexArrayObjectPrivate::bind() @@ -327,7 +348,7 @@ QOpenGLVertexArrayObject::~QOpenGLVertexArrayObject() Q_D(QOpenGLVertexArrayObject); QOpenGLContext *oldContext = 0; - if (d->context && d->context != ctx) { + if (d->context && ctx && d->context != ctx) { oldContext = ctx; if (d->context->makeCurrent(oldContext->surface())) { ctx = d->context; @@ -471,3 +492,5 @@ void QOpenGLVertexArrayObject::release() */ QT_END_NAMESPACE + +#include "moc_qopenglvertexarrayobject.cpp" diff --git a/src/gui/opengl/qopenglvertexarrayobject.h b/src/gui/opengl/qopenglvertexarrayobject.h index 569aeea730..8369497660 100644 --- a/src/gui/opengl/qopenglvertexarrayobject.h +++ b/src/gui/opengl/qopenglvertexarrayobject.h @@ -102,6 +102,7 @@ public: private: Q_DISABLE_COPY(QOpenGLVertexArrayObject) Q_DECLARE_PRIVATE(QOpenGLVertexArrayObject) + Q_PRIVATE_SLOT(d_func(), void _q_contextAboutToBeDestroyed()) QOpenGLVertexArrayObject(QOpenGLVertexArrayObjectPrivate &dd); }; diff --git a/src/gui/painting/qbezier.cpp b/src/gui/painting/qbezier.cpp index 6cef7cc501..2762560da7 100644 --- a/src/gui/painting/qbezier.cpp +++ b/src/gui/painting/qbezier.cpp @@ -150,33 +150,6 @@ static inline int quadraticRoots(qreal a, qreal b, qreal c, } } -static inline bool findInflections(qreal a, qreal b, qreal c, - qreal *t1 , qreal *t2, qreal *tCups) -{ - qreal r1 = 0, r2 = 0; - - short rootsCount = quadraticRoots(a, b, c, &r1, &r2); - - if (rootsCount >= 1) { - if (r1 < r2) { - *t1 = r1; - *t2 = r2; - } else { - *t1 = r2; - *t2 = r1; - } - if (!qFuzzyIsNull(a)) - *tCups = qreal(0.5) * (-b / a); - else - *tCups = 2; - - return true; - } - - return false; -} - - void QBezier::addToPolygon(QPolygonF *polygon, qreal bezier_flattening_threshold) const { QBezier beziers[10]; @@ -531,34 +504,6 @@ static QDebug operator<<(QDebug dbg, const QBezier &bz) } #endif -static inline void splitBezierAt(const QBezier &bez, qreal t, - QBezier *left, QBezier *right) -{ - left->x1 = bez.x1; - left->y1 = bez.y1; - - left->x2 = bez.x1 + t * ( bez.x2 - bez.x1 ); - left->y2 = bez.y1 + t * ( bez.y2 - bez.y1 ); - - left->x3 = bez.x2 + t * ( bez.x3 - bez.x2 ); // temporary holding spot - left->y3 = bez.y2 + t * ( bez.y3 - bez.y2 ); // temporary holding spot - - right->x3 = bez.x3 + t * ( bez.x4 - bez.x3 ); - right->y3 = bez.y3 + t * ( bez.y4 - bez.y3 ); - - right->x2 = left->x3 + t * ( right->x3 - left->x3); - right->y2 = left->y3 + t * ( right->y3 - left->y3); - - left->x3 = left->x2 + t * ( left->x3 - left->x2 ); - left->y3 = left->y2 + t * ( left->y3 - left->y2 ); - - left->x4 = right->x1 = left->x3 + t * (right->x2 - left->x3); - left->y4 = right->y1 = left->y3 + t * (right->y2 - left->y3); - - right->x4 = bez.x4; - right->y4 = bez.y4; -} - qreal QBezier::length(qreal error) const { qreal length = qreal(0.0); diff --git a/src/gui/painting/qpaintengine_raster.cpp b/src/gui/painting/qpaintengine_raster.cpp index 66a4a43cba..d1e9b81faa 100644 --- a/src/gui/painting/qpaintengine_raster.cpp +++ b/src/gui/painting/qpaintengine_raster.cpp @@ -3327,10 +3327,16 @@ bool QRasterPaintEngine::requiresPretransformedGlyphPositions(QFontEngine *fontE bool QRasterPaintEngine::shouldDrawCachedGlyphs(QFontEngine *fontEngine, const QTransform &m) const { + // The raster engine does not support projected cached glyph drawing + if (m.type() >= QTransform::TxProject) + return false; + // The font engine might not support filling the glyph cache // with the given transform applied, in which case we need to - // fall back to the QPainterPath code-path. - if (!fontEngine->supportsTransformation(m)) + // fall back to the QPainterPath code-path. This does not apply + // for engines with internal caching, as we don't use the engine + // to fill up our cache in that case. + if (!fontEngine->hasInternalCaching() && !fontEngine->supportsTransformation(m)) return false; return QPaintEngineEx::shouldDrawCachedGlyphs(fontEngine, m); diff --git a/src/gui/painting/qpathclipper.cpp b/src/gui/painting/qpathclipper.cpp index 2702b56e73..243c99e671 100644 --- a/src/gui/painting/qpathclipper.cpp +++ b/src/gui/painting/qpathclipper.cpp @@ -1036,16 +1036,6 @@ qreal QWingedEdge::delta(int vertex, int a, int b) const return result; } -static inline QPointF midPoint(const QWingedEdge &list, int ei) -{ - const QPathEdge *ep = list.edge(ei); - Q_ASSERT(ep); - - const QPointF a = *list.vertex(ep->first); - const QPointF b = *list.vertex(ep->second); - return a + 0.5 * (b - a); -} - QWingedEdge::TraversalStatus QWingedEdge::findInsertStatus(int vi, int ei) const { const QPathVertex *vp = vertex(vi); diff --git a/src/gui/painting/qpdf.cpp b/src/gui/painting/qpdf.cpp index 345ebefea7..9105e8b396 100644 --- a/src/gui/painting/qpdf.cpp +++ b/src/gui/painting/qpdf.cpp @@ -1469,7 +1469,12 @@ int QPdfEngine::metric(QPaintDevice::PaintDeviceMetric metricType) const return val; } +static inline QSizeF pageSizeToPostScriptPoints(const QSizeF &pageSizeMM) +{ #define Q_MM(n) int((n * 720 + 127) / 254) + return QSizeF(Q_MM(pageSizeMM.width()), Q_MM(pageSizeMM.height())); +#undef Q_MM +} QPdfEnginePrivate::QPdfEnginePrivate() : clipEnabled(false), allClipped(false), hasPen(true), hasBrush(false), simplePen(false), @@ -1477,7 +1482,7 @@ QPdfEnginePrivate::QPdfEnginePrivate() fullPage(false), embedFonts(true), landscape(false), grayscale(false), - paperSize(Q_MM(210), Q_MM(297)), // A4 + paperSize(pageSizeToPostScriptPoints(QSizeF(210, 297))), // A4 leftMargin(10), topMargin(10), rightMargin(10), bottomMargin(10) // ~3.5 mm { resolution = 1200; @@ -1491,6 +1496,11 @@ QPdfEnginePrivate::QPdfEnginePrivate() stream = new QDataStream; } +void QPdfEnginePrivate::setPaperSize(const QSizeF &pageSizeMM) +{ + paperSize = pageSizeToPostScriptPoints(pageSizeMM); +} + bool QPdfEngine::begin(QPaintDevice *pdev) { Q_D(QPdfEngine); @@ -2518,6 +2528,10 @@ void QPdfEnginePrivate::drawTextItem(const QPointF &p, const QTextItemInt &ti) qreal size = ti.fontEngine->fontDef.pixelSize; +#if defined(Q_OS_WIN) + size = (ti.fontEngine->ascent() + ti.fontEngine->descent()).toReal(); +#endif + QVarLengthArray<glyph_t> glyphs; QVarLengthArray<QFixedPoint> positions; QTransform m = QTransform::fromTranslate(p.x(), p.y()); diff --git a/src/gui/painting/qpdf_p.h b/src/gui/painting/qpdf_p.h index 560621775b..54530d0f78 100644 --- a/src/gui/painting/qpdf_p.h +++ b/src/gui/painting/qpdf_p.h @@ -226,6 +226,7 @@ public: QRect paperRect() const; QRect pageRect() const; + void setPaperSize(const QSizeF &pageSizeMM); int width() const { QRect r = paperRect(); diff --git a/src/gui/painting/qpdfwriter.cpp b/src/gui/painting/qpdfwriter.cpp index 136654cb5d..a783aad66a 100644 --- a/src/gui/painting/qpdfwriter.cpp +++ b/src/gui/painting/qpdfwriter.cpp @@ -166,7 +166,7 @@ void QPdfWriter::setPageSize(PageSize size) Q_D(const QPdfWriter); QPagedPaintDevice::setPageSize(size); - d->engine->d_func()->paperSize = pageSizeMM() * 25.4/72.; + d->engine->d_func()->setPaperSize(pageSizeMM()); } /*! @@ -177,7 +177,7 @@ void QPdfWriter::setPageSizeMM(const QSizeF &size) Q_D(const QPdfWriter); QPagedPaintDevice::setPageSizeMM(size); - d->engine->d_func()->paperSize = pageSizeMM() * 25.4/72.; + d->engine->d_func()->setPaperSize(pageSizeMM()); } /*! diff --git a/src/gui/text/qfontengine_ft.cpp b/src/gui/text/qfontengine_ft.cpp index 4545645dc6..7b4925a9c8 100644 --- a/src/gui/text/qfontengine_ft.cpp +++ b/src/gui/text/qfontengine_ft.cpp @@ -1437,6 +1437,14 @@ void QFontEngineFT::getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_me unlockFace(); } +bool QFontEngineFT::supportsTransformation(const QTransform &transform) const +{ + // The freetype engine falls back to QFontEngine for tranformed glyphs, + // which uses fast-tranform and produces very ugly results, so we claim + // to support just translations. + return transform.type() <= QTransform::TxTranslate; +} + static inline unsigned int getChar(const QChar *str, int &i, const int len) { uint ucs4 = str[i].unicode(); diff --git a/src/gui/text/qfontengine_ft_p.h b/src/gui/text/qfontengine_ft_p.h index e09fa6f94f..bd4c855b91 100644 --- a/src/gui/text/qfontengine_ft_p.h +++ b/src/gui/text/qfontengine_ft_p.h @@ -233,6 +233,8 @@ private: virtual void getUnscaledGlyph(glyph_t glyph, QPainterPath *path, glyph_metrics_t *metrics); + virtual bool supportsTransformation(const QTransform &transform) const; + virtual bool canRender(const QChar *string, int len); virtual void addGlyphsToPath(glyph_t *glyphs, QFixedPoint *positions, int nglyphs, diff --git a/src/network/access/qhttpnetworkconnectionchannel.cpp b/src/network/access/qhttpnetworkconnectionchannel.cpp index 1c7a61dca6..7aee9aa38a 100644 --- a/src/network/access/qhttpnetworkconnectionchannel.cpp +++ b/src/network/access/qhttpnetworkconnectionchannel.cpp @@ -1185,6 +1185,22 @@ void QHttpNetworkConnectionChannel::_q_error(QAbstractSocket::SocketError socket case QAbstractSocket::SslHandshakeFailedError: errorCode = QNetworkReply::SslHandshakeFailedError; break; + case QAbstractSocket::ProxyConnectionClosedError: + // try to reconnect/resend before sending an error. + if (reconnectAttempts-- > 0) { + closeAndResendCurrentRequest(); + return; + } + errorCode = QNetworkReply::ProxyConnectionClosedError; + break; + case QAbstractSocket::ProxyConnectionTimeoutError: + // try to reconnect/resend before sending an error. + if (reconnectAttempts-- > 0) { + closeAndResendCurrentRequest(); + return; + } + errorCode = QNetworkReply::ProxyTimeoutError; + break; default: // all other errors are treated as NetworkError errorCode = QNetworkReply::UnknownNetworkError; diff --git a/src/network/kernel/qhostaddress.h b/src/network/kernel/qhostaddress.h index 77a2ec4105..49032850be 100644 --- a/src/network/kernel/qhostaddress.h +++ b/src/network/kernel/qhostaddress.h @@ -64,6 +64,10 @@ public: typedef QIPv6Address Q_IPV6ADDR; +class QHostAddress; +// qHash is a friend, but we can't use default arguments for friends (§8.3.6.4) +Q_NETWORK_EXPORT uint qHash(const QHostAddress &key, uint seed = 0); + class Q_NETWORK_EXPORT QHostAddress { public: @@ -121,7 +125,7 @@ public: static QPair<QHostAddress, int> parseSubnet(const QString &subnet); - friend Q_NETWORK_EXPORT uint qHash(const QHostAddress &key, uint seed = 0); + friend Q_NETWORK_EXPORT uint qHash(const QHostAddress &key, uint seed); protected: QScopedPointer<QHostAddressPrivate> d; }; diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index 4e198cf550..80660041b7 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -545,8 +545,10 @@ void QGL2PaintEngineEx::beginNativePainting() d->funcs.glDisableVertexAttribArray(i); #ifndef QT_OPENGL_ES_2 + const QGLContext *ctx = d->ctx; const QGLFormat &fmt = d->device->format(); if (fmt.majorVersion() < 3 || (fmt.majorVersion() == 3 && fmt.minorVersion() < 1) + || (fmt.majorVersion() == 3 && fmt.minorVersion() == 1 && ctx->contextHandle()->hasExtension(QByteArrayLiteral("GL_ARB_compatibility"))) || fmt.profile() == QGLFormat::CompatibilityProfile) { // be nice to people who mix OpenGL 1.x code with QPainter commands @@ -625,8 +627,28 @@ bool QGL2PaintEngineEx::isNativePaintingActive() const { bool QGL2PaintEngineEx::shouldDrawCachedGlyphs(QFontEngine *fontEngine, const QTransform &t) const { - // Don't try to cache vastly transformed fonts - return t.type() < QTransform::TxProject && QPaintEngineEx::shouldDrawCachedGlyphs(fontEngine, t); + // The paint engine does not support projected cached glyph drawing + if (t.type() == QTransform::TxProject) + return false; + + // The font engine might not support filling the glyph cache + // with the given transform applied, in which case we need to + // fall back to the QPainterPath code-path. + if (!fontEngine->supportsTransformation(t)) { + // Except that drawing paths is slow, so for scales between + // 0.5 and 2.0 we leave the glyph cache untransformed and deal + // with the transform ourselves when painting, resulting in + // drawing 1x cached glyphs with a smooth-scale. + float det = t.determinant(); + if (det >= 0.25f && det <= 4.f) { + // Assuming the baseclass still agrees + return QPaintEngineEx::shouldDrawCachedGlyphs(fontEngine, t); + } + + return false; // Fall back to path-drawing + } + + return QPaintEngineEx::shouldDrawCachedGlyphs(fontEngine, t); } void QGL2PaintEngineExPrivate::transferMode(EngineMode newMode) @@ -1584,19 +1606,23 @@ void QGL2PaintEngineExPrivate::drawCachedGlyphs(QFontEngineGlyphCache::Type glyp void *cacheKey = const_cast<QGLContext *>(QGLContextPrivate::contextGroup(ctx)->context()); bool recreateVertexArrays = false; - // We allow scaling, so that the glyph-cache will contain glyphs with the - // appropriate resolution in the case of displays with a device-pixel-ratio != 1. - QTransform transform = s->matrix.type() < QTransform::TxRotate ? - QTransform::fromScale(qAbs(s->matrix.m11()), qAbs(s->matrix.m22())) : - QTransform::fromScale( - QVector2D(s->matrix.m11(), s->matrix.m12()).length(), - QVector2D(s->matrix.m21(), s->matrix.m22()).length()); - + QTransform glyphCacheTransform; QFontEngine *fe = staticTextItem->fontEngine(); + if (fe->supportsTransformation(s->matrix)) { + // The font-engine supports rendering glyphs with the current transform, so we + // build a glyph-cache with the scale pre-applied, so that the cache contains + // glyphs with the appropriate resolution in the case of retina displays. + glyphCacheTransform = s->matrix.type() < QTransform::TxRotate ? + QTransform::fromScale(qAbs(s->matrix.m11()), qAbs(s->matrix.m22())) : + QTransform::fromScale( + QVector2D(s->matrix.m11(), s->matrix.m12()).length(), + QVector2D(s->matrix.m21(), s->matrix.m22()).length()); + } + QGLTextureGlyphCache *cache = - (QGLTextureGlyphCache *) fe->glyphCache(cacheKey, glyphType, transform); + (QGLTextureGlyphCache *) fe->glyphCache(cacheKey, glyphType, glyphCacheTransform); if (!cache || cache->cacheType() != glyphType || cache->contextGroup() == 0) { - cache = new QGLTextureGlyphCache(glyphType, transform); + cache = new QGLTextureGlyphCache(glyphType, glyphCacheTransform); fe->setGlyphCache(cacheKey, cache); recreateVertexArrays = true; } diff --git a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp index f4cfa3ca40..1cc85bd0dc 100644 --- a/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp +++ b/src/platformsupport/fontdatabases/fontconfig/qfontconfigdatabase.cpp @@ -250,45 +250,6 @@ static const char *languageForWritingSystem[] = { }; enum { LanguageCount = sizeof(languageForWritingSystem) / sizeof(const char *) }; -// Unfortunately FontConfig doesn't know about some languages. We have to test these through the -// charset. The lists below contain the systems where we need to do this. -static const ushort sampleCharForWritingSystem[] = { - 0, // Any - 0, // Latin - 0, // Greek - 0, // Cyrillic - 0, // Armenian - 0, // Hebrew - 0, // Arabic - 0, // Syriac - 0, // Thaana - 0, // Devanagari - 0, // Bengali - 0, // Gurmukhi - 0, // Gujarati - 0, // Oriya - 0, // Tamil - 0xc15, // Telugu - 0xc95, // Kannada - 0xd15, // Malayalam - 0xd9a, // Sinhala - 0, // Thai - 0, // Lao - 0, // Tibetan - 0x1000, // Myanmar - 0, // Georgian - 0, // Khmer - 0, // SimplifiedChinese - 0, // TraditionalChinese - 0, // Japanese - 0, // Korean - 0, // Vietnamese - 0, // Symbol - 0x1681, // Ogham - 0x16a0, // Runic - 0x7ca // N'Ko -}; -enum { SampleCharCount = sizeof(sampleCharForWritingSystem) / sizeof(ushort) }; // Newer FontConfig let's us sort out fonts that contain certain glyphs, but no // open type tables for is directly. Do this so we don't pick some strange @@ -356,26 +317,6 @@ static const char *getFcFamilyForStyleHint(const QFont::StyleHint style) return stylehint; } -static bool isSymbolFont(FontFile *fontFile) -{ - if (fontFile == 0 || fontFile->fileName.isEmpty()) - return false; - - QFontEngine::FaceId id; - id.filename = QFile::encodeName(fontFile->fileName); - id.index = fontFile->indexValue; - - QFreetypeFace *f = QFreetypeFace::getFace(id); - if (f == 0) { - qWarning("isSymbolFont: Couldn't open face %s/%d", id.filename.data(), id.index); - return false; - } - - bool hasSymbolMap = f->symbol_map; - f->release(id); - return hasSymbolMap; -} - Q_GUI_EXPORT void qt_registerAliasToFontFamily(const QString &familyName, const QString &alias); void QFontconfigDatabase::populateFontDatabase() @@ -453,14 +394,20 @@ void QFontconfigDatabase::populateFontDatabase() FcLangSet *langset = 0; FcResult res = FcPatternGetLangSet(fonts->fonts[i], FC_LANG, 0, &langset); if (res == FcResultMatch) { + bool hasLang = false; for (int i = 1; i < LanguageCount; ++i) { const FcChar8 *lang = (const FcChar8*) languageForWritingSystem[i]; if (lang) { FcLangResult langRes = FcLangSetHasLang(langset, lang); - if (langRes != FcLangDifferentLang) + if (langRes != FcLangDifferentLang) { writingSystems.setSupported(QFontDatabase::WritingSystem(i)); + hasLang = true; + } } } + if (!hasLang) + // none of our known languages, add it to the other set + writingSystems.setSupported(QFontDatabase::Other); } else { // we set Other to supported for symbol fonts. It makes no // sense to merge these with other ones, as they are @@ -468,18 +415,6 @@ void QFontconfigDatabase::populateFontDatabase() writingSystems.setSupported(QFontDatabase::Other); } - FcCharSet *cs = 0; - res = FcPatternGetCharSet(fonts->fonts[i], FC_CHARSET, 0, &cs); - if (res == FcResultMatch) { - // some languages are not supported by FontConfig, we rather check the - // charset to detect these - for (int i = 1; i < SampleCharCount; ++i) { - if (!sampleCharForWritingSystem[i] || writingSystems.supported(QFontDatabase::WritingSystem(i))) - continue; - if (FcCharSetHasChar(cs, sampleCharForWritingSystem[i])) - writingSystems.setSupported(QFontDatabase::WritingSystem(i)); - } - } #if FC_VERSION >= 20297 for (int j = 1; j < LanguageCount; ++j) { @@ -497,23 +432,6 @@ void QFontconfigDatabase::populateFontDatabase() fontFile->fileName = QLatin1String((const char *)file_value); fontFile->indexValue = indexValue; - if (!writingSystems.supported(QFontDatabase::Symbol)) { - // Symbol encoding used to encode various crap in the 32..255 character - // code range, which belongs to Latin character code range. - // Symbol fonts usually don't have any other code ranges support. - bool mightBeSymbolFont = true; - for (int j = 2; j < QFontDatabase::WritingSystemsCount; ++j) { - if (writingSystems.supported(QFontDatabase::WritingSystem(j))) { - mightBeSymbolFont = false; - break; - } - } - if (mightBeSymbolFont && isSymbolFont(fontFile)) { - writingSystems.setSupported(QFontDatabase::Latin, false); - writingSystems.setSupported(QFontDatabase::Symbol); - } - } - QFont::Style style = (slant_value == FC_SLANT_ITALIC) ? QFont::StyleItalic : ((slant_value == FC_SLANT_OBLIQUE) diff --git a/src/plugins/accessible/widgets/complexwidgets.cpp b/src/plugins/accessible/widgets/complexwidgets.cpp index 9dbf7d7e0f..819ef6923f 100644 --- a/src/plugins/accessible/widgets/complexwidgets.cpp +++ b/src/plugins/accessible/widgets/complexwidgets.cpp @@ -370,18 +370,6 @@ QStringList QAccessibleComboBox::keyBindingsForAction(const QString &/*actionNam #endif // QT_NO_COMBOBOX -static inline void removeInvisibleWidgetsFromList(QWidgetList *list) -{ - if (!list || list->isEmpty()) - return; - - for (int i = 0; i < list->count(); ++i) { - QWidget *widget = list->at(i); - if (!widget->isVisible()) - list->removeAt(i); - } -} - #ifndef QT_NO_SCROLLAREA // ======================= QAccessibleAbstractScrollArea ======================= QAccessibleAbstractScrollArea::QAccessibleAbstractScrollArea(QWidget *widget) diff --git a/src/plugins/platforms/android/src/qandroidplatformintegration.cpp b/src/plugins/platforms/android/src/qandroidplatformintegration.cpp index 03503ec632..8899d98795 100644 --- a/src/plugins/platforms/android/src/qandroidplatformintegration.cpp +++ b/src/plugins/platforms/android/src/qandroidplatformintegration.cpp @@ -220,6 +220,16 @@ QPlatformServices *QAndroidPlatformIntegration::services() const return m_androidPlatformServices; } +QVariant QAndroidPlatformIntegration::styleHint(StyleHint hint) const +{ + switch (hint) { + case ShowIsFullScreen: + return true; + default: + return QPlatformIntegration::styleHint(hint); + } +} + static const QLatin1String androidThemeName("android"); QStringList QAndroidPlatformIntegration::themeNames() const { diff --git a/src/plugins/platforms/android/src/qandroidplatformintegration.h b/src/plugins/platforms/android/src/qandroidplatformintegration.h index 0e3a48c9f0..346d0c0953 100644 --- a/src/plugins/platforms/android/src/qandroidplatformintegration.h +++ b/src/plugins/platforms/android/src/qandroidplatformintegration.h @@ -113,6 +113,8 @@ public: QPlatformNativeInterface *nativeInterface() const; QPlatformServices *services() const; + QVariant styleHint(StyleHint hint) const; + QStringList themeNames() const; QPlatformTheme *createPlatformTheme(const QString &name) const; diff --git a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.h b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.h index e30f1d7425..59e029769d 100644 --- a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.h +++ b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.h @@ -59,15 +59,6 @@ public: void setCurrentColor(const QColor&); QColor currentColor() const; - -public: - bool showCocoaColorPanel(Qt::WindowModality windowModality, QWindow *parent); - bool hideCocoaColorPanel(); - - void createNSColorPanelDelegate(); - -private: - void *mDelegate; }; QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm index 13b4203f7f..d90d77ec1d 100644 --- a/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm +++ b/src/plugins/platforms/cocoa/qcocoacolordialoghelper.mm @@ -91,11 +91,14 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate); @implementation QNSColorPanelDelegate -- (id)initWithDialogHelper:(QCocoaColorDialogHelper *)helper +- (id)init { self = [super init]; mColorPanel = [NSColorPanel sharedColorPanel]; - mHelper = helper; + mHelper = 0; + mStolenContentView = 0; + mOkButton = 0; + mCancelButton = 0; mResultCode = NSCancelButton; mDialogIsExecuting = false; mResultSet = false; @@ -105,11 +108,31 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate); [mColorPanel setRestorable:NO]; #endif + [[NSNotificationCenter defaultCenter] addObserver:self + selector:@selector(colorChanged:) + name:NSColorPanelColorDidChangeNotification + object:mColorPanel]; + + [mColorPanel retain]; + return self; +} + +- (void)dealloc +{ + [self restoreOriginalContentView]; + [mColorPanel setDelegate:nil]; + [[NSNotificationCenter defaultCenter] removeObserver:self]; + + [super dealloc]; +} + +- (void)setDialogHelper:(QCocoaColorDialogHelper *)helper +{ + mHelper = helper; + [mColorPanel setShowsAlpha:mHelper->options()->testOption(QColorDialogOptions::ShowAlphaChannel)]; if (mHelper->options()->testOption(QColorDialogOptions::NoButtons)) { - mStolenContentView = 0; - mOkButton = 0; - mCancelButton = 0; - } else { + [self restoreOriginalContentView]; + } else if (!mStolenContentView) { // steal the color panel's contents view mStolenContentView = [mColorPanel contentView]; [mStolenContentView retain]; @@ -134,33 +157,6 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate); [mCancelButton setAction:@selector(onCancelClicked)]; [mCancelButton setTarget:self]; } - - [[NSNotificationCenter defaultCenter] addObserver:self - selector:@selector(colorChanged:) - name:NSColorPanelColorDidChangeNotification - object:mColorPanel]; - - [mColorPanel retain]; - return self; -} - -- (void)dealloc -{ - if (mOkButton) { - NSView *ourContentView = [mColorPanel contentView]; - - // return stolen stuff to its rightful owner - [mStolenContentView removeFromSuperview]; - [mColorPanel setContentView:mStolenContentView]; - [mOkButton release]; - [mCancelButton release]; - [ourContentView release]; - } - - [mColorPanel setDelegate:nil]; - [[NSNotificationCenter defaultCenter] removeObserver:self]; - - [super dealloc]; } - (void)closePanel @@ -178,7 +174,25 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate); { Q_UNUSED(notification); [self updateQtColor]; - emit mHelper->colorSelected(mQtColor); + if (mHelper) + emit mHelper->colorSelected(mQtColor); +} + +- (void)restoreOriginalContentView +{ + if (mStolenContentView) { + NSView *ourContentView = [mColorPanel contentView]; + + // return stolen stuff to its rightful owner + [mStolenContentView removeFromSuperview]; + [mColorPanel setContentView:mStolenContentView]; + [mOkButton release]; + [mCancelButton release]; + [ourContentView release]; + mOkButton = 0; + mCancelButton = 0; + mStolenContentView = 0; + } } - (void)relayout @@ -275,7 +289,8 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate); mQtColor.setRgbF(red, green, blue, alpha); } } - emit mHelper->currentColorChanged(mQtColor); + if (mHelper) + emit mHelper->currentColorChanged(mQtColor); } - (void)showModelessPanel @@ -313,7 +328,8 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate); [self finishOffWithCode:NSCancelButton]; } else { mResultSet = true; - emit mHelper->reject(); + if (mHelper) + emit mHelper->reject(); } return true; } @@ -348,27 +364,101 @@ QT_NAMESPACE_ALIAS_OBJC_CLASS(QNSColorPanelDelegate); QT_BEGIN_NAMESPACE -QCocoaColorDialogHelper::QCocoaColorDialogHelper() : - mDelegate(0) +class QCocoaColorPanel +{ +public: + QCocoaColorPanel() + { + mDelegate = [[QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) alloc] init]; + } + + ~QCocoaColorPanel() + { + [mDelegate release]; + } + + void init(QCocoaColorDialogHelper *helper) + { + [mDelegate setDialogHelper:helper]; + } + + void cleanup(QCocoaColorDialogHelper *helper) + { + if (mDelegate->mHelper == helper) + mDelegate->mHelper = 0; + } + + bool exec() + { + // Note: If NSApp is not running (which is the case if e.g a top-most + // QEventLoop has been interrupted, and the second-most event loop has not + // yet been reactivated (regardless if [NSApp run] is still on the stack)), + // showing a native modal dialog will fail. + return [mDelegate runApplicationModalPanel]; + } + + bool show(Qt::WindowModality windowModality, QWindow *parent) + { + Q_UNUSED(parent); + if (windowModality != Qt::WindowModal) + [mDelegate showModelessPanel]; + // no need to show a Qt::WindowModal dialog here, because it's necessary to call exec() in that case + return true; + } + + void hide() + { + [mDelegate closePanel]; + } + + QColor currentColor() const + { + return mDelegate->mQtColor; + } + + void setCurrentColor(const QColor &color) + { + // make sure that if ShowAlphaChannel option is set then also setShowsAlpha + // needs to be set, otherwise alpha value is omitted + if (color.alpha() < 255) + [mDelegate->mColorPanel setShowsAlpha:YES]; + + NSColor *nsColor; + const QColor::Spec spec = color.spec(); + if (spec == QColor::Cmyk) { + nsColor = [NSColor colorWithDeviceCyan:color.cyanF() + magenta:color.magentaF() + yellow:color.yellowF() + black:color.blackF() + alpha:color.alphaF()]; + } else { + nsColor = [NSColor colorWithCalibratedRed:color.redF() + green:color.greenF() + blue:color.blueF() + alpha:color.alphaF()]; + } + mDelegate->mQtColor = color; + [mDelegate->mColorPanel setColor:nsColor]; + } + +private: + QT_MANGLE_NAMESPACE(QNSColorPanelDelegate) *mDelegate; +}; + +Q_GLOBAL_STATIC(QCocoaColorPanel, sharedColorPanel) + +QCocoaColorDialogHelper::QCocoaColorDialogHelper() { } QCocoaColorDialogHelper::~QCocoaColorDialogHelper() { - if (!mDelegate) - return; - [reinterpret_cast<QNSColorPanelDelegate *>(mDelegate) release]; - mDelegate = 0; + sharedColorPanel()->cleanup(this); } void QCocoaColorDialogHelper::exec() { - // Note: If NSApp is not running (which is the case if e.g a top-most - // QEventLoop has been interrupted, and the second-most event loop has not - // yet been reactivated (regardless if [NSApp run] is still on the stack)), - // showing a native modal dialog will fail. - QNSColorPanelDelegate *delegate = static_cast<QNSColorPanelDelegate *>(mDelegate); - if ([delegate runApplicationModalPanel]) + if (sharedColorPanel()->exec()) emit accept(); else emit reject(); @@ -378,89 +468,24 @@ bool QCocoaColorDialogHelper::show(Qt::WindowFlags, Qt::WindowModality windowMod { if (windowModality == Qt::WindowModal) windowModality = Qt::ApplicationModal; - return showCocoaColorPanel(windowModality, parent); + sharedColorPanel()->init(this); + return sharedColorPanel()->show(windowModality, parent); } void QCocoaColorDialogHelper::hide() { - if (!mDelegate) - return; - QNSColorPanelDelegate *delegate = static_cast<QNSColorPanelDelegate *>(mDelegate); - if (![delegate->mColorPanel isVisible]) - return; - if (delegate->mDialogIsExecuting) - [delegate->mColorPanel performClose:delegate]; - else - [delegate->mColorPanel close]; + sharedColorPanel()->hide(); } void QCocoaColorDialogHelper::setCurrentColor(const QColor &color) { - if (!mDelegate) - createNSColorPanelDelegate(); - QNSColorPanelDelegate *delegate = static_cast<QNSColorPanelDelegate *>(mDelegate); - - // make sure that if ShowAlphaChannel option is set then also setShowsAlpha - // needs to be set, otherwise alpha value is omitted - [delegate->mColorPanel setShowsAlpha:options()->testOption(QColorDialogOptions::ShowAlphaChannel)]; - - NSColor *nsColor; - const QColor::Spec spec = color.spec(); - if (spec == QColor::Cmyk) { - nsColor = [NSColor colorWithDeviceCyan:color.cyanF() - magenta:color.magentaF() - yellow:color.yellowF() - black:color.blackF() - alpha:color.alphaF()]; - } else { - nsColor = [NSColor colorWithCalibratedRed:color.redF() - green:color.greenF() - blue:color.blueF() - alpha:color.alphaF()]; - } - delegate->mQtColor = color; - [delegate->mColorPanel setColor:nsColor]; + sharedColorPanel()->init(this); + sharedColorPanel()->setCurrentColor(color); } QColor QCocoaColorDialogHelper::currentColor() const { - if (!mDelegate) - return QColor(); - return reinterpret_cast<QNSColorPanelDelegate *>(mDelegate)->mQtColor; -} - -void QCocoaColorDialogHelper::createNSColorPanelDelegate() -{ - if (mDelegate) - return; - - QNSColorPanelDelegate *delegate = [[QNSColorPanelDelegate alloc] - initWithDialogHelper:this]; - - mDelegate = delegate; -} - -bool QCocoaColorDialogHelper::showCocoaColorPanel(Qt::WindowModality windowModality, QWindow *parent) -{ - Q_UNUSED(parent); - createNSColorPanelDelegate(); - QNSColorPanelDelegate *delegate = static_cast<QNSColorPanelDelegate *>(mDelegate); - [delegate->mColorPanel setShowsAlpha:options()->testOption(QColorDialogOptions::ShowAlphaChannel)]; - if (windowModality != Qt::WindowModal) - [delegate showModelessPanel]; - // no need to show a Qt::WindowModal dialog here, because it's necessary to call exec() in that case - return true; -} - -bool QCocoaColorDialogHelper::hideCocoaColorPanel() -{ - if (!mDelegate){ - return false; - } else { - QNSColorPanelDelegate *delegate = static_cast<QNSColorPanelDelegate *>(mDelegate); - [delegate closePanel]; - return true; - } + return sharedColorPanel()->currentColor(); } QT_END_NAMESPACE diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.h b/src/plugins/platforms/cocoa/qcocoahelpers.h index c801d9d926..3e402673f3 100644 --- a/src/plugins/platforms/cocoa/qcocoahelpers.h +++ b/src/plugins/platforms/cocoa/qcocoahelpers.h @@ -71,6 +71,7 @@ inline NSMutableArray *qt_mac_QStringListToNSMutableArray(const QStringList &qst CGImageRef qt_mac_image_to_cgimage(const QImage &image); NSImage *qt_mac_cgimage_to_nsimage(CGImageRef iamge); NSImage *qt_mac_create_nsimage(const QPixmap &pm); +NSImage *qt_mac_create_nsimage(const QIcon &icon); NSSize qt_mac_toNSSize(const QSize &qtSize); NSRect qt_mac_toNSRect(const QRect &rect); diff --git a/src/plugins/platforms/cocoa/qcocoahelpers.mm b/src/plugins/platforms/cocoa/qcocoahelpers.mm index 8ab1d9b579..3be294de7e 100644 --- a/src/plugins/platforms/cocoa/qcocoahelpers.mm +++ b/src/plugins/platforms/cocoa/qcocoahelpers.mm @@ -84,11 +84,8 @@ static void drawImageReleaseData (void *info, const void *, size_t) CGImageRef qt_mac_image_to_cgimage(const QImage &img) { - if (img.width() <= 0 || img.height() <= 0) { - qWarning() << Q_FUNC_INFO << - "trying to set" << img.width() << "x" << img.height() << "size for CGImage"; + if (img.isNull()) return 0; - } QImage *image; if (img.depth() != 32) @@ -124,16 +121,7 @@ CGImageRef qt_mac_image_to_cgimage(const QImage &img) NSImage *qt_mac_cgimage_to_nsimage(CGImageRef image) { - QCocoaAutoReleasePool pool; - NSImage *newImage = 0; - NSRect imageRect = NSMakeRect(0.0, 0.0, CGImageGetWidth(image), CGImageGetHeight(image)); - newImage = [[NSImage alloc] initWithSize:imageRect.size]; - [newImage lockFocus]; - { - CGContextRef imageContext = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort]; - CGContextDrawImage(imageContext, *(CGRect*)&imageRect, image); - } - [newImage unlockFocus]; + NSImage *newImage = [[NSImage alloc] initWithCGImage:image size:NSZeroSize]; return newImage; } @@ -148,6 +136,24 @@ NSImage *qt_mac_create_nsimage(const QPixmap &pm) return nsImage; } +NSImage *qt_mac_create_nsimage(const QIcon &icon) +{ + if (icon.isNull()) + return nil; + + NSImage *nsImage = [[NSImage alloc] init]; + foreach (QSize size, icon.availableSizes()) { + QPixmap pm = icon.pixmap(size); + QImage image = pm.toImage(); + CGImageRef cgImage = qt_mac_image_to_cgimage(image); + NSBitmapImageRep *imageRep = [[NSBitmapImageRep alloc] initWithCGImage:cgImage]; + [nsImage addRepresentation:imageRep]; + [imageRep release]; + CGImageRelease(cgImage); + } + return nsImage; +} + HIMutableShapeRef qt_mac_QRegionToHIMutableShape(const QRegion ®ion) { HIMutableShapeRef shape = HIShapeCreateMutable(); diff --git a/src/plugins/platforms/cocoa/qcocoamenu.mm b/src/plugins/platforms/cocoa/qcocoamenu.mm index f6378d126f..8c4325a775 100644 --- a/src/plugins/platforms/cocoa/qcocoamenu.mm +++ b/src/plugins/platforms/cocoa/qcocoamenu.mm @@ -49,6 +49,7 @@ #include <QtGui/private/qguiapplication_p.h> #include "qcocoaapplication.h" #include "qcocoamenuloader.h" +#include "qcocoamenubar.h" #include "qcocoawindow.h" #import "qnsview.h" @@ -540,6 +541,7 @@ void QCocoaMenu::syncModalState(bool modal) void QCocoaMenu::setMenuBar(QCocoaMenuBar *menuBar) { m_menuBar = menuBar; + setParent(menuBar); } QCocoaMenuBar *QCocoaMenu::menuBar() const diff --git a/src/plugins/platforms/cocoa/qcocoamenubar.mm b/src/plugins/platforms/cocoa/qcocoamenubar.mm index 52bfdfa385..da2704f19c 100644 --- a/src/plugins/platforms/cocoa/qcocoamenubar.mm +++ b/src/plugins/platforms/cocoa/qcocoamenubar.mm @@ -203,6 +203,11 @@ void QCocoaMenuBar::updateMenuBarImmediately() QCocoaAutoReleasePool pool; QCocoaMenuBar *mb = findGlobalMenubar(); QCocoaWindow *cw = findWindowForMenubar(); + + QWindow *win = cw ? cw->window() : 0; + if (win && (win->flags() & Qt::Popup) == Qt::Popup) + return; // context menus, comboboxes, etc. don't need to update the menubar + if (cw && cw->menubar()) mb = cw->menubar(); diff --git a/src/plugins/platforms/cocoa/qcocoamenuitem.mm b/src/plugins/platforms/cocoa/qcocoamenuitem.mm index 4fb79f6c93..013f9931ff 100644 --- a/src/plugins/platforms/cocoa/qcocoamenuitem.mm +++ b/src/plugins/platforms/cocoa/qcocoamenuitem.mm @@ -310,7 +310,8 @@ NSMenuItem *QCocoaMenuItem::sync() } if (!m_icon.isNull()) { - NSImage *img = static_cast<NSImage *>(qt_mac_create_nsimage(m_icon.pixmap(16, QIcon::Normal))); + NSImage *img = qt_mac_create_nsimage(m_icon); + [img setSize:NSMakeSize(16, 16)]; [m_native setImage: img]; [img release]; } diff --git a/src/plugins/platforms/cocoa/qcocoatheme.mm b/src/plugins/platforms/cocoa/qcocoatheme.mm index 5a5b2bc51f..1484ae2ba3 100644 --- a/src/plugins/platforms/cocoa/qcocoatheme.mm +++ b/src/plugins/platforms/cocoa/qcocoatheme.mm @@ -260,8 +260,9 @@ QPixmap QCocoaTheme::fileIconPixmap(const QFileInfo &fileInfo, const QSizeF &siz return QPixmap(); NSRect iconRect = NSMakeRect(0, 0, size.width(), size.height()); + NSGraphicsContext *gc = [NSGraphicsContext currentContext]; CGImageRef cgImage = [iconImage CGImageForProposedRect:&iconRect - context:[NSGraphicsContext currentContext] + context:([gc graphicsPort] ? gc : nil) hints:nil]; QPixmap pixmap = QPixmap::fromImage(qt_mac_toQImage(cgImage)); return pixmap; diff --git a/src/plugins/platforms/cocoa/qnsview.mm b/src/plugins/platforms/cocoa/qnsview.mm index 70b08c7feb..288d4b4742 100644 --- a/src/plugins/platforms/cocoa/qnsview.mm +++ b/src/plugins/platforms/cocoa/qnsview.mm @@ -916,6 +916,7 @@ static QTouchDevice *touchDevice = 0; ulong timestamp = [nsevent timestamp] * 1000; ulong nativeModifiers = [nsevent modifierFlags]; Qt::KeyboardModifiers modifiers = [QNSView convertKeyModifiers: nativeModifiers]; + NSString *charactersIgnoringModifiers = [nsevent charactersIgnoringModifiers]; NSString *characters = [nsevent characters]; // There is no way to get the scan code from carbon/cocoa. But we cannot @@ -927,7 +928,10 @@ static QTouchDevice *touchDevice = 0; QChar ch = QChar::ReplacementCharacter; int keyCode = Qt::Key_unknown; if ([characters length] != 0) { - ch = QChar([characters characterAtIndex:0]); + if ((modifiers & Qt::MetaModifier) && ([charactersIgnoringModifiers length] != 0)) + ch = QChar([charactersIgnoringModifiers characterAtIndex:0]); + else + ch = QChar([characters characterAtIndex:0]); keyCode = [self convertKeyCode:ch]; } diff --git a/src/plugins/platforms/ios/qioscontext.mm b/src/plugins/platforms/ios/qioscontext.mm index 07368f6ab6..85f560a722 100644 --- a/src/plugins/platforms/ios/qioscontext.mm +++ b/src/plugins/platforms/ios/qioscontext.mm @@ -190,8 +190,11 @@ void QIOSContext::windowDestroyed(QObject *object) { QWindow *window = static_cast<QWindow *>(object); if (m_framebufferObjects.contains(window)) { + EAGLContext *originalContext = [EAGLContext currentContext]; + [EAGLContext setCurrentContext:m_eaglContext]; deleteBuffers(m_framebufferObjects[window]); m_framebufferObjects.remove(window); + [EAGLContext setCurrentContext:originalContext]; } } diff --git a/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp b/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp index ce61a8b092..93592eb969 100644 --- a/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp +++ b/src/plugins/platforms/windows/accessible/qwindowsmsaaaccessible.cpp @@ -564,15 +564,10 @@ HRESULT STDMETHODCALLTYPE QWindowsMsaaAccessible::accLocation(long *pxLeft, long if (!accessible) return E_FAIL; - QRect rect; - if (varID.lVal) { - QAccessibleInterface *child = accessible->child(varID.lVal - 1); - if (!child || !child->isValid()) - return E_FAIL; - rect = child->rect(); - } else { - rect = accessible->rect(); - } + QAccessibleInterface *acc = childPointer(accessible, varID); + if (!acc || !acc->isValid()) + return E_FAIL; + const QRect rect = acc->rect(); *pxLeft = rect.x(); *pyTop = rect.y(); diff --git a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp index 12dd00f104..33bed61398 100644 --- a/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp +++ b/src/plugins/platforms/windows/qwindowsdialoghelpers.cpp @@ -2023,7 +2023,7 @@ void QWindowsNativeColorDialog::exec(HWND owner) qCustomColors[c] = COLORREFToQColor(m_customColors[c]).rgb(); emit accepted(); if (QWindowsContext::verboseDialogs) - qDebug() << '<' << __FUNCTION__ << m_color; + qDebug() << '<' << __FUNCTION__ << *m_color; } else { emit rejected(); } @@ -2044,7 +2044,7 @@ void QWindowsNativeColorDialog::exec(HWND owner) class QWindowsColorDialogHelper : public QWindowsDialogHelperBase<QPlatformColorDialogHelper> { public: - QWindowsColorDialogHelper() {} + QWindowsColorDialogHelper() : m_currentColor(new QColor) {} virtual bool supportsNonModalDialog() { return false; } @@ -2064,6 +2064,8 @@ QWindowsNativeDialogBase *QWindowsColorDialogHelper::createNativeDialog() { QWindowsNativeColorDialog *nativeDialog = new QWindowsNativeColorDialog(m_currentColor); nativeDialog->setWindowTitle(options()->windowTitle()); + connect(nativeDialog, SIGNAL(accepted()), this, SIGNAL(accept())); + connect(nativeDialog, SIGNAL(rejected()), this, SIGNAL(reject())); return nativeDialog; } #endif // USE_NATIVE_COLOR_DIALOG @@ -2096,9 +2098,9 @@ QPlatformDialogHelper *createHelper(QPlatformTheme::DialogType type) return 0; switch (type) { case QPlatformTheme::FileDialog: -#ifndef Q_OS_WINCE +#ifndef Q_OS_WINCE // Note: "Windows XP Professional x64 Edition has version number WV_5_2 (WV_2003). if (QWindowsIntegration::instance()->options() & QWindowsIntegration::XpNativeDialogs - || QSysInfo::windowsVersion() == QSysInfo::WV_XP) { + || QSysInfo::windowsVersion() <= QSysInfo::WV_2003) { return new QWindowsXpFileDialogHelper(); } if (QSysInfo::windowsVersion() > QSysInfo::WV_XP) diff --git a/src/plugins/platforms/windows/qwindowsmousehandler.cpp b/src/plugins/platforms/windows/qwindowsmousehandler.cpp index c6cfa4dbbc..43286eadf3 100644 --- a/src/plugins/platforms/windows/qwindowsmousehandler.cpp +++ b/src/plugins/platforms/windows/qwindowsmousehandler.cpp @@ -157,14 +157,19 @@ bool QWindowsMouseHandler::translateMouseEvent(QWindow *window, HWND hwnd, QtWindows::WindowsEventType et, MSG msg, LRESULT *result) { - enum { signatureMask = 0xffffff00, miWpSignature = 0xff515700 }; +#ifdef Q_COMPILER_CLASS_ENUM + enum : quint64 { signatureMask = 0xffffff00, miWpSignature = 0xff515700 }; +#else + static const quint64 signatureMask = 0xffffff00; + static const quint64 miWpSignature = 0xff515700; +#endif // !Q_COMPILER_CLASS_ENUM if (et == QtWindows::MouseWheelEvent) return translateMouseWheelEvent(window, hwnd, msg, result); #ifndef Q_OS_WINCE // Check for events synthesized from touch. Lower byte is touch index, 0 means pen. - const LPARAM extraInfo = GetMessageExtraInfo(); + const quint64 extraInfo = GetMessageExtraInfo(); const bool fromTouch = (extraInfo & signatureMask) == miWpSignature && (extraInfo & 0xff); if (fromTouch) return false; diff --git a/src/plugins/platforms/windows/qwindowsservices.cpp b/src/plugins/platforms/windows/qwindowsservices.cpp index 250fea56b1..546957a043 100644 --- a/src/plugins/platforms/windows/qwindowsservices.cpp +++ b/src/plugins/platforms/windows/qwindowsservices.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ +#define QT_NO_URL_CAST_FROM_STRING #include "qwindowsservices.h" #include "qtwindows_additional.h" @@ -55,19 +56,20 @@ QT_BEGIN_NAMESPACE enum { debug = 0 }; -static inline bool shellExecute(const QString &file) +static inline bool shellExecute(const QUrl &url) { #ifndef Q_OS_WINCE - const QString nativeFilePath = QDir::toNativeSeparators(file); + const QString nativeFilePath = + url.isLocalFile() ? QDir::toNativeSeparators(url.toLocalFile()) : url.toString(QUrl::FullyEncoded); const quintptr result = (quintptr)ShellExecute(0, 0, (wchar_t*)nativeFilePath.utf16(), 0, 0, SW_SHOWNORMAL); // ShellExecute returns a value greater than 32 if successful if (result <= 32) { - qWarning("ShellExecute '%s' failed (error %s).", qPrintable(file), qPrintable(QString::number(result))); + qWarning("ShellExecute '%s' failed (error %s).", qPrintable(url.toString()), qPrintable(QString::number(result))); return false; } return true; #else - Q_UNUSED(file) + Q_UNUSED(url); return false; #endif } @@ -131,7 +133,7 @@ static inline bool launchMail(const QUrl &url) } // Pass the url as the parameter. Should use QProcess::startDetached(), // but that cannot handle a Windows command line [yet]. - command.replace(QStringLiteral("%1"), url.toString()); + command.replace(QStringLiteral("%1"), url.toString(QUrl::FullyEncoded)); if (debug) qDebug() << __FUNCTION__ << "Launching" << command; //start the process @@ -152,16 +154,14 @@ static inline bool launchMail(const QUrl &url) bool QWindowsServices::openUrl(const QUrl &url) { const QString scheme = url.scheme(); - if (scheme.isEmpty()) - return openDocument(url); if (scheme == QStringLiteral("mailto") && launchMail(url)) return true; - return shellExecute(QLatin1String(url.toEncoded())); + return shellExecute(url); } bool QWindowsServices::openDocument(const QUrl &url) { - return shellExecute(url.isLocalFile() ? url.toLocalFile() : url.toString()); + return shellExecute(url); } QT_END_NAMESPACE diff --git a/src/plugins/platforms/windows/qwindowswindow.cpp b/src/plugins/platforms/windows/qwindowswindow.cpp index 08ff7123eb..c3ec949eef 100644 --- a/src/plugins/platforms/windows/qwindowswindow.cpp +++ b/src/plugins/platforms/windows/qwindowswindow.cpp @@ -845,7 +845,6 @@ QWindowsWindow::QWindowsWindow(QWindow *aWindow, const WindowData &data) : QWindowsWindow::~QWindowsWindow() { #ifndef Q_OS_WINCE - QWindowSystemInterface::flushWindowSystemEvents(); if (testFlag(TouchRegistered)) QWindowsContext::user32dll.unregisterTouchWindow(m_data.hwnd); #endif // !Q_OS_WINCE @@ -1390,9 +1389,22 @@ void QWindowsWindow::handleWindowStateChange(Qt::WindowState state) setFlag(FrameDirty); m_windowState = state; QWindowSystemInterface::handleWindowStateChanged(window(), state); - if (state == Qt::WindowMinimized) { + switch (state) { + case Qt::WindowMinimized: handleHidden(); QWindowSystemInterface::flushWindowSystemEvents(); // Tell QQuickWindow to stop rendering now. + break; + case Qt::WindowNoState: + // QTBUG-17548: We send expose events when receiving WM_Paint, but for + // layered windows, we won't receive any WM_Paint. + if (GetWindowLongPtr(m_data.hwnd, GWL_EXSTYLE) & WS_EX_LAYERED) { + fireExpose(QRegion(0, 0, window()->width(), window()->height())); + if (!QWindowsContext::instance()->asyncExpose()) + QWindowSystemInterface::flushWindowSystemEvents(); + } + break; + default: + break; } } diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.cpp b/src/plugins/platforms/xcb/qxcbkeyboard.cpp index 751bd168f6..5fbc23c049 100644 --- a/src/plugins/platforms/xcb/qxcbkeyboard.cpp +++ b/src/plugins/platforms/xcb/qxcbkeyboard.cpp @@ -1043,6 +1043,10 @@ void QXcbKeyboard::updateVModMapping() vmod_masks.meta = bit; else if (qstrcmp(vmod_name, "AltGr") == 0) vmod_masks.altgr = bit; + else if (qstrcmp(vmod_name, "Super") == 0) + vmod_masks.super = bit; + else if (qstrcmp(vmod_name, "Hyper") == 0) + vmod_masks.hyper = bit; } free(name_reply); @@ -1104,9 +1108,14 @@ void QXcbKeyboard::updateVModToRModMapping() rmod_masks.meta = modmap; else if (vmod_masks.altgr == bit) rmod_masks.altgr = modmap; + else if (vmod_masks.super == bit) + rmod_masks.super = modmap; + else if (vmod_masks.hyper == bit) + rmod_masks.hyper = modmap; } free(map_reply); + resolveMaskConflicts(); } #else void QXcbKeyboard::updateModifiers() @@ -1131,7 +1140,8 @@ void QXcbKeyboard::updateModifiers() // for Alt and Meta L and R are the same static const xcb_keysym_t symbols[] = { - XK_Alt_L, XK_Meta_L, XK_Mode_switch + XK_Alt_L, XK_Meta_L, XK_Mode_switch, XK_Super_L, XK_Super_R, + XK_Hyper_L, XK_Hyper_R }; static const size_t numSymbols = sizeof symbols / sizeof *symbols; @@ -1157,6 +1167,10 @@ void QXcbKeyboard::updateModifiers() rmod_masks.meta = mask; if (sym == XK_Mode_switch) rmod_masks.altgr = mask; + if ((sym == XK_Super_L) || (sym == XK_Super_R)) + rmod_masks.super = mask; + if ((sym == XK_Hyper_L) || (sym == XK_Hyper_R)) + rmod_masks.hyper = mask; } } } @@ -1165,9 +1179,28 @@ void QXcbKeyboard::updateModifiers() for (size_t i = 0; i < numSymbols; ++i) free(modKeyCodes[i]); free(modMapReply); + resolveMaskConflicts(); } #endif +void QXcbKeyboard::resolveMaskConflicts() +{ + // if we don't have a meta key (or it's hidden behind alt), use super or hyper to generate + // Qt::Key_Meta and Qt::MetaModifier, since most newer XFree86/Xorg installations map the Windows + // key to Super + if (rmod_masks.alt == rmod_masks.meta) + rmod_masks.meta = 0; + + if (rmod_masks.meta == 0) { + // no meta keys... s/meta/super, + rmod_masks.meta = rmod_masks.super; + if (rmod_masks.meta == 0) { + // no super keys either? guess we'll use hyper then + rmod_masks.meta = rmod_masks.hyper; + } + } +} + class KeyChecker { public: diff --git a/src/plugins/platforms/xcb/qxcbkeyboard.h b/src/plugins/platforms/xcb/qxcbkeyboard.h index af6677c20f..770a7eabea 100644 --- a/src/plugins/platforms/xcb/qxcbkeyboard.h +++ b/src/plugins/platforms/xcb/qxcbkeyboard.h @@ -84,6 +84,7 @@ public: protected: void handleKeyEvent(QWindow *window, QEvent::Type type, xcb_keycode_t code, quint16 state, xcb_timestamp_t time); + void resolveMaskConflicts(); QString keysymToUnicode(xcb_keysym_t sym) const; @@ -111,6 +112,8 @@ private: uint alt; uint altgr; uint meta; + uint super; + uint hyper; }; _mod_masks rmod_masks; diff --git a/src/plugins/platforms/xcb/qxcbwindow.cpp b/src/plugins/platforms/xcb/qxcbwindow.cpp index b9a2b0d37b..3a19788316 100644 --- a/src/plugins/platforms/xcb/qxcbwindow.cpp +++ b/src/plugins/platforms/xcb/qxcbwindow.cpp @@ -239,7 +239,7 @@ void QXcbWindow::create() // XCB_CW_BACK_PIXMAP XCB_NONE, // XCB_CW_OVERRIDE_REDIRECT - type == Qt::Popup || type == Qt::ToolTip, + type == Qt::Popup || type == Qt::ToolTip || (window()->flags() & Qt::BypassWindowManagerHint), // XCB_CW_SAVE_UNDER type == Qt::Popup || type == Qt::Tool || type == Qt::SplashScreen || type == Qt::ToolTip || type == Qt::Drawer, // XCB_CW_EVENT_MASK diff --git a/src/printsupport/kernel/qcups.cpp b/src/printsupport/kernel/qcups.cpp index d2deee1db3..49a97e327c 100644 --- a/src/printsupport/kernel/qcups.cpp +++ b/src/printsupport/kernel/qcups.cpp @@ -478,15 +478,6 @@ static inline QPrinter::PaperSize string2PaperSize(const char *name) return QPrinter::Custom; } -static inline const char *paperSize2String(QPrinter::PaperSize size) -{ - for (int i = 0; i < QPrinter::NPageSize; ++i) { - if (size == named_sizes_map[i].size) - return named_sizes_map[i].name; - } - return 0; -} - QList<QPrinter::PaperSize> QCUPSSupport::getCupsPrinterPaperSizes(int cupsPrinterIndex) { QList<QPrinter::PaperSize> result; diff --git a/src/sql/drivers/psql/qsql_psql_p.h b/src/sql/drivers/psql/qsql_psql_p.h index 5f4aa68b9e..d5dbda4058 100644 --- a/src/sql/drivers/psql/qsql_psql_p.h +++ b/src/sql/drivers/psql/qsql_psql_p.h @@ -119,7 +119,7 @@ public: Version82 = 13, Version83 = 14, Version84 = 15, - Version9 = 16, + Version9 = 16 }; explicit QPSQLDriver(QObject *parent=0); diff --git a/src/sql/kernel/qsqlcachedresult.cpp b/src/sql/kernel/qsqlcachedresult.cpp index 6456186bd2..2ec7e4e20f 100644 --- a/src/sql/kernel/qsqlcachedresult.cpp +++ b/src/sql/kernel/qsqlcachedresult.cpp @@ -253,7 +253,7 @@ QVariant QSqlCachedResult::data(int i) bool QSqlCachedResult::isNull(int i) { int idx = d->forwardOnly ? i : at() * d->colCount + i; - if (i > d->colCount || i < 0 || at() < 0 || idx >= d->rowCacheEnd) + if (i >= d->colCount || i < 0 || at() < 0 || idx >= d->rowCacheEnd) return true; return d->cache.at(idx).isNull(); diff --git a/src/tools/moc/moc.cpp b/src/tools/moc/moc.cpp index f3bfcc3144..fd1d2155fc 100644 --- a/src/tools/moc/moc.cpp +++ b/src/tools/moc/moc.cpp @@ -870,7 +870,12 @@ void Moc::generate(FILE *out) findRequiredContainers(&classList[i], &requiredQtContainers); } - foreach (const QByteArray &qtContainer, requiredQtContainers) { + // after finding the containers, we sort them into a list to avoid + // non-deterministic behavior which may cause rebuilds unnecessarily. + QList<QByteArray> requiredContainerList = requiredQtContainers.toList(); + std::sort(requiredContainerList.begin(), requiredContainerList.end()); + + foreach (const QByteArray &qtContainer, requiredContainerList) { fprintf(out, "#include <QtCore/%s>\n", qtContainer.constData()); } diff --git a/src/tools/qdoc/htmlgenerator.cpp b/src/tools/qdoc/htmlgenerator.cpp index 8afc1c749a..64c2e02a35 100644 --- a/src/tools/qdoc/htmlgenerator.cpp +++ b/src/tools/qdoc/htmlgenerator.cpp @@ -493,7 +493,7 @@ int HtmlGenerator::generateAtom(const Atom *atom, const Node *relative, CodeMark else if (atom->string() == "classes") { generateCompactList(Generic, relative, qdb_->getCppClasses(), true); } - else if (atom->string() == "qmlclasses") { + else if (atom->string() == "qmltypes") { generateCompactList(Generic, relative, qdb_->getQmlTypes(), true); } else if (atom->string().contains("classesbymodule")) { diff --git a/src/widgets/dialogs/qcolordialog.cpp b/src/widgets/dialogs/qcolordialog.cpp index 3d720e59e6..5da41aa0a5 100644 --- a/src/widgets/dialogs/qcolordialog.cpp +++ b/src/widgets/dialogs/qcolordialog.cpp @@ -136,6 +136,7 @@ public: signals: void selected(int row, int col); + void currentChanged(int row, int col); protected: virtual void paintCell(QPainter *, int row, int col, const QRect&); @@ -311,6 +312,8 @@ void QWellArray::setCurrent(int row, int col) updateCell(oldRow, oldCol); updateCell(curRow, curCol); + + emit currentChanged(curRow, curCol); } /* @@ -344,6 +347,7 @@ void QWellArray::setSelected(int row, int col) void QWellArray::focusInEvent(QFocusEvent*) { updateCell(curRow, curCol); + emit currentChanged(curRow, curCol); } void QWellArray::setCellBrush(int row, int col, const QBrush &b) @@ -1493,11 +1497,15 @@ void QColorDialogPrivate::_q_newColorTypedIn(QRgb rgb) } } +void QColorDialogPrivate::_q_nextCustom(int r, int c) +{ + nextCust = r + 2 * c; +} + void QColorDialogPrivate::_q_newCustom(int r, int c) { const int i = r + 2 * c; setCurrentColor(QColorDialogOptions::customColor(i)); - nextCust = i; if (standard) standard->setSelected(-1,-1); } @@ -1627,6 +1635,7 @@ void QColorDialogPrivate::initWidgets() custom->setAcceptDrops(true); q->connect(custom, SIGNAL(selected(int,int)), SLOT(_q_newCustom(int,int))); + q->connect(custom, SIGNAL(currentChanged(int,int)), SLOT(_q_nextCustom(int,int))); lblCustomColors = new QLabel(q); #ifndef QT_NO_SHORTCUT lblCustomColors->setBuddy(custom); diff --git a/src/widgets/dialogs/qcolordialog.h b/src/widgets/dialogs/qcolordialog.h index e76a120c3a..c7a1d6f400 100644 --- a/src/widgets/dialogs/qcolordialog.h +++ b/src/widgets/dialogs/qcolordialog.h @@ -123,6 +123,7 @@ private: Q_PRIVATE_SLOT(d_func(), void _q_addCustom()) Q_PRIVATE_SLOT(d_func(), void _q_newHsv(int h, int s, int v)) Q_PRIVATE_SLOT(d_func(), void _q_newColorTypedIn(QRgb rgb)) + Q_PRIVATE_SLOT(d_func(), void _q_nextCustom(int, int)) Q_PRIVATE_SLOT(d_func(), void _q_newCustom(int, int)) Q_PRIVATE_SLOT(d_func(), void _q_newStandard(int, int)) Q_PRIVATE_SLOT(d_func(), void _q_pickScreenColor()) diff --git a/src/widgets/dialogs/qcolordialog_p.h b/src/widgets/dialogs/qcolordialog_p.h index 71be0e61d3..08199cc7c1 100644 --- a/src/widgets/dialogs/qcolordialog_p.h +++ b/src/widgets/dialogs/qcolordialog_p.h @@ -100,6 +100,7 @@ public: void _q_newHsv(int h, int s, int v); void _q_newColorTypedIn(QRgb rgb); + void _q_nextCustom(int, int); void _q_newCustom(int, int); void _q_newStandard(int, int); void _q_pickScreenColor(); diff --git a/src/widgets/effects/qgraphicseffect.cpp b/src/widgets/effects/qgraphicseffect.cpp index ac873709e1..420392c0fb 100644 --- a/src/widgets/effects/qgraphicseffect.cpp +++ b/src/widgets/effects/qgraphicseffect.cpp @@ -864,8 +864,6 @@ void QGraphicsBlurEffect::draw(QPainter *painter) } PixmapPadMode mode = PadToEffectiveBoundingRect; - if (painter->paintEngine()->type() == QPaintEngine::OpenGL2) - mode = NoPad; QPoint offset; QPixmap pixmap = sourcePixmap(Qt::LogicalCoordinates, &offset, mode); @@ -1057,8 +1055,6 @@ void QGraphicsDropShadowEffect::draw(QPainter *painter) } PixmapPadMode mode = PadToEffectiveBoundingRect; - if (painter->paintEngine()->type() == QPaintEngine::OpenGL2) - mode = NoPad; // Draw pixmap in device coordinates to avoid pixmap scaling. QPoint offset; diff --git a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp index e281e4a7a3..93fb968d69 100644 --- a/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp +++ b/src/widgets/graphicsview/qgraphicsanchorlayout_p.cpp @@ -661,20 +661,6 @@ Qt::AnchorPoint QGraphicsAnchorLayoutPrivate::oppositeEdge(Qt::AnchorPoint edge) /*! - * \internal - * - * helper function in order to avoid overflowing anchor sizes - * the returned size will never be larger than FLT_MAX - * - */ -inline static qreal checkAdd(qreal a, qreal b) -{ - if (FLT_MAX - b < a) - return FLT_MAX; - return a + b; -} - -/*! \internal Adds \a newAnchor to the graph. diff --git a/src/widgets/graphicsview/qgraphicsitem.cpp b/src/widgets/graphicsview/qgraphicsitem.cpp index 668436c1a2..1c15905ff0 100644 --- a/src/widgets/graphicsview/qgraphicsitem.cpp +++ b/src/widgets/graphicsview/qgraphicsitem.cpp @@ -2741,7 +2741,7 @@ QGraphicsEffect *QGraphicsItem::graphicsEffect() const the new \a effect. You can delete an existing effect by calling setGraphicsEffect(0). - If \a effect is the installed on a different item, setGraphicsEffect() will remove + If \a effect is the installed effect on a different item, setGraphicsEffect() will remove the effect from the item and install it on this item. QGraphicsItem takes ownership of \a effect. diff --git a/src/widgets/graphicsview/qgraphicsscene.cpp b/src/widgets/graphicsview/qgraphicsscene.cpp index 88cccb5118..394c24d671 100644 --- a/src/widgets/graphicsview/qgraphicsscene.cpp +++ b/src/widgets/graphicsview/qgraphicsscene.cpp @@ -1810,10 +1810,6 @@ void QGraphicsScene::render(QPainter *painter, const QRectF &target, const QRect .translate(-sourceRect.left(), -sourceRect.top()); painter->setWorldTransform(painterTransform, true); - // Two unit vectors. - QLineF v1(0, 0, 1, 0); - QLineF v2(0, 0, 0, 1); - // Generate the style options QStyleOptionGraphicsItem *styleOptionArray = new QStyleOptionGraphicsItem[numItems]; for (int i = 0; i < numItems; ++i) diff --git a/src/widgets/kernel/qapplication.cpp b/src/widgets/kernel/qapplication.cpp index cb2eab8468..27a152b706 100644 --- a/src/widgets/kernel/qapplication.cpp +++ b/src/widgets/kernel/qapplication.cpp @@ -556,7 +556,7 @@ void QApplicationPrivate::construct() eventDispatcher->startingUp(); #ifdef QT_EVAL - extern void qt_gui_eval_init(uint); + extern void qt_gui_eval_init(QCoreApplicationPrivate::Type); qt_gui_eval_init(application_type); #endif diff --git a/src/widgets/kernel/qapplication_qpa.cpp b/src/widgets/kernel/qapplication_qpa.cpp index f6a8a3af3d..0fc065e74b 100644 --- a/src/widgets/kernel/qapplication_qpa.cpp +++ b/src/widgets/kernel/qapplication_qpa.cpp @@ -126,6 +126,8 @@ bool QApplicationPrivate::modalState() QWidget *qt_tlw_for_window(QWindow *wnd) { + while (wnd && !wnd->isTopLevel()) // QTBUG-32177, wnd might be a QQuickView embedded via window container. + wnd = wnd->parent(); if (wnd) foreach (QWidget *tlw, qApp->topLevelWidgets()) if (tlw->windowHandle() == wnd) diff --git a/src/widgets/kernel/qwidget.cpp b/src/widgets/kernel/qwidget.cpp index 2d19175725..869362654c 100644 --- a/src/widgets/kernel/qwidget.cpp +++ b/src/widgets/kernel/qwidget.cpp @@ -4840,7 +4840,7 @@ QGraphicsEffect *QWidget::graphicsEffect() const on this widget, QWidget will delete the existing effect before installing the new \a effect. - If \a effect is the installed on a different widget, setGraphicsEffect() will remove + If \a effect is the installed effect on a different widget, setGraphicsEffect() will remove the effect from the widget and install it on this widget. QWidget takes ownership of \a effect. diff --git a/src/widgets/kernel/qwidget_qpa.cpp b/src/widgets/kernel/qwidget_qpa.cpp index dafe7dc42a..f0846bea6b 100644 --- a/src/widgets/kernel/qwidget_qpa.cpp +++ b/src/widgets/kernel/qwidget_qpa.cpp @@ -887,6 +887,10 @@ void QWidgetPrivate::deleteSysExtra() } +#ifdef Q_OS_WIN +static const char activeXNativeParentHandleProperty[] = "_q_embedded_native_parent_handle"; +#endif + void QWidgetPrivate::createTLSysExtra() { Q_Q(QWidget); @@ -897,6 +901,10 @@ void QWidgetPrivate::createTLSysExtra() if (extra->maxw != QWIDGETSIZE_MAX || extra->maxh != QWIDGETSIZE_MAX) extra->topextra->window->setMaximumSize(QSize(extra->maxw, extra->maxh)); #ifdef Q_OS_WIN + // Pass on native parent handle for Widget embedded into Active X. + const QVariant activeXNativeParentHandle = q->property(activeXNativeParentHandleProperty); + if (activeXNativeParentHandle.isValid()) + extra->topextra->window->setProperty(activeXNativeParentHandleProperty, activeXNativeParentHandle); if (q->inherits("QTipLabel") || q->inherits("QAlphaWidget")) extra->topextra->window->setProperty("_q_windowsDropShadow", QVariant(true)); #endif diff --git a/src/widgets/styles/qfusionstyle.cpp b/src/widgets/styles/qfusionstyle.cpp index 41046a1254..149a5c6674 100644 --- a/src/widgets/styles/qfusionstyle.cpp +++ b/src/widgets/styles/qfusionstyle.cpp @@ -1219,6 +1219,10 @@ void QFusionStyle::drawControl(ControlElement element, const QStyleOption *optio - titleRect.bottom(), r.top() + titleRect.left() - rect.left(), titleRect.height(), titleRect.width()); + + painter->translate(r.left(), r.top() + r.width()); + painter->rotate(-90); + painter->translate(-r.left(), -r.top()); } if (!dwOpt->title.isEmpty()) { diff --git a/src/widgets/util/qsystemtrayicon_x11.cpp b/src/widgets/util/qsystemtrayicon_x11.cpp index e04656974d..5204b85a9a 100644 --- a/src/widgets/util/qsystemtrayicon_x11.cpp +++ b/src/widgets/util/qsystemtrayicon_x11.cpp @@ -153,16 +153,17 @@ private: QSystemTrayIcon *q; }; -QSystemTrayIconSys::QSystemTrayIconSys(QSystemTrayIcon *qIn) : - q(qIn) +QSystemTrayIconSys::QSystemTrayIconSys(QSystemTrayIcon *qIn) + : QWidget(0, Qt::Window | Qt::FramelessWindowHint | Qt::BypassWindowManagerHint) + , q(qIn) { + setObjectName(QStringLiteral("QSystemTrayIconSys")); setToolTip(q->toolTip()); QX11SystemTrayContext *context = qX11SystemTrayContext(); Q_ASSERT(context->isValid()); setAttribute(Qt::WA_AlwaysShowToolTips, true); setAttribute(Qt::WA_TranslucentBackground, true); setAttribute(Qt::WA_QuitOnClose, false); - setWindowFlags(Qt::Window | Qt::FramelessWindowHint); const QSize size(22, 22); // Gnome, standard size setGeometry(QRect(QPoint(0, 0), size)); setMinimumSize(size); @@ -182,7 +183,6 @@ QSystemTrayIconSys::QSystemTrayIconSys(QSystemTrayIcon *qIn) : ev.xclient.format = 32; memcpy((char *)&ev.xclient.data, (const char *) l, sizeof(l)); XSendEvent(display, ev.xclient.window, False, 0, &ev); - XSync(display, False); show(); } diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 6424ee41f1..b89067155d 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -1136,10 +1136,9 @@ Qt::MatchFlags QComboBoxPrivate::matchFlags() const void QComboBoxPrivate::_q_editingFinished() { Q_Q(QComboBox); - if (lineEdit && !lineEdit->text().isEmpty()) { - //here we just check if the current item was entered + if (lineEdit && !lineEdit->text().isEmpty() && itemText(currentIndex) != lineEdit->text()) { const int index = q_func()->findText(lineEdit->text(), matchFlags()); - if (index != -1 && itemText(currentIndex) != lineEdit->text()) { + if (index != -1) { q->setCurrentIndex(index); emitActivated(currentIndex); } diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp index ca831f5a39..ac061e7071 100644 --- a/src/widgets/widgets/qdockarealayout.cpp +++ b/src/widgets/widgets/qdockarealayout.cpp @@ -2577,7 +2577,6 @@ void QDockAreaLayout::remove(const QList<int> &path) docks[index].remove(path.mid(1)); } -static inline int qMin(int i1, int i2, int i3) { return qMin(i1, qMin(i2, i3)); } static inline int qMax(int i1, int i2, int i3) { return qMax(i1, qMax(i2, i3)); } void QDockAreaLayout::getGrid(QVector<QLayoutStruct> *_ver_struct_list, diff --git a/src/widgets/widgets/qlineedit.cpp b/src/widgets/widgets/qlineedit.cpp index 7cc783fecc..4254ef2b27 100644 --- a/src/widgets/widgets/qlineedit.cpp +++ b/src/widgets/widgets/qlineedit.cpp @@ -1808,9 +1808,9 @@ void QLineEdit::paintEvent(QPaintEvent *) col.setAlpha(128); QPen oldpen = p.pen(); p.setPen(col); - lineRect.adjust(minLB, 0, 0, 0); - QString elidedText = fm.elidedText(d->placeholderText, Qt::ElideRight, lineRect.width()); - p.drawText(lineRect, va, elidedText); + QRect ph = lineRect.adjusted(minLB, 0, 0, 0); + QString elidedText = fm.elidedText(d->placeholderText, Qt::ElideRight, ph.width()); + p.drawText(ph, va, elidedText); p.setPen(oldpen); } } diff --git a/src/widgets/widgets/qmainwindowlayout.cpp b/src/widgets/widgets/qmainwindowlayout.cpp index cfeb0e2c67..92a1274d7c 100644 --- a/src/widgets/widgets/qmainwindowlayout.cpp +++ b/src/widgets/widgets/qmainwindowlayout.cpp @@ -1016,19 +1016,6 @@ void QMainWindowLayout::toggleToolBarsVisible() #ifndef QT_NO_DOCKWIDGET -static inline void validateDockWidgetArea(Qt::DockWidgetArea &area) -{ - switch (area) { - case Qt::LeftDockWidgetArea: - case Qt::RightDockWidgetArea: - case Qt::TopDockWidgetArea: - case Qt::BottomDockWidgetArea: - break; - default: - area = Qt::LeftDockWidgetArea; - } -} - static QInternal::DockPosition toDockPos(Qt::DockWidgetArea area) { switch (area) { diff --git a/src/xml/doc/src/xml-processing.qdoc b/src/xml/doc/src/xml-processing.qdoc index c7c3edeeb0..8f534fe7a0 100644 --- a/src/xml/doc/src/xml-processing.qdoc +++ b/src/xml/doc/src/xml-processing.qdoc @@ -233,7 +233,7 @@ {hasError()} can be used to check and view the errors. An example of QXmlStreamReader implementation would be the \c XbelReader in - \l{QXmlStream Bookmarks Example}, which is a subclass of QXmlStreamReader. + \l{QXmlStream Bookmarks Example}, which wraps a QXmlStreamReader. The constructor takes \a treeWidget as a parameter and the class has Xbel specific functions: @@ -278,8 +278,8 @@ or subsequent calls to \l{QXmlStreamWriter::writeStartElement()} {writeStartElement()}. - The \c XbelWriter class from \l{QXmlStream Bookmarks Example} is a subclass - of QXmlStreamWriter. Its \c writeFile() function illustrates the core + The \c XbelWriter class from \l{QXmlStream Bookmarks Example} wraps a + QXmlStreamWriter. Its \c writeFile() function illustrates the core functions of QXmlStreamWriter mentioned above: \snippet streambookmarks/xbelwriter.cpp 1 |