diff options
Diffstat (limited to 'src/corelib')
23 files changed, 182 insertions, 125 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() |