summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/doc/snippets/code/src_corelib_tools_qvector.cpp4
-rw-r--r--src/corelib/global/qcompilerdetection.h5
-rw-r--r--src/corelib/io/qdir.cpp3
-rw-r--r--src/corelib/io/qfilesystemengine_win.cpp2
-rw-r--r--src/corelib/serialization/qjsonarray.cpp1
-rw-r--r--src/corelib/serialization/qjsonobject.cpp1
-rw-r--r--src/corelib/serialization/qjsonvalue.cpp18
-rw-r--r--src/corelib/text/qlocale.cpp25
8 files changed, 47 insertions, 12 deletions
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qvector.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qvector.cpp
index a05233049f..4595dfb2af 100644
--- a/src/corelib/doc/snippets/code/src_corelib_tools_qvector.cpp
+++ b/src/corelib/doc/snippets/code/src_corelib_tools_qvector.cpp
@@ -171,10 +171,10 @@ vector.lastIndexOf("X"); // returns -1
//! [14]
-QVector<double> vect;
+QVector<QString> vect;
vect << "red" << "green" << "blue" << "black";
-QList<double> list = vect.toList();
+QList<QString> list = vect.toList();
// list: ["red", "green", "blue", "black"]
//! [14]
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h
index d759548fbc..64c96023b0 100644
--- a/src/corelib/global/qcompilerdetection.h
+++ b/src/corelib/global/qcompilerdetection.h
@@ -48,6 +48,7 @@
/*
The compiler, must be one of: (Q_CC_x)
+ COVERITY - Coverity cov-scan
SYM - Digital Mars C/C++ (used to be Symantec C++)
MSVC - Microsoft Visual C/C++, Intel C++ for Windows
BOR - Borland/Turbo C++
@@ -74,6 +75,10 @@
Should be sorted most to least authoritative.
*/
+#if defined(__COVERITY__)
+# define Q_CC_COVERITY
+#endif
+
/* Symantec C++ is now Digital Mars */
#if defined(__DMC__) || defined(__SC__)
# define Q_CC_SYM
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp
index 0368eb8c34..7a3e68a19a 100644
--- a/src/corelib/io/qdir.cpp
+++ b/src/corelib/io/qdir.cpp
@@ -1961,7 +1961,8 @@ bool QDir::isEmpty(Filters filters) const
Returns a list of the root directories on this system.
On Windows this returns a list of QFileInfo objects containing "C:/",
- "D:/", etc. On other operating systems, it returns a list containing
+ "D:/", etc. This does not return drives with ejectable media that are empty.
+ On other operating systems, it returns a list containing
just one root directory (i.e. "/").
\sa root(), rootPath()
diff --git a/src/corelib/io/qfilesystemengine_win.cpp b/src/corelib/io/qfilesystemengine_win.cpp
index 81d3a71986..002f720926 100644
--- a/src/corelib/io/qfilesystemengine_win.cpp
+++ b/src/corelib/io/qfilesystemengine_win.cpp
@@ -1449,7 +1449,7 @@ QFileSystemEntry QFileSystemEngine::currentPath()
if (size != 0) {
if (size > PATH_MAX) {
wchar_t *newCurrentName = new wchar_t[size];
- if (::GetCurrentDirectory(PATH_MAX, newCurrentName) != 0)
+ if (::GetCurrentDirectory(size, newCurrentName) != 0)
ret = QString::fromWCharArray(newCurrentName, size);
delete [] newCurrentName;
} else {
diff --git a/src/corelib/serialization/qjsonarray.cpp b/src/corelib/serialization/qjsonarray.cpp
index a6415f2678..61b5f9c40e 100644
--- a/src/corelib/serialization/qjsonarray.cpp
+++ b/src/corelib/serialization/qjsonarray.cpp
@@ -155,7 +155,6 @@ QJsonArray::QJsonArray() = default;
QJsonArray::QJsonArray(QCborContainerPrivate *array)
: a(array)
{
- Q_ASSERT(array);
}
/*!
diff --git a/src/corelib/serialization/qjsonobject.cpp b/src/corelib/serialization/qjsonobject.cpp
index 0856a19630..cb0d1595c7 100644
--- a/src/corelib/serialization/qjsonobject.cpp
+++ b/src/corelib/serialization/qjsonobject.cpp
@@ -137,7 +137,6 @@ QJsonObject::QJsonObject() = default;
QJsonObject::QJsonObject(QCborContainerPrivate *object)
: o(object)
{
- Q_ASSERT(o);
}
/*!
diff --git a/src/corelib/serialization/qjsonvalue.cpp b/src/corelib/serialization/qjsonvalue.cpp
index 29c29184c1..0b11907e68 100644
--- a/src/corelib/serialization/qjsonvalue.cpp
+++ b/src/corelib/serialization/qjsonvalue.cpp
@@ -705,10 +705,13 @@ QString QJsonValue::toString() const
*/
QJsonArray QJsonValue::toArray(const QJsonArray &defaultValue) const
{
- if (t != QCborValue::Array || n >= 0 || !d)
+ if (!isArray())
return defaultValue;
-
- return QJsonArray(d.data());
+ QCborContainerPrivate *dd = nullptr;
+ Q_ASSERT(n == -1 || d == nullptr);
+ if (n < 0)
+ dd = d.data();
+ return QJsonArray(dd);
}
/*!
@@ -730,10 +733,13 @@ QJsonArray QJsonValue::toArray() const
*/
QJsonObject QJsonValue::toObject(const QJsonObject &defaultValue) const
{
- if (t != QCborValue::Map || n >= 0 || !d)
+ if (!isObject())
return defaultValue;
-
- return QJsonObject(d.data());
+ QCborContainerPrivate *dd = nullptr;
+ Q_ASSERT(n == -1 || d == nullptr);
+ if (n < 0)
+ dd = d.data();
+ return QJsonObject(dd);
}
/*!
diff --git a/src/corelib/text/qlocale.cpp b/src/corelib/text/qlocale.cpp
index a859badb3c..6cf0488f83 100644
--- a/src/corelib/text/qlocale.cpp
+++ b/src/corelib/text/qlocale.cpp
@@ -4526,6 +4526,31 @@ QStringList QLocale::uiLanguages() const
}
if (locales.isEmpty())
locales.append(systemLocale()->fallbackUiLocale());
+ // If the system locale (isn't C and) didn't include itself in the list,
+ // or as fallback, presume to know better than it and put its name
+ // first. (Known issue, QTBUG-104930, on some macOS versions when in
+ // locale en_DE.) Our translation system might have a translation for a
+ // locale the platform doesn't believe in.
+ const QString name = bcp47Name();
+ if (!name.isEmpty() && language() != C && !uiLanguages.contains(name)) {
+ // That uses contains(name) as a cheap pre-test, but there may be an
+ // entry that matches this on purging likely subtags.
+ QLocaleId mine =
+ { d->m_data->m_language_id, d->m_data->m_script_id, d->m_data->m_country_id };
+ mine = mine.withLikelySubtagsRemoved();
+ const auto isMine = [mine](const QString &entry) {
+ QLocale::Language lang;
+ QLocale::Script script;
+ QLocale::Country cntry;
+ QLocalePrivate::getLangAndCountry(entry, lang, script, cntry);
+ QLocaleId id = { ushort(lang), ushort(script), ushort(cntry) };
+ return id.withLikelySubtagsRemoved() == mine;
+ };
+ if (std::none_of(uiLanguages.constBegin(), uiLanguages.constEnd(), isMine)) {
+ locales.prepend(*this);
+ uiLanguages.prepend(name);
+ }
+ }
} else
#endif
{