diff options
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/kernel/qcoreapplication.cpp | 26 | ||||
-rw-r--r-- | src/corelib/kernel/qeventdispatcher_cf.mm | 3 | ||||
-rw-r--r-- | src/corelib/mimetypes/qmimeprovider.cpp | 7 | ||||
-rw-r--r-- | src/corelib/plugin/qfactoryloader.cpp | 2 | ||||
-rw-r--r-- | src/corelib/thread/qthread_unix.cpp | 22 | ||||
-rw-r--r-- | src/corelib/tools/qlocale_win.cpp | 48 | ||||
-rw-r--r-- | src/corelib/xml/qxmlstream.cpp | 7 | ||||
-rw-r--r-- | src/corelib/xml/qxmlstream.h | 26 |
8 files changed, 117 insertions, 24 deletions
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp index 53206cfb8c..e64ee04134 100644 --- a/src/corelib/kernel/qcoreapplication.cpp +++ b/src/corelib/kernel/qcoreapplication.cpp @@ -66,8 +66,12 @@ #ifndef QT_NO_QOBJECT #if defined(Q_OS_UNIX) -# if !defined(QT_NO_GLIB) -# include "qeventdispatcher_glib_p.h" +# if defined(Q_OS_OSX) +# include "qeventdispatcher_cf_p.h" +# else +# if !defined(QT_NO_GLIB) +# include "qeventdispatcher_glib_p.h" +# endif # endif # include "qeventdispatcher_unix_p.h" #endif @@ -469,12 +473,21 @@ void QCoreApplicationPrivate::createEventDispatcher() { Q_Q(QCoreApplication); #if defined(Q_OS_UNIX) -# if !defined(QT_NO_GLIB) +# if defined(Q_OS_OSX) + bool ok = false; + int value = qEnvironmentVariableIntValue("QT_EVENT_DISPATCHER_CORE_FOUNDATION", &ok); + if (ok && value > 0) + eventDispatcher = new QEventDispatcherCoreFoundation(q); + else + eventDispatcher = new QEventDispatcherUNIX(q); +# elif !defined(QT_NO_GLIB) if (qEnvironmentVariableIsEmpty("QT_NO_GLIB") && QEventDispatcherGlib::versionSupported()) eventDispatcher = new QEventDispatcherGlib(q); else -# endif eventDispatcher = new QEventDispatcherUNIX(q); +# else + eventDispatcher = new QEventDispatcherUNIX(q); +# endif #elif defined(Q_OS_WINRT) eventDispatcher = new QEventDispatcherWinRT(q); #elif defined(Q_OS_WIN) @@ -613,8 +626,9 @@ void QCoreApplicationPrivate::initLocale() The command line arguments which are passed to QCoreApplication's constructor should be accessed using the arguments() function. - Note that some arguments supplied by the user may have been - processed and removed by QCoreApplication. + + \note QCoreApplication removes option \c -qmljsdebugger="...". It parses the + argument of \c qmljsdebugger, and then removes this option plus its argument. For more advanced command line option handling, create a QCommandLineParser. diff --git a/src/corelib/kernel/qeventdispatcher_cf.mm b/src/corelib/kernel/qeventdispatcher_cf.mm index 240dfed79f..8422345968 100644 --- a/src/corelib/kernel/qeventdispatcher_cf.mm +++ b/src/corelib/kernel/qeventdispatcher_cf.mm @@ -49,6 +49,8 @@ # include <UIKit/UIApplication.h> #endif +QT_USE_NAMESPACE + @interface RunLoopModeTracker : NSObject { QStack<CFStringRef> m_runLoopModes; } @@ -119,7 +121,6 @@ static CFStringRef runLoopMode(NSDictionary *dictionary) @end QT_BEGIN_NAMESPACE -QT_USE_NAMESPACE class RunLoopDebugger : public QObject { diff --git a/src/corelib/mimetypes/qmimeprovider.cpp b/src/corelib/mimetypes/qmimeprovider.cpp index ebaa1b069c..e0fe144c26 100644 --- a/src/corelib/mimetypes/qmimeprovider.cpp +++ b/src/corelib/mimetypes/qmimeprovider.cpp @@ -578,11 +578,8 @@ void QMimeBinaryProvider::loadMimeTypePrivate(QMimeTypePrivate &data) QString mainPattern; const QString preferredLanguage = QLocale::system().name(); - QListIterator<QString> mimeFilesIter(mimeFiles); - mimeFilesIter.toBack(); - while (mimeFilesIter.hasPrevious()) { // global first, then local. - const QString fullPath = mimeFilesIter.previous(); - QFile qfile(fullPath); + for (QStringList::const_reverse_iterator it = mimeFiles.crbegin(), end = mimeFiles.crend(); it != end; ++it) { // global first, then local. + QFile qfile(*it); if (!qfile.open(QFile::ReadOnly)) continue; diff --git a/src/corelib/plugin/qfactoryloader.cpp b/src/corelib/plugin/qfactoryloader.cpp index f7545b5bcb..9924bef8f5 100644 --- a/src/corelib/plugin/qfactoryloader.cpp +++ b/src/corelib/plugin/qfactoryloader.cpp @@ -54,7 +54,9 @@ namespace { // avoid duplicate QStringLiteral data: inline QString iidKeyLiteral() { return QStringLiteral("IID"); } +#ifdef QT_SHARED inline QString versionKeyLiteral() { return QStringLiteral("version"); } +#endif inline QString metaDataKeyLiteral() { return QStringLiteral("MetaData"); } inline QString keysKeyLiteral() { return QStringLiteral("Keys"); } diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp index cc0476461f..9329c515af 100644 --- a/src/corelib/thread/qthread_unix.cpp +++ b/src/corelib/thread/qthread_unix.cpp @@ -36,9 +36,14 @@ #include "qplatformdefs.h" #include <private/qcoreapplication_p.h> +#include <private/qcore_unix_p.h> -#if !defined(QT_NO_GLIB) -# include "../kernel/qeventdispatcher_glib_p.h" +#if defined(Q_OS_OSX) +# include <private/qeventdispatcher_cf_p.h> +#else +# if !defined(QT_NO_GLIB) +# include "../kernel/qeventdispatcher_glib_p.h" +# endif #endif #include <private/qeventdispatcher_unix_p.h> @@ -243,14 +248,23 @@ typedef void*(*QtThreadCallback)(void*); void QThreadPrivate::createEventDispatcher(QThreadData *data) { -#if !defined(QT_NO_GLIB) +#if defined(Q_OS_OSX) + bool ok = false; + int value = qEnvironmentVariableIntValue("QT_EVENT_DISPATCHER_CORE_FOUNDATION", &ok); + if (ok && value > 0) + data->eventDispatcher.storeRelease(new QEventDispatcherCoreFoundation); + else + data->eventDispatcher.storeRelease(new QEventDispatcherUNIX); +#elif !defined(QT_NO_GLIB) if (qEnvironmentVariableIsEmpty("QT_NO_GLIB") && qEnvironmentVariableIsEmpty("QT_NO_THREADED_GLIB") && QEventDispatcherGlib::versionSupported()) data->eventDispatcher.storeRelease(new QEventDispatcherGlib); else -#endif + data->eventDispatcher.storeRelease(new QEventDispatcherUNIX); +#else data->eventDispatcher.storeRelease(new QEventDispatcherUNIX); +#endif data->eventDispatcher.load()->startingUp(); } diff --git a/src/corelib/tools/qlocale_win.cpp b/src/corelib/tools/qlocale_win.cpp index 574453f4ca..a5eb7ec058 100644 --- a/src/corelib/tools/qlocale_win.cpp +++ b/src/corelib/tools/qlocale_win.cpp @@ -48,6 +48,8 @@ #endif #ifdef Q_OS_WINRT +#include <qfunctions_winrt.h> + #include <wrl.h> #include <windows.foundation.h> #include <windows.foundation.collections.h> @@ -644,21 +646,53 @@ QVariant QSystemLocalePrivate::uiLanguages() } ComPtr<ABI::Windows::Foundation::Collections::IVectorView<HSTRING> > languageList; - appLanguagesStatics->get_ManifestLanguages(&languageList); - - if (!languageList) - return QStringList(); - + // Languages is a ranked list of "long names" (e.g. en-US) of preferred languages, which matches + // languages from the manifest with languages from the user's system. + HRESULT hr = appLanguagesStatics->get_Languages(&languageList); + Q_ASSERT_SUCCEEDED(hr); unsigned int size; - languageList->get_Size(&size); + hr = languageList->get_Size(&size); + Q_ASSERT_SUCCEEDED(hr); + result.reserve(size); for (unsigned int i = 0; i < size; ++i) { HString language; - languageList->GetAt(i, language.GetAddressOf()); + hr = languageList->GetAt(i, language.GetAddressOf()); + Q_ASSERT_SUCCEEDED(hr); UINT32 length; PCWSTR rawString = language.GetRawBuffer(&length); result << QString::fromWCharArray(rawString, length); } + // ManifestLanguages covers all languages given in the manifest and uses short names (like "en"). + hr = appLanguagesStatics->get_ManifestLanguages(&languageList); + Q_ASSERT_SUCCEEDED(hr); + hr = languageList->get_Size(&size); + Q_ASSERT_SUCCEEDED(hr); + for (unsigned int i = 0; i < size; ++i) { + HString language; + hr = languageList->GetAt(i, language.GetAddressOf()); + Q_ASSERT_SUCCEEDED(hr); + UINT32 length; + PCWSTR rawString = language.GetRawBuffer(&length); + const QString qLanguage = QString::fromWCharArray(rawString, length); + bool found = false; + // Since ApplicationLanguages:::Languages uses long names, we compare the "pre-dash" part of + // the language and filter it out, if it is already covered by a more specialized form. + foreach (const QString &lang, result) { + int dashIndex = lang.indexOf('-'); + // There will not be any long name after the first short name was found, so we can stop. + if (dashIndex == -1) + break; + + if (lang.leftRef(dashIndex) == qLanguage) { + found = true; + break; + } + } + if (!found) + result << qLanguage; + } + return result; #endif // Q_OS_WINRT } diff --git a/src/corelib/xml/qxmlstream.cpp b/src/corelib/xml/qxmlstream.cpp index 69e2e5d5c1..64a130e45a 100644 --- a/src/corelib/xml/qxmlstream.cpp +++ b/src/corelib/xml/qxmlstream.cpp @@ -2622,6 +2622,13 @@ QXmlStreamEntityDeclaration::~QXmlStreamEntityDeclaration() { } +/*! \fn QXmlStreamStringRef::swap(QXmlStreamStringRef &other) + \since 5.6 + + Swaps this string reference's contents with \a other. + This function is very fast and never fails. +*/ + /*! \fn QStringRef QXmlStreamEntityDeclaration::name() const Returns the entity name. diff --git a/src/corelib/xml/qxmlstream.h b/src/corelib/xml/qxmlstream.h index 7b1ea624c5..34f26cb953 100644 --- a/src/corelib/xml/qxmlstream.h +++ b/src/corelib/xml/qxmlstream.h @@ -53,13 +53,37 @@ public: inline QXmlStreamStringRef(const QStringRef &aString) :m_string(aString.string()?*aString.string():QString()), m_position(aString.position()), m_size(aString.size()){} inline QXmlStreamStringRef(const QString &aString):m_string(aString), m_position(0), m_size(aString.size()){} - inline ~QXmlStreamStringRef(){} + +#if QT_VERSION < QT_VERSION_CHECK(6,0,0) + QXmlStreamStringRef(const QXmlStreamStringRef &other) // = default + : m_string(other.m_string), m_position(other.m_position), m_size(other.m_size) {} +#ifdef Q_COMPILER_RVALUE_REFS + QXmlStreamStringRef(QXmlStreamStringRef &&other) Q_DECL_NOTHROW // = default + : m_string(std::move(other.m_string)), m_position(other.m_position), m_size(other.m_size) {} + QXmlStreamStringRef &operator=(QXmlStreamStringRef &&other) Q_DECL_NOTHROW // = default + { swap(other); return *this; } +#endif + QXmlStreamStringRef &operator=(const QXmlStreamStringRef &other) // = default + { m_string = other.m_string; m_position = other.m_position; m_size = other.m_size; return *this; } + inline ~QXmlStreamStringRef() {} // ### this prevents (or deprecates) all the move/copy special member functions, + // ### that's why we need to provide them by hand above. We can't remove it in + // ### Qt 5, since that would change the way its passed to functions. In Qt 6, remove all. +#endif // Qt < 6.0 + + void swap(QXmlStreamStringRef &other) Q_DECL_NOTHROW + { + qSwap(m_string, other.m_string); + qSwap(m_position, other.m_position); + qSwap(m_size, other.m_size); + } + inline void clear() { m_string.clear(); m_position = m_size = 0; } inline operator QStringRef() const { return QStringRef(&m_string, m_position, m_size); } inline const QString *string() const { return &m_string; } inline int position() const { return m_position; } inline int size() const { return m_size; } }; +Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6(QXmlStreamStringRef) class QXmlStreamReaderPrivate; |