From dacc222d5a3327fb27d69e57d99111cdf9084304 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Nowacki?= Date: Tue, 12 Feb 2013 14:08:48 +0100 Subject: Fix QVector detaching in one thread while another destroys it. The patch adds handling for a case when a QVector is shared between two threads. In such scenario detaching in one thread could collide with destruction in the other one, causing a memory leak or assert in debug mode. Task-number: QTBUG-29134 Change-Id: Idbff250d9cfc6cf83174954ea91dbf41f8ea4aa4 Reviewed-by: Olivier Goffart Reviewed-by: Thiago Macieira --- src/corelib/tools/qvector.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'src/corelib/tools') diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h index 191be6292c..94f3008274 100644 --- a/src/corelib/tools/qvector.h +++ b/src/corelib/tools/qvector.h @@ -506,8 +506,7 @@ void QVector::reallocData(const int asize, const int aalloc, QArrayData::Allo } if (d != x) { if (!d->ref.deref()) { - Q_ASSERT(!isShared); - if (QTypeInfo::isStatic || !aalloc) { + if (QTypeInfo::isStatic || !aalloc || (isShared && QTypeInfo::isComplex)) { // data was copy constructed, we need to call destructors // or if !alloc we did nothing to the old 'd'. freeData(d); -- cgit v1.2.3 From 1b08e0307dfebe561fbb0819a2d6b53edd8e8e93 Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Wed, 20 Feb 2013 17:53:39 -0800 Subject: Don't assume that all CFPropertyListRef are CFArrayRefs MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit We might need more robust code in the future. But at least for this case it looks like a CFStringRef is also a possibility. Task-number: QTBUG-29776 Change-Id: Iaf50835122fcbb7e6e9c7fbf65e31e6143b2bc54 Reviewed-by: Morten Johan Sørvig Reviewed-by: Denis Dzyubenko --- src/corelib/tools/qlocale_mac.mm | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) (limited to 'src/corelib/tools') diff --git a/src/corelib/tools/qlocale_mac.mm b/src/corelib/tools/qlocale_mac.mm index 0dc6f389b3..0c35860b56 100644 --- a/src/corelib/tools/qlocale_mac.mm +++ b/src/corelib/tools/qlocale_mac.mm @@ -434,18 +434,26 @@ QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const case CurrencyToString: return macFormatCurrency(in.value()); case UILanguages: { - QCFType languages = (CFArrayRef)CFPreferencesCopyValue( + QCFType languages = (CFArrayRef)CFPreferencesCopyValue( CFSTR("AppleLanguages"), kCFPreferencesAnyApplication, kCFPreferencesCurrentUser, kCFPreferencesAnyHost); - const int cnt = languages == NULL ? 0 : CFArrayGetCount(languages); QStringList result; - result.reserve(cnt); - for (int i = 0; i < cnt; ++i) { - const QString lang = QCFString::toQString( - static_cast(CFArrayGetValueAtIndex(languages, i))); - result.append(lang); + CFTypeID typeId = CFGetTypeID(languages); + if (typeId == CFArrayGetTypeID()) { + const int cnt = CFArrayGetCount(languages.as()); + result.reserve(cnt); + for (int i = 0; i < cnt; ++i) { + const QString lang = QCFString::toQString( + static_cast(CFArrayGetValueAtIndex(languages.as(), i))); + result.append(lang); + } + } else if (typeId == CFStringGetTypeID()) { + result = QStringList(QCFString::toQString(languages.as())); + } else { + qWarning("QLocale::uiLanguages(): CFPreferencesCopyValue returned unhandled type \"%s\"; please report to http://bugreports.qt-project.org", + qPrintable(QCFString::toQString(CFCopyTypeIDDescription(typeId)))); } return QVariant(result); } -- cgit v1.2.3 From 6d270051a23fbfe1cb148ced365ea3a6aecf5e60 Mon Sep 17 00:00:00 2001 From: Debao Zhang Date: Mon, 25 Feb 2013 13:26:07 +0800 Subject: Doc: Add the missing \since 5.0 Change-Id: I79f67e18b64efe7d22ed80adbc6f024ef35b3aac Reviewed-by: Thiago Macieira Reviewed-by: Friedemann Kleint --- src/corelib/tools/qstring.cpp | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/corelib/tools') diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index 61d5073a1f..c9525cf0ae 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -9169,6 +9169,8 @@ QVector QStringRef::toUcs4() const */ /*! + \since 5.0 + Converts a plain text string to an HTML string with HTML metacharacters \c{<}, \c{>}, \c{&}, and \c{"} replaced by HTML entities. -- cgit v1.2.3 From f3f60743551936e3d06f7f5c8bb2c76eab6d536c Mon Sep 17 00:00:00 2001 From: Friedemann Kleint Date: Wed, 20 Feb 2013 11:58:35 +0100 Subject: Document MSVC-restrictions regarding QStringLiteral. Task-number: QTBUG-28885 Change-Id: I02eed2b27970ec31479a6c80fbe4c336431e13de Reviewed-by: Thiago Macieira Reviewed-by: Olivier Goffart --- src/corelib/tools/qstring.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) (limited to 'src/corelib/tools') diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index c9525cf0ae..404e3be289 100644 --- a/src/corelib/tools/qstring.cpp +++ b/src/corelib/tools/qstring.cpp @@ -9239,6 +9239,19 @@ QString QString::toHtmlEscaped() const \code if (attribute.name() == QLatin1String("http-contents-length")) //... \endcode + + \note There some restrictions when using the MSVC 2010 or 2012 compilers. The example snippets provided here + fail to compile with them. + \list + \li Concatenated string literals cannot be used with QStringLiteral. + \code + QString s = QStringLiteral("a" "b"); + \endcode + \li QStringLiteral cannot be used to initialize lists or arrays of QString. + \code + QString a[] = { QStringLiteral("a"), QStringLiteral("b") }; + \endcode + \endlist */ QT_END_NAMESPACE -- cgit v1.2.3