diff options
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/io/qprocess_unix.cpp | 10 | ||||
-rw-r--r-- | src/corelib/json/qjsonobject.cpp | 10 | ||||
-rw-r--r-- | src/corelib/json/qjsonobject.h | 2 | ||||
-rw-r--r-- | src/corelib/kernel/qeventdispatcher_winrt.cpp | 13 | ||||
-rw-r--r-- | src/corelib/kernel/qsharedmemory_win.cpp | 6 | ||||
-rw-r--r-- | src/corelib/kernel/qvariant.h | 4 | ||||
-rw-r--r-- | src/corelib/plugin/qlibrary_win.cpp | 9 | ||||
-rw-r--r-- | src/corelib/tools/qsharedpointer_impl.h | 2 | ||||
-rw-r--r-- | src/corelib/tools/qstring.cpp | 24 | ||||
-rw-r--r-- | src/corelib/tools/qstring.h | 7 | ||||
-rw-r--r-- | src/corelib/tools/qtimezone.cpp | 5 |
11 files changed, 72 insertions, 20 deletions
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp index 9a25f56c5f..ab5734a298 100644 --- a/src/corelib/io/qprocess_unix.cpp +++ b/src/corelib/io/qprocess_unix.cpp @@ -92,6 +92,7 @@ QT_END_NAMESPACE #include <private/qthread_p.h> #include <qfile.h> #include <qfileinfo.h> +#include <qdir.h> #include <qlist.h> #include <qmutex.h> #include <qsemaphore.h> @@ -362,11 +363,14 @@ void QProcessPrivate::startProcess() static QBasicMutex cfbundleMutex; QMutexLocker lock(&cfbundleMutex); QCFType<CFBundleRef> bundle = CFBundleCreate(0, url); - url = CFBundleCopyExecutableURL(bundle); + // 'executableURL' can be either relative or absolute ... + QCFType<CFURLRef> executableURL = CFBundleCopyExecutableURL(bundle); + // not to depend on caching - make sure it's always absolute. + url = CFURLCopyAbsoluteURL(executableURL); } if (url) { - QCFString str = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle); - encodedProgramName += "/Contents/MacOS/" + QCFString::toQString(str).toUtf8(); + const QCFString str = CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle); + encodedProgramName += (QDir::separator() + QDir(program).relativeFilePath(QCFString::toQString(str))).toUtf8(); } } #endif diff --git a/src/corelib/json/qjsonobject.cpp b/src/corelib/json/qjsonobject.cpp index b7dfe88434..c225606717 100644 --- a/src/corelib/json/qjsonobject.cpp +++ b/src/corelib/json/qjsonobject.cpp @@ -693,6 +693,11 @@ QJsonObject::const_iterator QJsonObject::constFind(const QString &key) const \internal */ +/*! \typedef QJsonObject::iterator::pointer + + \internal +*/ + /*! \fn QJsonObject::iterator::iterator() Constructs an uninitialized iterator. @@ -895,6 +900,11 @@ QJsonObject::const_iterator QJsonObject::constFind(const QString &key) const \internal */ +/*! \typedef QJsonObject::const_iterator::pointer + + \internal +*/ + /*! \fn QJsonObject::const_iterator::const_iterator() Constructs an uninitialized iterator. diff --git a/src/corelib/json/qjsonobject.h b/src/corelib/json/qjsonobject.h index 19c938fd83..5b475f52ae 100644 --- a/src/corelib/json/qjsonobject.h +++ b/src/corelib/json/qjsonobject.h @@ -104,6 +104,7 @@ public: typedef int difference_type; typedef QJsonValue value_type; typedef QJsonValueRef reference; + typedef QJsonValuePtr pointer; Q_DECL_CONSTEXPR inline iterator() : o(Q_NULLPTR), i(0) {} Q_DECL_CONSTEXPR inline iterator(QJsonObject *obj, int index) : o(obj), i(index) {} @@ -146,6 +147,7 @@ public: typedef int difference_type; typedef QJsonValue value_type; typedef QJsonValue reference; + typedef QJsonValuePtr pointer; Q_DECL_CONSTEXPR inline const_iterator() : o(Q_NULLPTR), i(0) {} Q_DECL_CONSTEXPR inline const_iterator(const QJsonObject *obj, int index) diff --git a/src/corelib/kernel/qeventdispatcher_winrt.cpp b/src/corelib/kernel/qeventdispatcher_winrt.cpp index 58b87bd36b..df070dd1ae 100644 --- a/src/corelib/kernel/qeventdispatcher_winrt.cpp +++ b/src/corelib/kernel/qeventdispatcher_winrt.cpp @@ -201,14 +201,16 @@ bool QEventDispatcherWinRT::processEvents(QEventLoop::ProcessEventsFlags flags) { Q_D(QEventDispatcherWinRT); + DWORD waitTime = 0; do { // Additional user events have to be handled before timer events, but the function may not // return yet. const bool userEventsSent = sendPostedEvents(flags); - emit aboutToBlock(); const QVector<HANDLE> timerHandles = d->timerIdToHandle.values().toVector(); - DWORD waitResult = WaitForMultipleObjectsEx(timerHandles.count(), timerHandles.constData(), FALSE, 1, TRUE); + if (waitTime) + emit aboutToBlock(); + DWORD waitResult = WaitForMultipleObjectsEx(timerHandles.count(), timerHandles.constData(), FALSE, waitTime, TRUE); if (waitResult >= WAIT_OBJECT_0 && waitResult < WAIT_OBJECT_0 + timerHandles.count()) { const HANDLE handle = timerHandles.value(waitResult - WAIT_OBJECT_0); ResetEvent(handle); @@ -231,6 +233,13 @@ bool QEventDispatcherWinRT::processEvents(QEventLoop::ProcessEventsFlags flags) if (userEventsSent) return true; + + // We cannot wait infinitely like on other platforms, as + // WaitForMultipleObjectsEx might not return. + // For instance win32 uses MsgWaitForMultipleObjects to hook + // into the native event loop, while WinRT handles those + // via callbacks. + waitTime = 1; } while (flags & QEventLoop::WaitForMoreEvents); return false; } diff --git a/src/corelib/kernel/qsharedmemory_win.cpp b/src/corelib/kernel/qsharedmemory_win.cpp index 5cc54b1def..f90763d308 100644 --- a/src/corelib/kernel/qsharedmemory_win.cpp +++ b/src/corelib/kernel/qsharedmemory_win.cpp @@ -58,7 +58,7 @@ void QSharedMemoryPrivate::setErrorString(QLatin1String function) errorString = QSharedMemory::tr("%1: already exists").arg(function); break; case ERROR_FILE_NOT_FOUND: -#ifdef Q_OS_WINCE +#if defined(Q_OS_WINCE) || (defined(Q_OS_WINRT) && _MSC_VER < 1900) // This happens on CE only if no file is present as CreateFileMappingW // bails out with this error code case ERROR_INVALID_PARAMETER: @@ -101,7 +101,11 @@ HANDLE QSharedMemoryPrivate::handle() Q_UNIMPLEMENTED(); hand = 0; #elif defined(Q_OS_WINRT) +#if _MSC_VER >= 1900 + hand = OpenFileMappingFromApp(FILE_MAP_ALL_ACCESS, FALSE, reinterpret_cast<PCWSTR>(nativeKey.utf16())); +#else hand = CreateFileMappingFromApp(INVALID_HANDLE_VALUE, 0, PAGE_READWRITE, 0, (PCWSTR)nativeKey.utf16()); +#endif #elif defined(Q_OS_WINCE) // This works for opening a mapping too, but always opens it with read/write access in // attach as it seems. diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h index 4c7e498280..bed0e193db 100644 --- a/src/corelib/kernel/qvariant.h +++ b/src/corelib/kernel/qvariant.h @@ -772,7 +772,7 @@ namespace QtPrivate { QVariantHash l; l.reserve(iter.size()); for (QAssociativeIterable::const_iterator it = iter.begin(), end = iter.end(); it != end; ++it) - l.insert(it.key().toString(), it.value()); + l.insertMulti(it.key().toString(), it.value()); return l; } return QVariantValueHelper<QVariantHash>::invoke(v); @@ -788,7 +788,7 @@ namespace QtPrivate { QAssociativeIterable iter = QVariantValueHelperInterface<QAssociativeIterable>::invoke(v); QVariantMap l; for (QAssociativeIterable::const_iterator it = iter.begin(), end = iter.end(); it != end; ++it) - l.insert(it.key().toString(), it.value()); + l.insertMulti(it.key().toString(), it.value()); return l; } return QVariantValueHelper<QVariantMap>::invoke(v); diff --git a/src/corelib/plugin/qlibrary_win.cpp b/src/corelib/plugin/qlibrary_win.cpp index c1ce198c84..f5604a24bd 100644 --- a/src/corelib/plugin/qlibrary_win.cpp +++ b/src/corelib/plugin/qlibrary_win.cpp @@ -124,7 +124,8 @@ bool QLibraryPrivate::load_sys() SetErrorMode(oldmode); #endif if (!pHnd) { - errorString = QLibrary::tr("Cannot load library %1: %2").arg(fileName).arg(qt_error_string()); + errorString = QLibrary::tr("Cannot load library %1: %2").arg( + QDir::toNativeSeparators(fileName)).arg(qt_error_string()); } else { // Query the actual name of the library that was loaded errorString.clear(); @@ -148,7 +149,8 @@ bool QLibraryPrivate::load_sys() bool QLibraryPrivate::unload_sys() { if (!FreeLibrary(pHnd)) { - errorString = QLibrary::tr("Cannot unload library %1: %2").arg(fileName).arg(qt_error_string()); + errorString = QLibrary::tr("Cannot unload library %1: %2").arg( + QDir::toNativeSeparators(fileName)).arg(qt_error_string()); return false; } errorString.clear(); @@ -164,7 +166,8 @@ QFunctionPointer QLibraryPrivate::resolve_sys(const char* symbol) #endif if (!address) { errorString = QLibrary::tr("Cannot resolve symbol \"%1\" in %2: %3").arg( - QString::fromLatin1(symbol)).arg(fileName).arg(qt_error_string()); + QString::fromLatin1(symbol)).arg( + QDir::toNativeSeparators(fileName)).arg(qt_error_string()); } else { errorString.clear(); } diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index ace6c5d093..6827483464 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -500,7 +500,7 @@ private: template <class X> inline void enableSharedFromThis(const QEnableSharedFromThis<X> *ptr) { - ptr->initializeFromSharedPointer(*this); + ptr->initializeFromSharedPointer(constCast<typename QtPrivate::remove_cv<T>::type>()); } inline void enableSharedFromThis(...) {} diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index b582204d67..2f340477fc 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -1819,6 +1819,17 @@ QString &QString::operator=(const QString &other) Q_DECL_NOTHROW Assigns the Latin-1 string \a str to this string. */ +QString &QString::operator=(QLatin1String other) +{ + if (isDetached() && other.size() <= capacity()) { // assumes d->alloc == 0 → !isDetached() (sharedNull) + d->size = other.size(); + d->data()[other.size()] = 0; + qt_from_latin1(d->data(), other.latin1(), other.size()); + } else { + *this = fromLatin1(other.latin1(), other.size()); + } + return *this; +} /*! \fn QString &QString::operator=(const QByteArray &ba) @@ -1869,7 +1880,16 @@ QString &QString::operator=(const QString &other) Q_DECL_NOTHROW */ QString &QString::operator=(QChar ch) { - return operator=(QString(ch)); + if (isDetached() && capacity() >= 1) { // assumes d->alloc == 0 → !isDetached() (sharedNull) + // re-use existing capacity: + ushort *dat = d->data(); + dat[0] = ch.unicode(); + dat[1] = 0; + d->size = 1; + } else { + operator=(QString(ch)); + } + return *this; } /*! @@ -5667,7 +5687,7 @@ QString QString::rightJustified(int width, QChar fill, bool truncate) const */ namespace QUnicodeTables { -/*! +/* \internal Converts the \a str string starting from the position pointed to by the \a it iterator, using the Unicode case traits \c Traits, and returns the diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h index 4ae81f9269..75f94d7f93 100644 --- a/src/corelib/tools/qstring.h +++ b/src/corelib/tools/qstring.h @@ -221,7 +221,7 @@ public: inline ~QString(); QString &operator=(QChar c); QString &operator=(const QString &) Q_DECL_NOTHROW; - inline QString &operator=(QLatin1String latin1); + QString &operator=(QLatin1String latin1); #ifdef Q_COMPILER_RVALUE_REFS inline QString(QString && other) Q_DECL_NOTHROW : d(other.d) { other.d = Data::sharedNull(); } inline QString &operator=(QString &&other) Q_DECL_NOTHROW @@ -885,11 +885,6 @@ inline void QString::detach() { if (d->ref.isShared() || (d->offset != sizeof(QStringData))) reallocData(uint(d->size) + 1u); } inline bool QString::isDetached() const { return !d->ref.isShared(); } -inline QString &QString::operator=(QLatin1String s) -{ - *this = fromLatin1(s.latin1(), s.size()); - return *this; -} inline void QString::clear() { if (!isNull()) *this = QString(); } inline QString::QString(const QString &other) Q_DECL_NOTHROW : d(other.d) diff --git a/src/corelib/tools/qtimezone.cpp b/src/corelib/tools/qtimezone.cpp index 57c1838b76..333a5c3471 100644 --- a/src/corelib/tools/qtimezone.cpp +++ b/src/corelib/tools/qtimezone.cpp @@ -695,6 +695,11 @@ QTimeZone::OffsetData QTimeZone::offsetData(const QDateTime &forDateTime) const /*! Returns \c true if the system backend supports obtaining transitions. + + Transitions are changes in the time-zone: these happen when DST turns on or + off and when authorities alter the offsets for the time-zone. + + \sa nextTransition(), previousTransition(), transitions() */ bool QTimeZone::hasTransitions() const |