From db81129240d1198884b4197857ec5934a5dc33d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Mon, 20 Jan 2020 15:07:34 +0100 Subject: macOS: Remove doc references to the Carbon framework Change-Id: I4d496acfc3d810d6334baba99cd697168bef0b75 Reviewed-by: Timur Pocheptsov --- src/corelib/global/qnamespace.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index bebe67be3f..1908fedead 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -1017,7 +1017,7 @@ \value WA_MacNoClickThrough This value is obsolete and has no effect. - \value WA_MacOpaqueSizeGrip Indicates that the native Carbon size grip + \value WA_MacOpaqueSizeGrip Indicates that the native size grip should be opaque instead of transparent (the default). This attribute is only applicable to \macos and is set by the widget's author. -- cgit v1.2.3 From d0e9e5a36e3e49ec9fb0fb3f1639c21e7414c615 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tor=20Arne=20Vestb=C3=B8?= Date: Tue, 21 Jan 2020 14:13:03 +0100 Subject: macOS: Work around CoreFoundation failing to resolve bundle resources When a framework is loaded from a Samba share CoreFoundation will fail to resolve its Resources directory, and hence its Info.plist, which means we can't look up the bundle by id. Until this has been fixed in CoreFoundation and/or the macOS Samba implementation we work around it by manually looking for QtCore. This fixes our particular use-case of finding QtCore so we can resolve the relocatable prefix, but there's still a potential issue if any other code tries to use CF for bundle lookups. We don't seem to have any of those in Qt itself, but this should be kept in mind if we see similar issues in the future. Change-Id: I8fd471e44f6afe33a7459ce550f0fcec9acfefb4 Reviewed-by: Alexandru Croitor --- src/corelib/global/qlibraryinfo.cpp | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp index f0f77fe68e..7d6beaf9c2 100644 --- a/src/corelib/global/qlibraryinfo.cpp +++ b/src/corelib/global/qlibraryinfo.cpp @@ -535,8 +535,25 @@ static QString getRelocatablePrefix() #if defined(QT_STATIC) prefixPath = prefixFromAppDirHelper(); #elif defined(Q_OS_DARWIN) && QT_CONFIG(framework) - CFBundleRef qtCoreBundle = CFBundleGetBundleWithIdentifier( - CFSTR("org.qt-project.QtCore")); + auto qtCoreBundle = CFBundleGetBundleWithIdentifier(CFSTR("org.qt-project.QtCore")); + if (!qtCoreBundle) { + // When running Qt apps over Samba shares, CoreFoundation will fail to find + // the Resources directory inside the bundle, This directory is a symlink, + // and CF relies on readdir() and dtent.dt_type to detect symlinks, which + // does not work reliably for Samba shares. We work around it by manually + // looking for the QtCore bundle. + auto allBundles = CFBundleGetAllBundles(); + auto bundleCount = CFArrayGetCount(allBundles); + for (int i = 0; i < bundleCount; ++i) { + auto bundle = CFBundleRef(CFArrayGetValueAtIndex(allBundles, i)); + auto url = QCFType(CFBundleCopyBundleURL(bundle)); + auto path = QCFType(CFURLCopyFileSystemPath(url, kCFURLPOSIXPathStyle)); + if (CFStringHasSuffix(path, CFSTR("/QtCore.framework"))) { + qtCoreBundle = bundle; + break; + } + } + } Q_ASSERT(qtCoreBundle); QCFType qtCorePath = CFBundleCopyBundleURL(qtCoreBundle); -- cgit v1.2.3 From 0b28f1e3bae10def59e7fe8afac29ed5355a3f1e Mon Sep 17 00:00:00 2001 From: Andy Shaw Date: Tue, 21 Jan 2020 15:01:55 +0100 Subject: Fix QLocale::system() and uiLanguages() for the mobile platforms On iOS, it was no longer using the Cocoa specific code needed to get the locale and uiLanguages information so this functionality is brought back as it was accidently lost. In addition, this has a side-effect of fixing a problem with Android versions below API 24 where it has no UiLanguages functionality so it gets the information based on the system locale as a fallback. Fixes: QTBUG-81307 Fixes: QTBUG-81357 Change-Id: I1709675b5bd5e9cedefb99eaec28279f20a347a4 Reviewed-by: Edward Welbourne --- src/corelib/text/qlocale.cpp | 2 ++ src/corelib/text/text.pri | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) (limited to 'src/corelib') diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp index e3530eeee1..d8c4b41624 100644 --- a/src/corelib/text/qlocale.cpp +++ b/src/corelib/text/qlocale.cpp @@ -4463,6 +4463,8 @@ QStringList QLocale::uiLanguages() const for (const auto entry : qAsConst(uiLanguages)) locales.append(QLocale(entry)); } + if (locales.isEmpty()) + locales.append(systemLocale()->fallbackUiLocale()); } else #endif { diff --git a/src/corelib/text/text.pri b/src/corelib/text/text.pri index 25e281f37a..d2a02059c7 100644 --- a/src/corelib/text/text.pri +++ b/src/corelib/text/text.pri @@ -48,7 +48,7 @@ SOURCES += \ NO_PCH_SOURCES += text/qstring_compat.cpp false: SOURCES += $$NO_PCH_SOURCES # Hack for QtCreator -!nacl:macos: { +!nacl:darwin: { SOURCES += text/qlocale_mac.mm } else:unix { -- cgit v1.2.3 From 4d8a515a230ca9864a94830fd376a1d3ecbe6886 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Wed, 15 Jan 2020 20:53:21 +0100 Subject: QXmlStreamReader: early return in case of malformed attributes There's no point at keep raising errors after encountering the first malformed attribute. Change-Id: Idb37e577ea96c3bd850b3caf008fe3ecd57dd32e Reviewed-by: Thiago Macieira --- src/corelib/serialization/qxmlstream.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/serialization/qxmlstream.cpp b/src/corelib/serialization/qxmlstream.cpp index 500e0aa6be..dfa36ea642 100644 --- a/src/corelib/serialization/qxmlstream.cpp +++ b/src/corelib/serialization/qxmlstream.cpp @@ -50,6 +50,7 @@ #endif #include #include +#include #ifndef QT_BOOTSTRAPPED #include #else @@ -1582,6 +1583,7 @@ QStringRef QXmlStreamReaderPrivate::namespaceForPrefix(const QStringRef &prefix) */ void QXmlStreamReaderPrivate::resolveTag() { + const auto attributeStackCleaner = qScopeGuard([this](){ attributeStack.clear(); }); int n = attributeStack.size(); if (namespaceProcessing) { @@ -1649,7 +1651,10 @@ void QXmlStreamReaderPrivate::resolveTag() if (attributes[j].name() == attribute.name() && attributes[j].namespaceUri() == attribute.namespaceUri() && (namespaceProcessing || attributes[j].qualifiedName() == attribute.qualifiedName())) + { raiseWellFormedError(QXmlStream::tr("Attribute '%1' redefined.").arg(attribute.qualifiedName())); + return; + } } } @@ -1680,8 +1685,6 @@ void QXmlStreamReaderPrivate::resolveTag() attribute.m_isDefault = true; attributes.append(attribute); } - - attributeStack.clear(); } void QXmlStreamReaderPrivate::resolvePublicNamespaces() -- cgit v1.2.3 From e83c4e813840b8632ec44f00ee3daf2ba1b18133 Mon Sep 17 00:00:00 2001 From: Giuseppe D'Angelo Date: Tue, 21 Jan 2020 14:43:01 +0100 Subject: QXmlStreamReader: fix memory leak On some inputs a QXmlStreamReaderPrivate may allocate another QXmlStreamReaderPrivate as its entityResolver. Which, recursively, may allocate yet another one. This "chain" of QXmlStreamReaderPrivate objects was managed using raw pointers, and a leak was possible by resetting one of these pointers to nullptr without freeing the corresponding object. Change-Id: I2c6e1f023a2ed68b2b1857db25c53cce7f6bd3e7 Reviewed-by: Sona Kurazyan --- src/corelib/serialization/qxmlstream.cpp | 7 ++++--- src/corelib/serialization/qxmlstream_p.h | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/serialization/qxmlstream.cpp b/src/corelib/serialization/qxmlstream.cpp index dfa36ea642..7ff87885a5 100644 --- a/src/corelib/serialization/qxmlstream.cpp +++ b/src/corelib/serialization/qxmlstream.cpp @@ -69,6 +69,8 @@ public: \ { return QString::fromLatin1(sourceText); } \ private: #endif +#include + QT_BEGIN_NAMESPACE #include "qxmlstream_p.h" @@ -848,7 +850,7 @@ void QXmlStreamReaderPrivate::init() #endif attributeStack.clear(); attributeStack.reserve(16); - entityParser = nullptr; + entityParser.reset(); hasCheckedStartDocument = false; normalizeLiterals = false; hasSeenTag = false; @@ -881,7 +883,7 @@ void QXmlStreamReaderPrivate::parseEntity(const QString &value) if (!entityParser) - entityParser = new QXmlStreamReaderPrivate(q); + entityParser = qt_make_unique(q); else entityParser->init(); entityParser->inParseEntity = true; @@ -911,7 +913,6 @@ QXmlStreamReaderPrivate::~QXmlStreamReaderPrivate() #endif free(sym_stack); free(state_stack); - delete entityParser; } diff --git a/src/corelib/serialization/qxmlstream_p.h b/src/corelib/serialization/qxmlstream_p.h index cde66a48a3..9c94e6d434 100644 --- a/src/corelib/serialization/qxmlstream_p.h +++ b/src/corelib/serialization/qxmlstream_p.h @@ -981,7 +981,7 @@ public: QString resolveUndeclaredEntity(const QString &name); void parseEntity(const QString &value); - QXmlStreamReaderPrivate *entityParser; + std::unique_ptr entityParser; bool scanAfterLangleBang(); bool scanPublicOrSystem(); -- cgit v1.2.3 From ca85e1246eacfe7ba570882a674e313be3b808f8 Mon Sep 17 00:00:00 2001 From: Edward Welbourne Date: Mon, 20 Jan 2020 13:44:30 +0100 Subject: updateSystemPrivate(): fix handling of empty string as non-null QVariant QSystemLocale::query() can return an empty string for PositiveSign on Windows, apparently. In any case, we shouldn't be taking .at(0) of a QString without checking it's non-empty. Fixes: QTBUG-81530 Change-Id: I4d496a2650362f225d02998bd7b8be9fd783edb4 Reviewed-by: Friedemann Kleint --- src/corelib/text/qlocale.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'src/corelib') diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp index d8c4b41624..26db674a99 100644 --- a/src/corelib/text/qlocale.cpp +++ b/src/corelib/text/qlocale.cpp @@ -734,23 +734,23 @@ static void updateSystemPrivate() globalLocaleData.m_script_id = res.toInt(); res = sys_locale->query(QSystemLocale::DecimalPoint, QVariant()); - if (!res.isNull()) + if (!res.isNull() && !res.toString().isEmpty()) globalLocaleData.m_decimal = res.toString().at(0).unicode(); res = sys_locale->query(QSystemLocale::GroupSeparator, QVariant()); - if (!res.isNull()) + if (!res.isNull() && !res.toString().isEmpty()) globalLocaleData.m_group = res.toString().at(0).unicode(); res = sys_locale->query(QSystemLocale::ZeroDigit, QVariant()); - if (!res.isNull()) + if (!res.isNull() && !res.toString().isEmpty()) globalLocaleData.m_zero = res.toString().at(0).unicode(); res = sys_locale->query(QSystemLocale::NegativeSign, QVariant()); - if (!res.isNull()) + if (!res.isNull() && !res.toString().isEmpty()) globalLocaleData.m_minus = res.toString().at(0).unicode(); res = sys_locale->query(QSystemLocale::PositiveSign, QVariant()); - if (!res.isNull()) + if (!res.isNull() && !res.toString().isEmpty()) globalLocaleData.m_plus = res.toString().at(0).unicode(); } #endif // !QT_NO_SYSTEMLOCALE -- cgit v1.2.3