summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2013-11-20 12:18:23 +0100
committerThe Qt Project <gerrit-noreply@qt-project.org>2013-11-20 12:18:23 +0100
commitc83c08d84fe00a4033d7ba61fd95c150f643736d (patch)
tree088927e1b2e9d67300253c29ba73be6be6d8ae31 /src/corelib
parent1e446fc99167a992b1a8342168b6254f43b097fe (diff)
parent72ea7900858a31c1c6b93e6fed9f2f4dc30291e4 (diff)
Merge "Merge remote-tracking branch 'origin/release' into stable" into refs/staging/stable
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/global/qcompilerdetection.h7
-rw-r--r--src/corelib/io/qfileselector.cpp30
-rw-r--r--src/corelib/io/qfileselector.h2
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp2
-rw-r--r--src/corelib/plugin/quuid.h4
-rw-r--r--src/corelib/tools/qcollator.cpp42
-rw-r--r--src/corelib/tools/qcollator.h24
-rw-r--r--src/corelib/tools/qcollator_icu.cpp5
-rw-r--r--src/corelib/tools/qcollator_macx.cpp5
-rw-r--r--src/corelib/tools/qcollator_posix.cpp5
-rw-r--r--src/corelib/tools/qcollator_win.cpp5
-rw-r--r--src/corelib/tools/qmap.cpp6
-rw-r--r--src/corelib/tools/qtimezone.cpp9
-rw-r--r--src/corelib/tools/qtimezone.h10
14 files changed, 104 insertions, 52 deletions
diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h
index d02e4cf199..f23478d75c 100644
--- a/src/corelib/global/qcompilerdetection.h
+++ b/src/corelib/global/qcompilerdetection.h
@@ -465,6 +465,7 @@
* N2659 Q_COMPILER_THREAD_LOCAL
* N2765 Q_COMPILER_UDL
* N2442 Q_COMPILER_UNICODE_STRINGS
+ * N2640 Q_COMPILER_UNIFORM_INIT
* N2544 Q_COMPILER_UNRESTRICTED_UNIONS
* N1653 Q_COMPILER_VARIADIC_MACROS
* N2242 N2555 Q_COMPILER_VARIADIC_TEMPLATES
@@ -502,6 +503,7 @@
// constexpr support is only partial
//# define Q_COMPILER_CONSTEXPR
# define Q_COMPILER_INITIALIZER_LISTS
+# define Q_COMPILER_UNIFORM_INIT
# define Q_COMPILER_NOEXCEPT
# endif
# if __INTEL_COMPILER >= 1400
@@ -573,6 +575,7 @@
# endif
# if __has_feature(cxx_generalized_initializers)
# define Q_COMPILER_INITIALIZER_LISTS
+# define Q_COMPILER_UNIFORM_INIT /* both covered by this feature macro, according to docs */
# endif
# if __has_feature(cxx_lambdas)
# define Q_COMPILER_LAMBDA
@@ -645,6 +648,7 @@
# define Q_COMPILER_DELETE_MEMBERS
# define Q_COMPILER_EXTERN_TEMPLATES
# define Q_COMPILER_INITIALIZER_LISTS
+# define Q_COMPILER_UNIFORM_INIT
# define Q_COMPILER_UNICODE_STRINGS
# define Q_COMPILER_VARIADIC_TEMPLATES
# endif
@@ -718,8 +722,9 @@
# define Q_COMPILER_DECLTYPE
# define Q_COMPILER_RVALUE_REFS
# define Q_COMPILER_STATIC_ASSERT
-// MSVC has std::initilizer_list, but does not support the braces initialization
+// MSVC's library has std::initilizer_list, but the compiler does not support the braces initialization
//# define Q_COMPILER_INITIALIZER_LISTS
+//# define Q_COMPILER_UNIFORM_INIT
# endif
# if _MSC_VER >= 1700
/* C++11 features supported in VC11 = VC2012: */
diff --git a/src/corelib/io/qfileselector.cpp b/src/corelib/io/qfileselector.cpp
index d67ea80e51..eed9e8870a 100644
--- a/src/corelib/io/qfileselector.cpp
+++ b/src/corelib/io/qfileselector.cpp
@@ -348,22 +348,28 @@ void QFileSelectorPrivate::updateSelectors()
QStringList QFileSelectorPrivate::platformSelectors()
{
QStringList ret;
-#if defined(Q_OS_LINUX_ANDROID)
+#if defined(Q_OS_WIN)
+ ret << QStringLiteral("windows");
+# if defined(Q_OS_WINCE)
+ ret << QStringLiteral("wince");
+# endif
+#elif defined(Q_OS_UNIX)
+ ret << QStringLiteral("unix");
+# if defined(Q_OS_LINUX_ANDROID)
ret << QStringLiteral("android");
-#elif defined(Q_OS_BLACKBERRY)
+# elif defined(Q_OS_BLACKBERRY)
ret << QStringLiteral("blackberry");
-#elif defined(Q_OS_IOS)
+# elif defined(Q_OS_IOS)
ret << QStringLiteral("ios");
-#elif defined(Q_OS_WINCE)
- ret << QStringLiteral("wince");
-#elif defined(Q_OS_WIN)
- ret << QStringLiteral("windows");
-#elif defined(Q_OS_LINUX)
+# elif defined(Q_OS_LINUX)
ret << QStringLiteral("linux");
-#elif defined(Q_OS_OSX)
- ret << QStringLiteral("osx");
-#elif defined(Q_OS_UNIX)
- ret << QStringLiteral("generic_unix");
+# elif defined(Q_OS_MAC)
+ ret << QStringLiteral("mac");
+# else
+ struct utsname u;
+ if (uname(&u) != -1)
+ ret << QString::fromLatin1(u.sysname).toLower();
+# endif
#endif
return ret;
}
diff --git a/src/corelib/io/qfileselector.h b/src/corelib/io/qfileselector.h
index 9afd985757..cb5f71faae 100644
--- a/src/corelib/io/qfileselector.h
+++ b/src/corelib/io/qfileselector.h
@@ -52,7 +52,7 @@ class Q_CORE_EXPORT QFileSelector : public QObject
{
Q_OBJECT
public:
- QFileSelector(QObject *parent = 0);
+ explicit QFileSelector(QObject *parent = 0);
~QFileSelector();
QString select(const QString &filePath) const;
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index 1ae4da12e8..43c64b7b2c 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -1027,7 +1027,7 @@ bool QCoreApplication::closingDown()
You can call this function occasionally when your program is busy
performing a long operation (e.g. copying a file).
- In event you are running a local loop which calls this function
+ In the event that you are running a local loop which calls this function
continuously, without an event loop, the
\l{QEvent::DeferredDelete}{DeferredDelete} events will
not be processed. This can affect the behaviour of widgets,
diff --git a/src/corelib/plugin/quuid.h b/src/corelib/plugin/quuid.h
index 31b9890351..a0d2923bed 100644
--- a/src/corelib/plugin/quuid.h
+++ b/src/corelib/plugin/quuid.h
@@ -82,7 +82,7 @@ public:
Sha1 = 5 // 0 1 0 1
};
-#if defined(Q_COMPILER_INITIALIZER_LISTS) && !defined(Q_QDOC)
+#if defined(Q_COMPILER_UNIFORM_INIT) && !defined(Q_QDOC)
Q_DECL_CONSTEXPR QUuid() : data1(0), data2(0), data3(0), data4{0,0,0,0,0,0,0,0} {}
Q_DECL_CONSTEXPR QUuid(uint l, ushort w1, ushort w2, uchar b1, uchar b2, uchar b3,
@@ -147,7 +147,7 @@ public:
#if defined(Q_OS_WIN)
// On Windows we have a type GUID that is used by the platform API, so we
// provide convenience operators to cast from and to this type.
-#if defined(Q_COMPILER_INITIALIZER_LISTS) && !defined(Q_QDOC)
+#if defined(Q_COMPILER_UNIFORM_INIT) && !defined(Q_QDOC)
Q_DECL_CONSTEXPR QUuid(const GUID &guid)
: data1(guid.Data1), data2(guid.Data2), data3(guid.Data3),
data4{guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3],
diff --git a/src/corelib/tools/qcollator.cpp b/src/corelib/tools/qcollator.cpp
index a3a9ef940b..9c97d6b158 100644
--- a/src/corelib/tools/qcollator.cpp
+++ b/src/corelib/tools/qcollator.cpp
@@ -99,7 +99,7 @@ QCollator::QCollator(const QCollator &other)
*/
QCollator::~QCollator()
{
- if (!d->ref.deref())
+ if (d && !d->ref.deref())
delete d;
}
@@ -109,14 +109,41 @@ QCollator::~QCollator()
QCollator &QCollator::operator=(const QCollator &other)
{
if (this != &other) {
- if (!d->ref.deref())
+ if (d && !d->ref.deref())
delete d;
d = other.d;
- d->ref.ref();
+ if (d) d->ref.ref();
}
return *this;
}
+/*
+ \fn void QCollator::QCollator(QCollator &&other)
+
+ Move constructor. Moves from \a other into this collator.
+
+ Note that a moved-from QCollator can only be destroyed or assigned
+ to. The effect of calling other functions than the destructor or
+ one of the assignment operators is undefined.
+*/
+
+/*
+ \fn QCollator &QCollator::operator=(QCollator &&other)
+
+ Move-assigns from \a other to this collator.
+
+ Note that a moved-from QCollator can only be destroyed or assigned
+ to. The effect of calling other functions than the destructor or
+ one of the assignment operators is undefined.
+*/
+
+/*!
+ \fn void QCollator::swap(QCollator &other)
+
+ Swaps this collator with \a other. This function is very fast and
+ never fails.
+*/
+
/*!
\internal
*/
@@ -301,12 +328,13 @@ QCollatorSortKey& QCollatorSortKey::operator=(const QCollatorSortKey &other)
}
/*!
- \fn bool QCollatorSortKey::operator<(const QCollatorSortKey &otherKey) const
+ \fn bool operator<(const QCollatorSortKey &lhs, const QCollatorSortKey &rhs)
+ \relates QCollatorSortKey
- According to the QCollator that created the key, returns \c true if the
- key should be sorted before than \a otherKey; otherwise returns \c false.
+ According to the QCollator that created the keys, returns \c true if \a lhs
+ should be sorted before \a rhs; otherwise returns \c false.
- \sa compare()
+ \sa QCollatorSortKey::compare()
*/
/*!
diff --git a/src/corelib/tools/qcollator.h b/src/corelib/tools/qcollator.h
index b99fd1c0cc..781e95b10c 100644
--- a/src/corelib/tools/qcollator.h
+++ b/src/corelib/tools/qcollator.h
@@ -61,10 +61,11 @@ public:
QCollatorSortKey &operator=(const QCollatorSortKey &other);
#ifdef Q_COMPILER_RVALUE_REFS
inline QCollatorSortKey &operator=(QCollatorSortKey &&other)
- { qSwap(d, other.d); return *this; }
+ { swap(other); return *this; }
#endif
+ void swap(QCollatorSortKey &other)
+ { d.swap(other.d); }
- bool operator<(const QCollatorSortKey &key) const;
int compare(const QCollatorSortKey &key) const;
protected:
@@ -76,13 +77,27 @@ private:
QCollatorSortKey();
};
+inline bool operator<(const QCollatorSortKey &lhs, const QCollatorSortKey &rhs)
+{
+ return lhs.compare(rhs) < 0;
+}
+
class Q_CORE_EXPORT QCollator
{
public:
- QCollator(const QLocale &locale = QLocale());
+ explicit QCollator(const QLocale &locale = QLocale());
QCollator(const QCollator &);
~QCollator();
QCollator &operator=(const QCollator &);
+#ifdef Q_COMPILER_RVALUE_REFS
+ QCollator(QCollator &&other)
+ : d(other.d) { other.d = 0; }
+ QCollator &operator=(QCollator &&other)
+ { swap(other); return *this; }
+#endif
+
+ void swap(QCollator &other)
+ { qSwap(d, other.d); }
void setLocale(const QLocale &locale);
QLocale locale() const;
@@ -111,6 +126,9 @@ private:
void detach();
};
+Q_DECLARE_SHARED(QCollatorSortKey)
+Q_DECLARE_SHARED(QCollator)
+
QT_END_NAMESPACE
#endif // QCOLLATOR_P_H
diff --git a/src/corelib/tools/qcollator_icu.cpp b/src/corelib/tools/qcollator_icu.cpp
index 46f830a34c..407a493d25 100644
--- a/src/corelib/tools/qcollator_icu.cpp
+++ b/src/corelib/tools/qcollator_icu.cpp
@@ -151,11 +151,6 @@ QCollatorSortKey QCollator::sortKey(const QString &string) const
return QCollatorSortKey(new QCollatorSortKeyPrivate(result));
}
-bool QCollatorSortKey::operator<(const QCollatorSortKey &otherKey) const
-{
- return d->m_key < otherKey.d->m_key;
-}
-
int QCollatorSortKey::compare(const QCollatorSortKey &otherKey) const
{
return qstrcmp(d->m_key, otherKey.d->m_key);
diff --git a/src/corelib/tools/qcollator_macx.cpp b/src/corelib/tools/qcollator_macx.cpp
index 8edd190fbe..8985cd4eba 100644
--- a/src/corelib/tools/qcollator_macx.cpp
+++ b/src/corelib/tools/qcollator_macx.cpp
@@ -162,11 +162,6 @@ QCollatorSortKey QCollator::sortKey(const QString &string) const
return QCollatorSortKey(new QCollatorSortKeyPrivate(ret));
}
-bool QCollatorSortKey::operator<(const QCollatorSortKey &key) const
-{
- return compare(key) < 0;
-}
-
int QCollatorSortKey::compare(const QCollatorSortKey &key) const
{
SInt32 order;
diff --git a/src/corelib/tools/qcollator_posix.cpp b/src/corelib/tools/qcollator_posix.cpp
index a43618dcf1..b47b546d01 100644
--- a/src/corelib/tools/qcollator_posix.cpp
+++ b/src/corelib/tools/qcollator_posix.cpp
@@ -135,11 +135,6 @@ QCollatorSortKey QCollator::sortKey(const QString &string) const
return QCollatorSortKey(new QCollatorSortKeyPrivate(result));
}
-bool QCollatorSortKey::operator<(const QCollatorSortKey &otherKey) const
-{
- return compare(otherKey) < 0;
-}
-
int QCollatorSortKey::compare(const QCollatorSortKey &otherKey) const
{
return std::wcscmp(d->m_key.constData(),
diff --git a/src/corelib/tools/qcollator_win.cpp b/src/corelib/tools/qcollator_win.cpp
index 282711fbc6..8e59000946 100644
--- a/src/corelib/tools/qcollator_win.cpp
+++ b/src/corelib/tools/qcollator_win.cpp
@@ -155,11 +155,6 @@ QCollatorSortKey QCollator::sortKey(const QString &string) const
return QCollatorSortKey(new QCollatorSortKeyPrivate(ret));
}
-bool QCollatorSortKey::operator<(const QCollatorSortKey &otherKey) const
-{
- return d->m_key < otherKey.d->m_key;
-}
-
int QCollatorSortKey::compare(const QCollatorSortKey &otherKey) const
{
return d->m_key.compare(otherKey.d->m_key);
diff --git a/src/corelib/tools/qmap.cpp b/src/corelib/tools/qmap.cpp
index 9aebbb7b3c..22d744f869 100644
--- a/src/corelib/tools/qmap.cpp
+++ b/src/corelib/tools/qmap.cpp
@@ -897,6 +897,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
*/
/*! \fn const Key &QMap::firstKey() const
+ \since 5.2
Returns a reference to the smallest key in the map.
This function assumes that the map is not empty.
@@ -907,6 +908,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
*/
/*! \fn const Key &QMap::lastKey() const
+ \since 5.2
Returns a reference to the largest key in the map.
This function assumes that the map is not empty.
@@ -917,6 +919,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
*/
/*! \fn T &QMap::first()
+ \since 5.2
Returns a reference to the first value in the map, that is the value mapped
to the smallest key. This function assumes that the map is not empty.
@@ -927,11 +930,13 @@ void QMapDataBase::freeData(QMapDataBase *d)
*/
/*! \fn const T &QMap::first() const
+ \since 5.2
\overload
*/
/*! \fn T &QMap::last()
+ \since 5.2
Returns a reference to the last value in the map, that is the value mapped
to the largest key. This function assumes that the map is not empty.
@@ -942,6 +947,7 @@ void QMapDataBase::freeData(QMapDataBase *d)
*/
/*! \fn const T &QMap::last() const
+ \since 5.2
\overload
*/
diff --git a/src/corelib/tools/qtimezone.cpp b/src/corelib/tools/qtimezone.cpp
index b6196d99e5..9288dc7756 100644
--- a/src/corelib/tools/qtimezone.cpp
+++ b/src/corelib/tools/qtimezone.cpp
@@ -422,13 +422,18 @@ QTimeZone &QTimeZone::operator=(const QTimeZone &other)
return *this;
}
+/*
+ \fn void QTimeZone::swap(QTimeZone &other)
+
+ Swaps this timezone with \a other. This function is very fast and
+ never fails.
+*/
+
/*!
\fn QTimeZone &QTimeZone::operator=(QTimeZone &&other)
Move-assigns \a other to this QTimeZone instance, transferring the
ownership of the managed pointer to this instance.
-
- \since 5.2
*/
/*!
diff --git a/src/corelib/tools/qtimezone.h b/src/corelib/tools/qtimezone.h
index 1a6a923cf4..cbc4f3e4ad 100644
--- a/src/corelib/tools/qtimezone.h
+++ b/src/corelib/tools/qtimezone.h
@@ -78,8 +78,8 @@ public:
QTimeZone();
explicit QTimeZone(const QByteArray &olsenId);
- QTimeZone(int offsetSeconds);
- QTimeZone(const QByteArray &zoneId, int offsetSeconds, const QString &name,
+ explicit QTimeZone(int offsetSeconds);
+ /*implicit*/ QTimeZone(const QByteArray &zoneId, int offsetSeconds, const QString &name,
const QString &abbreviation, QLocale::Country country = QLocale::AnyCountry,
const QString &comment = QString());
QTimeZone(const QTimeZone &other);
@@ -87,9 +87,12 @@ public:
QTimeZone &operator=(const QTimeZone &other);
#ifdef Q_COMPILER_RVALUE_REFS
- QTimeZone &operator=(QTimeZone &&other) { std::swap(d, other.d); return *this; }
+ QTimeZone &operator=(QTimeZone &&other) { swap(other); return *this; }
#endif
+ void swap(QTimeZone &other)
+ { d.swap(other.d); }
+
bool operator==(const QTimeZone &other) const;
bool operator!=(const QTimeZone &other) const;
@@ -149,6 +152,7 @@ private:
};
Q_DECLARE_TYPEINFO(QTimeZone::OffsetData, Q_MOVABLE_TYPE);
+Q_DECLARE_SHARED(QTimeZone)
#ifndef QT_NO_DATASTREAM
Q_CORE_EXPORT QDataStream &operator<<(QDataStream &ds, const QTimeZone &tz);