summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/animation/qabstractanimation.cpp146
-rw-r--r--src/corelib/animation/qabstractanimation.h31
-rw-r--r--src/corelib/animation/qabstractanimation_p.h52
-rw-r--r--src/corelib/arch/qatomic_arm.h2
-rw-r--r--src/corelib/concurrent/qtconcurrentrunbase.h25
-rw-r--r--src/corelib/global/qglobal.h26
-rw-r--r--src/corelib/global/qmalloc.cpp16
-rw-r--r--src/corelib/io/qfilesystemwatcher_inotify.cpp16
-rw-r--r--src/corelib/io/qfsfileengine_win.cpp4
-rw-r--r--src/corelib/io/qsettings.cpp37
-rw-r--r--src/corelib/io/qurl.cpp8
-rw-r--r--src/corelib/io/qurl.h2
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp9
-rw-r--r--src/corelib/kernel/qeventdispatcher_glib.cpp9
-rw-r--r--src/corelib/kernel/qeventdispatcher_symbian.cpp9
-rw-r--r--src/corelib/kernel/qeventdispatcher_symbian_p.h4
-rw-r--r--src/corelib/kernel/qmimedata.cpp2
-rw-r--r--src/corelib/kernel/qobject.cpp4
-rw-r--r--src/corelib/kernel/qvariant.cpp8
-rw-r--r--src/corelib/kernel/qvariant.h2
-rw-r--r--src/corelib/plugin/qelfparser_p.cpp6
-rw-r--r--src/corelib/plugin/qelfparser_p.h5
-rw-r--r--src/corelib/statemachine/qstatemachine.cpp2
-rw-r--r--src/corelib/thread/qthread_unix.cpp1
-rw-r--r--src/corelib/thread/qthread_win.cpp1
-rw-r--r--src/corelib/tools/qbitarray.cpp7
-rw-r--r--src/corelib/tools/qbitarray.h2
-rw-r--r--src/corelib/tools/qbytearray.cpp17
-rw-r--r--src/corelib/tools/qbytearray.h2
-rw-r--r--src/corelib/tools/qcontiguouscache.cpp7
-rw-r--r--src/corelib/tools/qcontiguouscache.h1
-rw-r--r--src/corelib/tools/qhash.cpp14
-rw-r--r--src/corelib/tools/qhash.h2
-rw-r--r--src/corelib/tools/qlinkedlist.cpp7
-rw-r--r--src/corelib/tools/qlinkedlist.h1
-rw-r--r--src/corelib/tools/qlist.cpp7
-rw-r--r--src/corelib/tools/qlist.h1
-rw-r--r--src/corelib/tools/qlocale.cpp1
-rw-r--r--src/corelib/tools/qlocale.h2
-rw-r--r--src/corelib/tools/qmap.cpp14
-rw-r--r--src/corelib/tools/qmap.h2
-rw-r--r--src/corelib/tools/qpoint.cpp6
-rw-r--r--src/corelib/tools/qqueue.cpp8
-rw-r--r--src/corelib/tools/qqueue.h1
-rw-r--r--src/corelib/tools/qregexp.cpp8
-rw-r--r--src/corelib/tools/qregexp.h1
-rw-r--r--src/corelib/tools/qscopedpointer.h12
-rw-r--r--src/corelib/tools/qset.h1
-rw-r--r--src/corelib/tools/qset.qdoc7
-rw-r--r--src/corelib/tools/qshareddata.h14
-rw-r--r--src/corelib/tools/qsharedpointer_impl.h10
-rw-r--r--src/corelib/tools/qsize.cpp6
-rw-r--r--src/corelib/tools/qstack.cpp8
-rw-r--r--src/corelib/tools/qstack.h1
-rw-r--r--src/corelib/tools/qstring.cpp7
-rw-r--r--src/corelib/tools/qstring.h1
-rw-r--r--src/corelib/tools/qvarlengtharray.h124
-rw-r--r--src/corelib/tools/qvarlengtharray.qdoc208
-rw-r--r--src/corelib/tools/qvector.cpp7
-rw-r--r--src/corelib/tools/qvector.h7
60 files changed, 877 insertions, 74 deletions
diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp
index 641b42bdb9..9add36e14b 100644
--- a/src/corelib/animation/qabstractanimation.cpp
+++ b/src/corelib/animation/qabstractanimation.cpp
@@ -166,11 +166,12 @@ Q_GLOBAL_STATIC(QThreadStorage<QUnifiedTimer *>, unifiedTimer)
#endif
QUnifiedTimer::QUnifiedTimer() :
- QObject(), lastTick(0), timingInterval(DEFAULT_TIMER_INTERVAL),
+ QObject(), defaultDriver(this), lastTick(0), timingInterval(DEFAULT_TIMER_INTERVAL),
currentAnimationIdx(0), consistentTiming(false), slowMode(false),
slowdownFactor(5.0f), isPauseTimerActive(false), runningLeafAnimations(0)
{
time.invalidate();
+ driver = &defaultDriver;
}
@@ -247,14 +248,27 @@ void QUnifiedTimer::restartAnimationTimer()
qDebug() << runningPauseAnimations;
qDebug() << closestPauseAnimationTimeToFinish();
}
+ driver->stop();
animationTimer.start(closestTimeToFinish, this);
isPauseTimerActive = true;
- } else if (!animationTimer.isActive() || isPauseTimerActive) {
- animationTimer.start(timingInterval, this);
+ } else if (!driver->isRunning() || isPauseTimerActive) {
+ driver->start();
isPauseTimerActive = false;
}
}
+void QUnifiedTimer::setTimingInterval(int interval)
+{
+ timingInterval = interval;
+
+ if (driver->isRunning() && !isPauseTimerActive) {
+ //we changed the timing interval
+ driver->stop();
+ driver->start();
+ }
+}
+
+
void QUnifiedTimer::timerEvent(QTimerEvent *event)
{
//in the case of consistent timing we make sure the orders in which events come is always the same
@@ -369,6 +383,129 @@ int QUnifiedTimer::closestPauseAnimationTimeToFinish()
return closestTimeToFinish;
}
+void QUnifiedTimer::installAnimationDriver(QAnimationDriver *d)
+{
+ if (driver->isRunning()) {
+ qWarning("QUnifiedTimer: Cannot change animation driver while animations are running");
+ return;
+ }
+
+ if (driver && driver != &defaultDriver)
+ delete driver;
+
+ driver = d;
+}
+
+/*!
+ \class QAnimationDriver
+
+ \brief The QAnimationDriver class is used to exchange the mechanism that drives animations.
+
+ The default animation system is driven by a timer that fires at regular intervals.
+ In some scenarios, it is better to drive the animation based on other synchronization
+ mechanisms, such as the vertical refresh rate of the screen.
+ */
+
+QAnimationDriver::QAnimationDriver(QObject *parent)
+ : QObject(*(new QAnimationDriverPrivate), parent)
+{
+}
+
+QAnimationDriver::QAnimationDriver(QAnimationDriverPrivate &dd, QObject *parent)
+ : QObject(dd, parent)
+{
+}
+
+
+/*!
+ Advances the animation based on the current time. This function should
+ be continuously called by the driver while the animation is running.
+ */
+void QAnimationDriver::advance()
+{
+ QUnifiedTimer *instance = QUnifiedTimer::instance();
+
+ // update current time on all top level animations
+ instance->updateAnimationsTime();
+ instance->restartAnimationTimer();
+}
+
+
+/*!
+ Installs this animation driver. The animation driver is thread local and
+ will only apply for the thread its installed in.
+ */
+void QAnimationDriver::install()
+{
+ QUnifiedTimer *timer = QUnifiedTimer::instance(true);
+ timer->installAnimationDriver(this);
+}
+
+bool QAnimationDriver::isRunning() const
+{
+ return d_func()->running;
+}
+
+
+void QAnimationDriver::start()
+{
+ Q_D(QAnimationDriver);
+ if (!d->running) {
+ started();
+ d->running = true;
+ }
+}
+
+
+void QAnimationDriver::stop()
+{
+ Q_D(QAnimationDriver);
+ if (d->running) {
+ stopped();
+ d->running = false;
+ }
+}
+
+/*!
+ \fn QAnimationDriver::started()
+
+ This function is called by the animation framework to notify the driver
+ that it should start running.
+ */
+
+/*!
+ \fn QAnimationDriver::stopped()
+
+ This function is called by the animation framework to notify the driver
+ that it should stop running.
+ */
+
+/*!
+ The default animation driver just spins the timer...
+ */
+QDefaultAnimationDriver::QDefaultAnimationDriver(QUnifiedTimer *timer)
+ : QAnimationDriver(0), m_unified_timer(timer)
+{
+}
+
+void QDefaultAnimationDriver::timerEvent(QTimerEvent *e)
+{
+ Q_ASSERT(e->timerId() == m_timer.timerId());
+ advance();
+}
+
+void QDefaultAnimationDriver::started()
+{
+ m_timer.start(m_unified_timer->timingInterval, this);
+}
+
+void QDefaultAnimationDriver::stopped()
+{
+ m_timer.stop();
+}
+
+
+
void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState)
{
Q_Q(QAbstractAnimation);
@@ -794,6 +931,9 @@ void QAbstractAnimation::stop()
{
Q_D(QAbstractAnimation);
+ if (d->state == Stopped)
+ return;
+
d->setState(Stopped);
}
diff --git a/src/corelib/animation/qabstractanimation.h b/src/corelib/animation/qabstractanimation.h
index d3c0d0dcec..6abe8c197d 100644
--- a/src/corelib/animation/qabstractanimation.h
+++ b/src/corelib/animation/qabstractanimation.h
@@ -54,6 +54,7 @@ QT_MODULE(Core)
class QAnimationGroup;
class QSequentialAnimationGroup;
+class QAnimationDriver;
class QAbstractAnimationPrivate;
class Q_CORE_EXPORT QAbstractAnimation : public QObject
@@ -132,6 +133,36 @@ private:
Q_DECLARE_PRIVATE(QAbstractAnimation)
};
+class QAnimationDriverPrivate;
+class Q_CORE_EXPORT QAnimationDriver : public QObject
+{
+ Q_OBJECT
+ Q_DECLARE_PRIVATE(QAnimationDriver)
+
+public:
+ QAnimationDriver(QObject *parent);
+
+ void advance();
+ void install();
+
+ bool isRunning() const;
+
+protected:
+ virtual void started() = 0;
+ virtual void stopped() = 0;
+
+ QAnimationDriver(QAnimationDriverPrivate &dd, QObject *parent = 0);
+
+private:
+ friend class QUnifiedTimer;
+
+ void start();
+ void stop();
+};
+
+
+
+
#endif //QT_NO_ANIMATION
QT_END_NAMESPACE
diff --git a/src/corelib/animation/qabstractanimation_p.h b/src/corelib/animation/qabstractanimation_p.h
index d3d4098252..d56c130d12 100644
--- a/src/corelib/animation/qabstractanimation_p.h
+++ b/src/corelib/animation/qabstractanimation_p.h
@@ -58,6 +58,7 @@
#include <QtCore/qtimer.h>
#include <QtCore/qelapsedtimer.h>
#include <private/qobject_p.h>
+#include <qabstractanimation.h>
#ifdef Q_OS_WIN
#include <qt_windows.h>
@@ -114,30 +115,47 @@ private:
Q_DECLARE_PUBLIC(QAbstractAnimation)
};
+
+class QUnifiedTimer;
+class QDefaultAnimationDriver : public QAnimationDriver
+{
+ Q_OBJECT
+public:
+ QDefaultAnimationDriver(QUnifiedTimer *timer);
+ void timerEvent(QTimerEvent *e);
+
+ void started();
+ void stopped();
+
+private:
+ QBasicTimer m_timer;
+ QUnifiedTimer *m_unified_timer;
+};
+
+class Q_CORE_EXPORT QAnimationDriverPrivate : public QObjectPrivate
+{
+public:
+ QAnimationDriverPrivate() : running(false) {}
+ bool running;
+};
+
typedef QElapsedTimer ElapsedTimer;
-class QUnifiedTimer : public QObject
+class Q_CORE_EXPORT QUnifiedTimer : public QObject
{
private:
QUnifiedTimer();
public:
//XXX this is needed by dui
- static Q_CORE_EXPORT QUnifiedTimer *instance();
+ static QUnifiedTimer *instance();
static QUnifiedTimer *instance(bool create);
static void registerAnimation(QAbstractAnimation *animation, bool isTopLevel);
static void unregisterAnimation(QAbstractAnimation *animation);
//defines the timing interval. Default is DEFAULT_TIMER_INTERVAL
- void setTimingInterval(int interval)
- {
- timingInterval = interval;
- if (animationTimer.isActive() && !isPauseTimerActive) {
- //we changed the timing interval
- animationTimer.start(timingInterval, this);
- }
- }
+ void setTimingInterval(int interval);
/*
this allows to have a consistent timer interval at each tick from the timer
@@ -161,11 +179,20 @@ public:
*/
static void updateAnimationTimer();
+ void installAnimationDriver(QAnimationDriver *driver);
+
+ void restartAnimationTimer();
+ void updateAnimationsTime();
+
protected:
void timerEvent(QTimerEvent *);
private:
- // timer used for all active (running) animations
+ friend class QDefaultAnimationDriver;
+
+ QAnimationDriver *driver;
+ QDefaultAnimationDriver defaultDriver;
+
QBasicTimer animationTimer;
// timer used to delay the check if we should start/stop the animation timer
QBasicTimer startStopAnimationTimer;
@@ -195,9 +222,6 @@ private:
void registerRunningAnimation(QAbstractAnimation *animation);
void unregisterRunningAnimation(QAbstractAnimation *animation);
- void restartAnimationTimer();
-
- void updateAnimationsTime();
int closestPauseAnimationTimeToFinish();
};
diff --git a/src/corelib/arch/qatomic_arm.h b/src/corelib/arch/qatomic_arm.h
index 1c1c8a54b1..0513af2a2a 100644
--- a/src/corelib/arch/qatomic_arm.h
+++ b/src/corelib/arch/qatomic_arm.h
@@ -59,7 +59,7 @@ QT_END_INCLUDE_HEADER
|| defined(__ARM_ARCH_6K__) \
|| defined(__ARM_ARCH_6ZK__) \
|| defined(__ARM_ARCH_6M__) \
- || (__TARGET_ARCH_ARM-0 >= 6)
+ || (defined(__TARGET_ARCH_ARM) && (__TARGET_ARCH_ARM-0 >= 6))
# define QT_ARCH_ARMV6
QT_BEGIN_INCLUDE_HEADER
# include "QtCore/qatomic_armv6.h"
diff --git a/src/corelib/concurrent/qtconcurrentrunbase.h b/src/corelib/concurrent/qtconcurrentrunbase.h
index a6bbe3e0c3..888d3952c6 100644
--- a/src/corelib/concurrent/qtconcurrentrunbase.h
+++ b/src/corelib/concurrent/qtconcurrentrunbase.h
@@ -100,7 +100,18 @@ public:
this->reportFinished();
return;
}
- this->runFunctor();
+#ifndef QT_NO_EXCEPTIONS
+ try {
+#endif
+ this->runFunctor();
+#ifndef QT_NO_EXCEPTIONS
+ } catch (QtConcurrent::Exception &e) {
+ QFutureInterface<T>::reportException(e);
+ } catch (...) {
+ QFutureInterface<T>::reportException(QtConcurrent::UnhandledException());
+ }
+#endif
+
this->reportResult(result);
this->reportFinished();
}
@@ -117,7 +128,17 @@ public:
this->reportFinished();
return;
}
- this->runFunctor();
+#ifndef QT_NO_EXCEPTIONS
+ try {
+#endif
+ this->runFunctor();
+#ifndef QT_NO_EXCEPTIONS
+ } catch (QtConcurrent::Exception &e) {
+ QFutureInterface<void>::reportException(e);
+ } catch (...) {
+ QFutureInterface<void>::reportException(QtConcurrent::UnhandledException());
+ }
+#endif
this->reportFinished();
}
};
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index e71e3b6d44..b75a3d8617 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -64,6 +64,10 @@
#ifdef __cplusplus
+#ifndef QT_NO_STL
+#include <algorithm>
+#endif
+
#ifndef QT_NAMESPACE /* user namespace */
# define QT_PREPEND_NAMESPACE(name) ::name
@@ -2064,9 +2068,14 @@ Q_DECLARE_TYPEINFO_BODY(TYPE, FLAGS)
template <typename T>
inline void qSwap(T &value1, T &value2)
{
+#ifdef QT_NO_STL
const T t = value1;
value1 = value2;
value2 = t;
+#else
+ using std::swap;
+ swap(value1, value2);
+#endif
}
/*
@@ -2078,12 +2087,23 @@ inline void qSwap(T &value1, T &value2)
types must declare a 'bool isDetached(void) const;' member for this
to work.
*/
+#ifdef QT_NO_STL
+#define Q_DECLARE_SHARED_STL(TYPE)
+#else
+#define Q_DECLARE_SHARED_STL(TYPE) \
+QT_END_NAMESPACE \
+namespace std { \
+ template<> inline void swap<QT_PREPEND_NAMESPACE(TYPE)>(QT_PREPEND_NAMESPACE(TYPE) &value1, QT_PREPEND_NAMESPACE(TYPE) &value2) \
+ { swap(value1.data_ptr(), value2.data_ptr()); } \
+} \
+QT_BEGIN_NAMESPACE
+#endif
+
#define Q_DECLARE_SHARED(TYPE) \
template <> inline bool qIsDetached<TYPE>(TYPE &t) { return t.isDetached(); } \
template <> inline void qSwap<TYPE>(TYPE &value1, TYPE &value2) \
-{ \
- qSwap(value1.data_ptr(), value2.data_ptr()); \
-}
+{ qSwap(value1.data_ptr(), value2.data_ptr()); } \
+Q_DECLARE_SHARED_STL(TYPE)
/*
QTypeInfo primitive specializations
diff --git a/src/corelib/global/qmalloc.cpp b/src/corelib/global/qmalloc.cpp
index 090998c0cf..028a0a580d 100644
--- a/src/corelib/global/qmalloc.cpp
+++ b/src/corelib/global/qmalloc.cpp
@@ -90,8 +90,6 @@ void *qReallocAligned(void *oldptr, size_t newsize, size_t oldsize, size_t align
return newptr + 1;
}
- union { void *ptr; void **pptr; quintptr n; } real, faked;
-
// qMalloc returns pointers aligned at least at sizeof(size_t) boundaries
// but usually more (8- or 16-byte boundaries).
// So we overallocate by alignment-sizeof(size_t) bytes, so we're guaranteed to find a
@@ -100,19 +98,21 @@ void *qReallocAligned(void *oldptr, size_t newsize, size_t oldsize, size_t align
// However, we need to store the actual pointer, so we need to allocate actually size +
// alignment anyway.
- real.ptr = qRealloc(actualptr, newsize + alignment);
- if (!real.ptr)
+ void *real = qRealloc(actualptr, newsize + alignment);
+ if (!real)
return 0;
- faked.n = real.n + alignment;
- faked.n &= ~(alignment - 1);
+ quintptr faked = reinterpret_cast<quintptr>(real) + alignment;
+ faked &= ~(alignment - 1);
+
+ void **faked_ptr = reinterpret_cast<void **>(faked);
// now save the value of the real pointer at faked-sizeof(void*)
// by construction, alignment > sizeof(void*) and is a power of 2, so
// faked-sizeof(void*) is properly aligned for a pointer
- faked.pptr[-1] = real.ptr;
+ faked_ptr[-1] = real;
- return faked.ptr;
+ return faked_ptr;
}
void qFreeAligned(void *ptr)
diff --git a/src/corelib/io/qfilesystemwatcher_inotify.cpp b/src/corelib/io/qfilesystemwatcher_inotify.cpp
index 4740a8974b..dc18ae77e7 100644
--- a/src/corelib/io/qfilesystemwatcher_inotify.cpp
+++ b/src/corelib/io/qfilesystemwatcher_inotify.cpp
@@ -353,24 +353,24 @@ void QInotifyFileSystemWatcherEngine::readFromInotify()
ioctl(inotifyFd, FIONREAD, (char *) &buffSize);
QVarLengthArray<char, 4096> buffer(buffSize);
buffSize = read(inotifyFd, buffer.data(), buffSize);
- const char *at = buffer.data();
- const char * const end = at + buffSize;
+ char *at = buffer.data();
+ char * const end = at + buffSize;
- QMap<int, inotify_event> eventForId;
+ QMap<int, inotify_event *> eventForId;
while (at < end) {
- const inotify_event *event = reinterpret_cast<const inotify_event *>(at);
+ inotify_event *event = reinterpret_cast<inotify_event *>(at);
if (eventForId.contains(event->wd))
- eventForId[event->wd].mask |= event->mask;
+ eventForId[event->wd]->mask |= event->mask;
else
- eventForId.insert(event->wd, *event);
+ eventForId.insert(event->wd, event);
at += sizeof(inotify_event) + event->len;
}
- QMap<int, inotify_event>::const_iterator it = eventForId.constBegin();
+ QMap<int, inotify_event *>::const_iterator it = eventForId.constBegin();
while (it != eventForId.constEnd()) {
- inotify_event event = *it;
+ const inotify_event &event = **it;
++it;
// qDebug() << "inotify event, wd" << event.wd << "mask" << hex << event.mask;
diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp
index 3f11c3949d..71b10b4cb9 100644
--- a/src/corelib/io/qfsfileengine_win.cpp
+++ b/src/corelib/io/qfsfileengine_win.cpp
@@ -73,6 +73,10 @@
#define SPI_GETPLATFORMTYPE 257
#endif
+#ifndef PATH_MAX
+#define PATH_MAX FILENAME_MAX
+#endif
+
#ifndef _INTPTR_T_DEFINED
#ifdef _WIN64
typedef __int64 intptr_t;
diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp
index e4fb295772..7235459126 100644
--- a/src/corelib/io/qsettings.cpp
+++ b/src/corelib/io/qsettings.cpp
@@ -88,6 +88,12 @@
#define CSIDL_APPDATA 0x001a // <username>\Application Data
#endif
+#ifdef Q_AUTOTEST_EXPORT
+# define Q_AUTOTEST_EXPORT_HELPER Q_AUTOTEST_EXPORT
+#else
+# define Q_AUTOTEST_EXPORT_HELPER static
+#endif
+
// ************************************************************************
// QConfFile
@@ -134,7 +140,7 @@ QT_BEGIN_INCLUDE_NAMESPACE
# include <sys/mount.h>
QT_END_INCLUDE_NAMESPACE
-static bool isLikelyToBeNfs(int handle)
+Q_AUTOTEST_EXPORT_HELPER bool qIsLikelyToBeNfs(int handle)
{
struct statfs buf;
if (fstatfs(handle, &buf) != 0)
@@ -160,7 +166,7 @@ QT_END_INCLUDE_NAMESPACE
# define AUTOFSNG_SUPER_MAGIC 0x7d92b1a0
# endif
-static bool isLikelyToBeNfs(int handle)
+Q_AUTOTEST_EXPORT_HELPER bool qIsLikelyToBeNfs(int handle)
{
struct statfs buf;
if (fstatfs(handle, &buf) != 0)
@@ -177,7 +183,7 @@ QT_BEGIN_INCLUDE_NAMESPACE
# include <sys/statvfs.h>
QT_END_INCLUDE_NAMESPACE
-static bool isLikelyToBeNfs(int handle)
+Q_AUTOTEST_EXPORT_HELPER bool qIsLikelyToBeNfs(int handle)
{
struct statvfs buf;
if (fstatvfs(handle, &buf) != 0)
@@ -189,7 +195,7 @@ static bool isLikelyToBeNfs(int handle)
#endif
}
#else
-static inline bool isLikelyToBeNfs(int /* handle */)
+Q_AUTOTEST_EXPORT_HELPER inline bool qIsLikelyToBeNfs(int /* handle */)
{
return true;
}
@@ -203,7 +209,7 @@ static bool unixLock(int handle, int lockType)
now is to disable locking when we detect NFS (or AutoFS or
CacheFS, which are probably wrapping NFS).
*/
- if (isLikelyToBeNfs(handle))
+ if (qIsLikelyToBeNfs(handle))
return false;
struct flock fl;
@@ -1229,16 +1235,21 @@ QConfFileSettingsPrivate::~QConfFileSettingsPrivate()
if (confFiles[i] && !confFiles[i]->ref.deref()) {
if (confFiles[i]->size == 0) {
delete confFiles[i].take();
- } else if (unusedCache) {
+ } else {
if (usedHash)
usedHash->remove(confFiles[i]->name);
- QT_TRY {
- // compute a better size?
- unusedCache->insert(confFiles[i]->name, confFiles[i].data(),
- 10 + (confFiles[i]->originalKeys.size() / 4));
- confFiles[i].take();
- } QT_CATCH(...) {
- // out of memory. Do not cache the file.
+ if (unusedCache) {
+ QT_TRY {
+ // compute a better size?
+ unusedCache->insert(confFiles[i]->name, confFiles[i].data(),
+ 10 + (confFiles[i]->originalKeys.size() / 4));
+ confFiles[i].take();
+ } QT_CATCH(...) {
+ // out of memory. Do not cache the file.
+ delete confFiles[i].take();
+ }
+ } else {
+ // unusedCache is gone - delete the entry to prevent a memory leak
delete confFiles[i].take();
}
}
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index 6452c0fc80..6ec556205d 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -6048,6 +6048,14 @@ QUrl &QUrl::operator =(const QString &url)
return *this;
}
+/*!
+ \fn void QUrl::swap(QUrl &other)
+ \since 4.8
+
+ Swaps URL \a other with this URL. This operation is very
+ fast and never fails.
+*/
+
/*! \internal
Forces a detach.
diff --git a/src/corelib/io/qurl.h b/src/corelib/io/qurl.h
index 563be5fd19..63fe98dcae 100644
--- a/src/corelib/io/qurl.h
+++ b/src/corelib/io/qurl.h
@@ -100,6 +100,8 @@ public:
#endif
~QUrl();
+ inline void swap(QUrl &other) { qSwap(d, other.d); }
+
void setUrl(const QString &url);
void setUrl(const QString &url, ParsingMode mode);
// ### Qt 5: merge the two setUrl() functions, with mode = TolerantMode
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index e967884241..a8dc491c4e 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -415,11 +415,10 @@ QString qAppName()
operations can call processEvents() to keep the application
responsive.
- Some Qt classes, such as QString, can be used without a
- QCoreApplication object. However, in general, we recommend that
- you create a QCoreApplication or a QApplication object in your \c
- main() function as early as possible. exit() will not return
- until the event loop exits; e.g., when quit() is called.
+ In general, we recommend that you create a QCoreApplication or
+ a QApplication object in your \c main() function as early as
+ possible. exit() will not return until the event loop exits;
+ e.g., when quit() is called.
Several static convenience functions are also provided. The
QCoreApplication object is available from instance(). Events can
diff --git a/src/corelib/kernel/qeventdispatcher_glib.cpp b/src/corelib/kernel/qeventdispatcher_glib.cpp
index 8390275bb7..8d257803fa 100644
--- a/src/corelib/kernel/qeventdispatcher_glib.cpp
+++ b/src/corelib/kernel/qeventdispatcher_glib.cpp
@@ -180,6 +180,8 @@ static gboolean timerSourceCheck(GSource *source)
static gboolean timerSourceDispatch(GSource *source, GSourceFunc, gpointer)
{
GTimerSource *timerSource = reinterpret_cast<GTimerSource *>(source);
+ if (timerSource->processEventsFlags & QEventLoop::X11ExcludeTimers)
+ return true;
timerSource->runWithIdlePriority = true;
(void) timerSource->timerList.activateTimers();
return true; // ??? don't remove, right again?
@@ -311,6 +313,10 @@ QEventDispatcherGlibPrivate::QEventDispatcherGlibPrivate(GMainContext *context)
}
}
+#if GLIB_CHECK_VERSION (2, 22, 0)
+ g_main_context_push_thread_default (mainContext);
+#endif
+
// setup post event source
postEventSource = reinterpret_cast<GPostEventSource *>(g_source_new(&postEventSourceFuncs,
sizeof(GPostEventSource)));
@@ -389,6 +395,9 @@ QEventDispatcherGlib::~QEventDispatcherGlib()
d->postEventSource = 0;
Q_ASSERT(d->mainContext != 0);
+#if GLIB_CHECK_VERSION (2, 22, 0)
+ g_main_context_pop_thread_default (d->mainContext);
+#endif
g_main_context_unref(d->mainContext);
d->mainContext = 0;
}
diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp
index 87d6a49775..61541199db 100644
--- a/src/corelib/kernel/qeventdispatcher_symbian.cpp
+++ b/src/corelib/kernel/qeventdispatcher_symbian.cpp
@@ -975,9 +975,7 @@ bool QEventDispatcherSymbian::sendPostedEvents()
inline void QEventDispatcherSymbian::addDeferredActiveObject(QActiveObject *object)
{
- if (m_deferredActiveObjects.isEmpty()) {
- m_completeDeferredAOs->complete();
- }
+ queueDeferredActiveObjectsCompletion();
m_deferredActiveObjects.append(object);
}
@@ -986,6 +984,11 @@ inline void QEventDispatcherSymbian::removeDeferredActiveObject(QActiveObject *o
m_deferredActiveObjects.removeAll(object);
}
+void QEventDispatcherSymbian::queueDeferredActiveObjectsCompletion()
+{
+ m_completeDeferredAOs->complete();
+}
+
void QEventDispatcherSymbian::reactivateDeferredActiveObjects()
{
while (!m_deferredActiveObjects.isEmpty()) {
diff --git a/src/corelib/kernel/qeventdispatcher_symbian_p.h b/src/corelib/kernel/qeventdispatcher_symbian_p.h
index 1486db504e..3615996f54 100644
--- a/src/corelib/kernel/qeventdispatcher_symbian_p.h
+++ b/src/corelib/kernel/qeventdispatcher_symbian_p.h
@@ -247,7 +247,9 @@ public:
void addDeferredActiveObject(QActiveObject *object);
void removeDeferredActiveObject(QActiveObject *object);
- void reactivateDeferredActiveObjects();
+ void queueDeferredActiveObjectsCompletion();
+ // Can be overridden to activate local active objects too, but do call baseclass!
+ virtual void reactivateDeferredActiveObjects();
inline int iterationCount() const { return m_iterationCount; }
diff --git a/src/corelib/kernel/qmimedata.cpp b/src/corelib/kernel/qmimedata.cpp
index bf4001a1fc..899ca7bc9a 100644
--- a/src/corelib/kernel/qmimedata.cpp
+++ b/src/corelib/kernel/qmimedata.cpp
@@ -249,7 +249,7 @@ QVariant QMimeDataPrivate::retrieveTypedData(const QString &format, QVariant::Ty
\o We can subclass QMimeData and reimplement hasFormat(),
formats(), and retrieveData().
- \o If the drag and drop operation occurs withing a single
+ \o If the drag and drop operation occurs within a single
application, we can subclass QMimeData and add extra data in
it, and use a qobject_cast() in the receiver's drop event
handler. For example:
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 573bb50bcb..7fe9c52a56 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -3508,9 +3508,7 @@ void QMetaObject::activate(QObject *sender, const QMetaObject *m, int local_sign
// determine if this connection should be sent immediately or
// put into the event queue
- if ((c->connectionType == Qt::AutoConnection
- && (!receiverInSameThread
- || receiver->d_func()->threadData != sender->d_func()->threadData))
+ if ((c->connectionType == Qt::AutoConnection && !receiverInSameThread)
|| (c->connectionType == Qt::QueuedConnection)) {
queued_activate(sender, signal_absolute_index, c, argv ? argv : empty_argv);
continue;
diff --git a/src/corelib/kernel/qvariant.cpp b/src/corelib/kernel/qvariant.cpp
index feb85ce714..aa070f118c 100644
--- a/src/corelib/kernel/qvariant.cpp
+++ b/src/corelib/kernel/qvariant.cpp
@@ -1808,6 +1808,14 @@ QVariant& QVariant::operator=(const QVariant &variant)
}
/*!
+ \fn void QVariant::swap(QVariant &other)
+ \since 4.8
+
+ Swaps variant \a other with this variant. This operation is very
+ fast and never fails.
+*/
+
+/*!
\fn void QVariant::detach()
\internal
diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h
index b2679548c8..611db8bd83 100644
--- a/src/corelib/kernel/qvariant.h
+++ b/src/corelib/kernel/qvariant.h
@@ -224,6 +224,8 @@ class Q_CORE_EXPORT QVariant
{ qSwap(d, other.d); return *this; }
#endif
+ inline void swap(QVariant &other) { qSwap(d, other.d); }
+
Type type() const;
int userType() const;
const char *typeName() const;
diff --git a/src/corelib/plugin/qelfparser_p.cpp b/src/corelib/plugin/qelfparser_p.cpp
index 4ae7f8509f..c60b3d5973 100644
--- a/src/corelib/plugin/qelfparser_p.cpp
+++ b/src/corelib/plugin/qelfparser_p.cpp
@@ -39,8 +39,11 @@
**
****************************************************************************/
-#include "qlibrary_p.h"
#include "qelfparser_p.h"
+
+#if defined (Q_OF_ELF) && defined(Q_CC_GNU)
+
+#include "qlibrary_p.h"
#include <qdebug.h>
QT_BEGIN_NAMESPACE
@@ -232,3 +235,4 @@ int QElfParser::parse(const char *dataStart, ulong fdlen, const QString &library
QT_END_NAMESPACE
+#endif // defined(Q_OF_ELF) && defined(Q_CC_GNU)
diff --git a/src/corelib/plugin/qelfparser_p.h b/src/corelib/plugin/qelfparser_p.h
index 380d5a1e16..8087da5597 100644
--- a/src/corelib/plugin/qelfparser_p.h
+++ b/src/corelib/plugin/qelfparser_p.h
@@ -56,6 +56,8 @@
#include <qendian.h>
#include <qglobal.h>
+#if defined (Q_OF_ELF) && defined(Q_CC_GNU)
+
QT_BEGIN_NAMESPACE
class QString;
@@ -99,5 +101,6 @@ public:
QT_END_NAMESPACE
-#endif // QELFPARSER_P_H
+#endif // defined(Q_OF_ELF) && defined(Q_CC_GNU)
+#endif // QELFPARSER_P_H
diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp
index 09558a9aab..98f7931dcb 100644
--- a/src/corelib/statemachine/qstatemachine.cpp
+++ b/src/corelib/statemachine/qstatemachine.cpp
@@ -178,7 +178,7 @@ QT_BEGIN_NAMESPACE
QStateMachinePrivate::QStateMachinePrivate()
{
- QAbstractStatePrivate::isMachine = true;
+ isMachine = true;
state = NotRunning;
_startState = 0;
diff --git a/src/corelib/thread/qthread_unix.cpp b/src/corelib/thread/qthread_unix.cpp
index daf1a939ba..f508c0a4c0 100644
--- a/src/corelib/thread/qthread_unix.cpp
+++ b/src/corelib/thread/qthread_unix.cpp
@@ -345,6 +345,7 @@ void QThreadPrivate::finish(void *arg)
emit thr->terminated();
d->terminated = false;
emit thr->finished();
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
if (d->data->eventDispatcher) {
d->data->eventDispatcher->closingDown();
diff --git a/src/corelib/thread/qthread_win.cpp b/src/corelib/thread/qthread_win.cpp
index f0cbe8dab3..4a967ed3bc 100644
--- a/src/corelib/thread/qthread_win.cpp
+++ b/src/corelib/thread/qthread_win.cpp
@@ -332,6 +332,7 @@ void QThreadPrivate::finish(void *arg, bool lockAnyway)
emit thr->terminated();
d->terminated = false;
emit thr->finished();
+ QCoreApplication::sendPostedEvents(0, QEvent::DeferredDelete);
if (d->data->eventDispatcher) {
d->data->eventDispatcher->closingDown();
diff --git a/src/corelib/tools/qbitarray.cpp b/src/corelib/tools/qbitarray.cpp
index 04018ba20f..a1ad787e09 100644
--- a/src/corelib/tools/qbitarray.cpp
+++ b/src/corelib/tools/qbitarray.cpp
@@ -418,6 +418,13 @@ void QBitArray::fill(bool value, int begin, int end)
this bit array.
*/
+/*! \fn void QBitArray::swap(QBitArray &other)
+ \since 4.8
+
+ Swaps bit array \a other with this bit array. This operation is very
+ fast and never fails.
+*/
+
/*! \fn bool QBitArray::operator==(const QBitArray &other) const
Returns true if \a other is equal to this bit array; otherwise
diff --git a/src/corelib/tools/qbitarray.h b/src/corelib/tools/qbitarray.h
index bd79904ec6..ddda5e7af0 100644
--- a/src/corelib/tools/qbitarray.h
+++ b/src/corelib/tools/qbitarray.h
@@ -68,6 +68,8 @@ public:
{ qSwap(d, other.d); return *this; }
#endif
+ inline void swap(QBitArray &other) { qSwap(d, other.d); }
+
inline int size() const { return (d.size() << 3) - *d.constData(); }
inline int count() const { return (d.size() << 3) - *d.constData(); }
int count(bool on) const;
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp
index 6ba9fd3e75..f26d8783f6 100644
--- a/src/corelib/tools/qbytearray.cpp
+++ b/src/corelib/tools/qbytearray.cpp
@@ -541,6 +541,11 @@ QByteArray qUncompress(const uchar* data, int nbytes)
forever {
ulong alloc = len;
+ if (len >= (1 << 31) - sizeof(QByteArray::Data)) {
+ //QByteArray does not support that huge size anyway.
+ qWarning("qUncompress: Input data is corrupted");
+ return QByteArray();
+ }
QByteArray::Data *p = static_cast<QByteArray::Data *>(qRealloc(d.data(), sizeof(QByteArray::Data) + alloc));
if (!p) {
// we are not allowed to crash here when compiling with QT_NO_EXCEPTIONS
@@ -556,6 +561,11 @@ QByteArray qUncompress(const uchar* data, int nbytes)
switch (res) {
case Z_OK:
if (len != alloc) {
+ if (len >= (1 << 31) - sizeof(QByteArray::Data)) {
+ //QByteArray does not support that huge size anyway.
+ qWarning("qUncompress: Input data is corrupted");
+ return QByteArray();
+ }
QByteArray::Data *p = static_cast<QByteArray::Data *>(qRealloc(d.data(), sizeof(QByteArray::Data) + len));
if (!p) {
// we are not allowed to crash here when compiling with QT_NO_EXCEPTIONS
@@ -904,6 +914,13 @@ QByteArray &QByteArray::operator=(const char *str)
return *this;
}
+/*! \fn void QByteArray::swap(QByteArray &other)
+ \since 4.8
+
+ Swaps byte array \a other with this byte array. This operation is very
+ fast and never fails.
+*/
+
/*! \fn int QByteArray::size() const
Returns the number of bytes in this byte array.
diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h
index 3cdcaabd4e..b625f4c5e2 100644
--- a/src/corelib/tools/qbytearray.h
+++ b/src/corelib/tools/qbytearray.h
@@ -149,6 +149,8 @@ public:
{ qSwap(d, other.d); return *this; }
#endif
+ inline void swap(QByteArray &other) { qSwap(d, other.d); }
+
inline int size() const;
bool isEmpty() const;
void resize(int size);
diff --git a/src/corelib/tools/qcontiguouscache.cpp b/src/corelib/tools/qcontiguouscache.cpp
index 3ba5186af9..7880bd3a3d 100644
--- a/src/corelib/tools/qcontiguouscache.cpp
+++ b/src/corelib/tools/qcontiguouscache.cpp
@@ -194,6 +194,13 @@ MyRecord record(int row) const
Assigns \a other to this cache and returns a reference to this cache.
*/
+/*! \fn void QContiguousCache::swap(QContiguousCache<T> &other)
+ \since 4.8
+
+ Swaps cache \a other with this cache. This operation is very
+ fast and never fails.
+*/
+
/*! \fn bool QContiguousCache::operator==(const QContiguousCache<T> &other) const
Returns true if \a other is equal to this cache; otherwise returns false.
diff --git a/src/corelib/tools/qcontiguouscache.h b/src/corelib/tools/qcontiguouscache.h
index 4c1a846633..3d0a1593b5 100644
--- a/src/corelib/tools/qcontiguouscache.h
+++ b/src/corelib/tools/qcontiguouscache.h
@@ -114,6 +114,7 @@ public:
inline QContiguousCache<T> &operator=(QContiguousCache<T> &&other)
{ qSwap(d, other.d); return *this; }
#endif
+ inline void swap(QContiguousCache<T> &other) { qSwap(d, other.d); }
bool operator==(const QContiguousCache<T> &other) const;
inline bool operator!=(const QContiguousCache<T> &other) const { return !(*this == other); }
diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp
index 2971c063c1..3dc9c92fff 100644
--- a/src/corelib/tools/qhash.cpp
+++ b/src/corelib/tools/qhash.cpp
@@ -730,6 +730,20 @@ void QHashData::checkSanity()
Assigns \a other to this hash and returns a reference to this hash.
*/
+/*! \fn void QHash::swap(QHash<Key, T> &other)
+ \since 4.8
+
+ Swaps hash \a other with this hash. This operation is very
+ fast and never fails.
+*/
+
+/*! \fn void QMultiHash::swap(QMultiHash<Key, T> &other)
+ \since 4.8
+
+ Swaps hash \a other with this hash. This operation is very
+ fast and never fails.
+*/
+
/*! \fn bool QHash::operator==(const QHash<Key, T> &other) const
Returns true if \a other is equal to this hash; otherwise returns
diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h
index 992ff33b94..21fca2dd05 100644
--- a/src/corelib/tools/qhash.h
+++ b/src/corelib/tools/qhash.h
@@ -287,6 +287,7 @@ public:
inline QHash<Key, T> &operator=(QHash<Key, T> &&other)
{ qSwap(d, other.d); return *this; }
#endif
+ inline void swap(QHash<Key, T> &other) { qSwap(d, other.d); }
bool operator==(const QHash<Key, T> &other) const;
inline bool operator!=(const QHash<Key, T> &other) const { return !(*this == other); }
@@ -925,6 +926,7 @@ class QMultiHash : public QHash<Key, T>
public:
QMultiHash() {}
QMultiHash(const QHash<Key, T> &other) : QHash<Key, T>(other) {}
+ inline void swap(QMultiHash<Key, T> &other) { QHash<Key, T>::swap(other); } // prevent QMultiHash<->QHash swaps
inline typename QHash<Key, T>::iterator replace(const Key &key, const T &value)
{ return QHash<Key, T>::insert(key, value); }
diff --git a/src/corelib/tools/qlinkedlist.cpp b/src/corelib/tools/qlinkedlist.cpp
index 7213c6ef31..7b452fc1b8 100644
--- a/src/corelib/tools/qlinkedlist.cpp
+++ b/src/corelib/tools/qlinkedlist.cpp
@@ -147,6 +147,13 @@ QLinkedListData QLinkedListData::shared_null = {
list.
*/
+/*! \fn void QLinkedList::swap(QLinkedList<T> &other)
+ \since 4.8
+
+ Swaps list \a other with this list. This operation is very
+ fast and never fails.
+*/
+
/*! \fn bool QLinkedList::operator==(const QLinkedList<T> &other) const
Returns true if \a other is equal to this list; otherwise returns
diff --git a/src/corelib/tools/qlinkedlist.h b/src/corelib/tools/qlinkedlist.h
index c0879441fd..849bfd3a52 100644
--- a/src/corelib/tools/qlinkedlist.h
+++ b/src/corelib/tools/qlinkedlist.h
@@ -89,6 +89,7 @@ public:
inline QLinkedList<T> &operator=(QLinkedList<T> &&other)
{ qSwap(d, other.d); return *this; }
#endif
+ inline void swap(QLinkedList<T> &other) { qSwap(d, other.d); }
bool operator==(const QLinkedList<T> &l) const;
inline bool operator!=(const QLinkedList<T> &l) const { return !(*this == l); }
diff --git a/src/corelib/tools/qlist.cpp b/src/corelib/tools/qlist.cpp
index 9ba3768acb..5706171130 100644
--- a/src/corelib/tools/qlist.cpp
+++ b/src/corelib/tools/qlist.cpp
@@ -602,6 +602,13 @@ void **QListData::erase(void **xi)
list.
*/
+/*! \fn void QList::swap(QList<T> &other)
+ \since 4.8
+
+ Swaps list \a other with this list. This operation is very
+ fast and never fails.
+*/
+
/*! \fn bool QList::operator==(const QList<T> &other) const
Returns true if \a other is equal to this list; otherwise returns
diff --git a/src/corelib/tools/qlist.h b/src/corelib/tools/qlist.h
index 8f988d60a2..b1fcabfa8c 100644
--- a/src/corelib/tools/qlist.h
+++ b/src/corelib/tools/qlist.h
@@ -126,6 +126,7 @@ public:
inline QList &operator=(QList &&other)
{ qSwap(d, other.d); return *this; }
#endif
+ inline void swap(QList<T> &other) { qSwap(d, other.d); }
#ifdef Q_COMPILER_INITIALIZER_LISTS
inline QList(std::initializer_list<T> args) : d(&QListData::shared_null)
{ d->ref.ref(); qCopy(args.begin(), args.end(), std::back_inserter(*this)); }
diff --git a/src/corelib/tools/qlocale.cpp b/src/corelib/tools/qlocale.cpp
index 6b1de5ef0e..2fb3616223 100644
--- a/src/corelib/tools/qlocale.cpp
+++ b/src/corelib/tools/qlocale.cpp
@@ -7308,6 +7308,7 @@ Q_CORE_EXPORT char *qdtoa( double d, int mode, int ndigits, int *decpt, int *sig
Q_CORE_EXPORT double qstrtod(const char *s00, const char **se, bool *ok)
{
+ errno = 0;
double ret = strtod((char*)s00, (char**)se);
if (ok) {
if((ret == 0.0l && errno == ERANGE)
diff --git a/src/corelib/tools/qlocale.h b/src/corelib/tools/qlocale.h
index 8b424bbc3a..1af2cb476a 100644
--- a/src/corelib/tools/qlocale.h
+++ b/src/corelib/tools/qlocale.h
@@ -114,7 +114,7 @@ class Q_CORE_EXPORT QLocale
friend class QString;
friend class QByteArray;
friend class QIntValidator;
- friend class QDoubleValidator;
+ friend class QDoubleValidatorPrivate;
friend class QTextStream;
friend class QTextStreamPrivate;
diff --git a/src/corelib/tools/qmap.cpp b/src/corelib/tools/qmap.cpp
index 3143ee4081..5a5fffde8a 100644
--- a/src/corelib/tools/qmap.cpp
+++ b/src/corelib/tools/qmap.cpp
@@ -404,6 +404,20 @@ void QMapData::dump()
Assigns \a other to this map and returns a reference to this map.
*/
+/*! \fn void QMap::swap(QMap<Key, T> &other)
+ \since 4.8
+
+ Swaps map \a other with this map. This operation is very
+ fast and never fails.
+*/
+
+/*! \fn void QMultiMap::swap(QMultiMap<Key, T> &other)
+ \since 4.8
+
+ Swaps map \a other with this map. This operation is very
+ fast and never fails.
+*/
+
/*! \fn bool QMap::operator==(const QMap<Key, T> &other) const
Returns true if \a other is equal to this map; otherwise returns
diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h
index ce8fd75f7a..2897529463 100644
--- a/src/corelib/tools/qmap.h
+++ b/src/corelib/tools/qmap.h
@@ -189,6 +189,7 @@ public:
inline QMap<Key, T> &operator=(QMap<Key, T> &&other)
{ qSwap(d, other.d); return *this; }
#endif
+ inline void swap(QMap<Key, T> &other) { qSwap(d, other.d); }
#ifndef QT_NO_STL
explicit QMap(const typename std::map<Key, T> &other);
std::map<Key, T> toStdMap() const;
@@ -973,6 +974,7 @@ class QMultiMap : public QMap<Key, T>
public:
QMultiMap() {}
QMultiMap(const QMap<Key, T> &other) : QMap<Key, T>(other) {}
+ inline void swap(QMultiMap<Key, T> &other) { QMap<Key, T>::swap(other); }
inline typename QMap<Key, T>::iterator replace(const Key &key, const T &value)
{ return QMap<Key, T>::insert(key, value); }
diff --git a/src/corelib/tools/qpoint.cpp b/src/corelib/tools/qpoint.cpp
index 66f06e9ccd..c297709ee5 100644
--- a/src/corelib/tools/qpoint.cpp
+++ b/src/corelib/tools/qpoint.cpp
@@ -438,8 +438,12 @@ QDebug operator<<(QDebug d, const QPointF &p)
/*!
\fn bool QPointF::isNull() const
- Returns true if both the x and y coordinates are set to 0.0,
+ Returns true if both the x and y coordinates are set to +0.0;
otherwise returns false.
+
+ \note Since this function treats +0.0 and -0.0 differently, points
+ with zero-valued coordinates where either or both values have a
+ negative sign are not defined to be null points.
*/
diff --git a/src/corelib/tools/qqueue.cpp b/src/corelib/tools/qqueue.cpp
index 849bb0b473..36026956b2 100644
--- a/src/corelib/tools/qqueue.cpp
+++ b/src/corelib/tools/qqueue.cpp
@@ -91,6 +91,14 @@
*/
/*!
+ \fn void QQueue::swap(QQueue<T> &other)
+ \since 4.8
+
+ Swaps queue \a other with this queue. This operation is very
+ fast and never fails.
+*/
+
+/*!
\fn void QQueue::enqueue(const T& t)
Adds value \a t to the tail of the queue.
diff --git a/src/corelib/tools/qqueue.h b/src/corelib/tools/qqueue.h
index c29134b6f1..4ef1a61023 100644
--- a/src/corelib/tools/qqueue.h
+++ b/src/corelib/tools/qqueue.h
@@ -56,6 +56,7 @@ class QQueue : public QList<T>
public:
inline QQueue() {}
inline ~QQueue() {}
+ inline void swap(QQueue<T> &other) { QList<T>::swap(other); } // prevent QList<->QQueue swaps
inline void enqueue(const T &t) { QList<T>::append(t); }
inline T dequeue() { return QList<T>::takeFirst(); }
inline T &head() { return QList<T>::first(); }
diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/tools/qregexp.cpp
index 7a26c4f364..5d2a0e3954 100644
--- a/src/corelib/tools/qregexp.cpp
+++ b/src/corelib/tools/qregexp.cpp
@@ -3858,6 +3858,14 @@ QRegExp &QRegExp::operator=(const QRegExp &rx)
}
/*!
+ \fn void QRegExp::swap(QRegExp &other)
+ \since 4.8
+
+ Swaps regular expression \a other with this regular
+ expression. This operation is very fast and never fails.
+*/
+
+/*!
Returns true if this regular expression is equal to \a rx;
otherwise returns false.
diff --git a/src/corelib/tools/qregexp.h b/src/corelib/tools/qregexp.h
index 0b4a702c62..4a74f90dbc 100644
--- a/src/corelib/tools/qregexp.h
+++ b/src/corelib/tools/qregexp.h
@@ -80,6 +80,7 @@ public:
inline QRegExp &operator=(QRegExp &&other)
{ qSwap(priv,other.priv); return *this; }
#endif
+ inline void swap(QRegExp &other) { qSwap(priv, other.priv); }
bool operator==(const QRegExp &rx) const;
inline bool operator!=(const QRegExp &rx) const { return !operator==(rx); }
diff --git a/src/corelib/tools/qscopedpointer.h b/src/corelib/tools/qscopedpointer.h
index 40d3851f5d..b3a6db6fe4 100644
--- a/src/corelib/tools/qscopedpointer.h
+++ b/src/corelib/tools/qscopedpointer.h
@@ -186,6 +186,18 @@ template <class T, class Cleanup>
Q_INLINE_TEMPLATE void qSwap(QScopedPointer<T, Cleanup> &p1, QScopedPointer<T, Cleanup> &p2)
{ p1.swap(p2); }
+#ifndef QT_NO_STL
+QT_END_NAMESPACE
+namespace std {
+ template <class T, class Cleanup>
+ Q_INLINE_TEMPLATE void swap(QT_PREPEND_NAMESPACE(QScopedPointer)<T, Cleanup> &p1, QT_PREPEND_NAMESPACE(QScopedPointer)<T, Cleanup> &p2)
+ { p1.swap(p2); }
+}
+QT_BEGIN_NAMESPACE
+#endif
+
+
+
namespace QtPrivate {
template <typename X, typename Y> struct QScopedArrayEnsureSameType;
template <typename X> struct QScopedArrayEnsureSameType<X,X> { typedef X* Type; };
diff --git a/src/corelib/tools/qset.h b/src/corelib/tools/qset.h
index dc3c45a046..472078f8dc 100644
--- a/src/corelib/tools/qset.h
+++ b/src/corelib/tools/qset.h
@@ -65,6 +65,7 @@ public:
inline QSet<T> &operator=(QSet<T> &&other)
{ qSwap(q_hash, other.q_hash); return *this; }
#endif
+ inline void swap(QSet<T> &other) { q_hash.swap(other.q_hash); }
inline bool operator==(const QSet<T> &other) const
{ return q_hash == other.q_hash; }
diff --git a/src/corelib/tools/qset.qdoc b/src/corelib/tools/qset.qdoc
index 0bc2d2d68a..57368f04c3 100644
--- a/src/corelib/tools/qset.qdoc
+++ b/src/corelib/tools/qset.qdoc
@@ -123,6 +123,13 @@
*/
/*!
+ \fn void QSet::swap(QSet<T> &other)
+
+ Swaps set \a other with this set. This operation is very fast and
+ never fails.
+*/
+
+/*!
\fn bool QSet::operator==(const QSet<T> &other) const
Returns true if the \a other set is equal to this set; otherwise
diff --git a/src/corelib/tools/qshareddata.h b/src/corelib/tools/qshareddata.h
index b646a9d3ce..45456feb54 100644
--- a/src/corelib/tools/qshareddata.h
+++ b/src/corelib/tools/qshareddata.h
@@ -263,6 +263,20 @@ template <class T>
Q_INLINE_TEMPLATE void qSwap(QExplicitlySharedDataPointer<T> &p1, QExplicitlySharedDataPointer<T> &p2)
{ p1.swap(p2); }
+#ifndef QT_NO_STL
+QT_END_NAMESPACE
+namespace std {
+ template <class T>
+ Q_INLINE_TEMPLATE void swap(QT_PREPEND_NAMESPACE(QSharedDataPointer)<T> &p1, QT_PREPEND_NAMESPACE(QSharedDataPointer)<T> &p2)
+ { p1.swap(p2); }
+
+ template <class T>
+ Q_INLINE_TEMPLATE void swap(QT_PREPEND_NAMESPACE(QExplicitlySharedDataPointer)<T> &p1, QT_PREPEND_NAMESPACE(QExplicitlySharedDataPointer)<T> &p2)
+ { p1.swap(p2); }
+}
+QT_BEGIN_NAMESPACE
+#endif
+
QT_END_NAMESPACE
QT_END_HEADER
diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h
index 4b477133e3..ef8c454f2a 100644
--- a/src/corelib/tools/qsharedpointer_impl.h
+++ b/src/corelib/tools/qsharedpointer_impl.h
@@ -784,6 +784,16 @@ inline void qSwap(QSharedPointer<T> &p1, QSharedPointer<T> &p2)
p1.swap(p2);
}
+#ifndef QT_NO_STL
+QT_END_NAMESPACE
+namespace std {
+ template <class T>
+ inline void swap(QT_PREPEND_NAMESPACE(QSharedPointer)<T> &p1, QT_PREPEND_NAMESPACE(QSharedPointer)<T> &p2)
+ { p1.swap(p2); }
+}
+QT_BEGIN_NAMESPACE
+#endif
+
namespace QtSharedPointer {
// helper functions:
template <class X, class T>
diff --git a/src/corelib/tools/qsize.cpp b/src/corelib/tools/qsize.cpp
index 20ac344b39..12287abf5c 100644
--- a/src/corelib/tools/qsize.cpp
+++ b/src/corelib/tools/qsize.cpp
@@ -492,9 +492,13 @@ QDebug operator<<(QDebug dbg, const QSize &s) {
/*!
\fn bool QSizeF::isNull() const
- Returns true if both the width and height is 0; otherwise returns
+ Returns true if both the width and height are +0.0; otherwise returns
false.
+ \note Since this function treats +0.0 and -0.0 differently, sizes with
+ zero width and height where either or both values have a negative
+ sign are not defined to be null sizes.
+
\sa isValid(), isEmpty()
*/
diff --git a/src/corelib/tools/qstack.cpp b/src/corelib/tools/qstack.cpp
index fa149006e6..b42fe3bc3a 100644
--- a/src/corelib/tools/qstack.cpp
+++ b/src/corelib/tools/qstack.cpp
@@ -91,6 +91,14 @@
*/
/*!
+ \fn void QStack::swap(QStack<T> &other)
+ \since 4.8
+
+ Swaps stack \a other with this stack. This operation is very fast and
+ never fails.
+*/
+
+/*!
\fn void QStack::push(const T& t)
Adds element \a t to the top of the stack.
diff --git a/src/corelib/tools/qstack.h b/src/corelib/tools/qstack.h
index 526c7051eb..6ddc38119b 100644
--- a/src/corelib/tools/qstack.h
+++ b/src/corelib/tools/qstack.h
@@ -56,6 +56,7 @@ class QStack : public QVector<T>
public:
inline QStack() {}
inline ~QStack() {}
+ inline void swap(QStack<T> &other) { QVector<T>::swap(other); } // prevent QVector<->QStack swaps
inline void push(const T &t) { QVector<T>::append(t); }
T pop();
T &top();
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index 2737574ec2..a3d89f226a 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -1174,6 +1174,13 @@ QString::QString(QChar ch)
*/
+/*! \fn void QString::swap(QString &other)
+ \since 4.8
+
+ Swaps string \a other with this string. This operation is very fast and
+ never fails.
+*/
+
/*! \fn void QString::detach()
\internal
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h
index 589fdc2d20..07f43ca2c8 100644
--- a/src/corelib/tools/qstring.h
+++ b/src/corelib/tools/qstring.h
@@ -108,6 +108,7 @@ public:
inline QString &operator=(QString &&other)
{ qSwap(d, other.d); return *this; }
#endif
+ inline void swap(QString &other) { qSwap(d, other.d); }
inline int size() const { return d->size; }
inline int count() const { return d->size; }
inline int length() const;
diff --git a/src/corelib/tools/qvarlengtharray.h b/src/corelib/tools/qvarlengtharray.h
index 4a6bb4b802..38823239a0 100644
--- a/src/corelib/tools/qvarlengtharray.h
+++ b/src/corelib/tools/qvarlengtharray.h
@@ -44,7 +44,10 @@
#include <QtCore/qcontainerfwd.h>
#include <QtCore/qglobal.h>
+#include <QtCore/qalgorithms.h>
+
#include <new>
+#include <string.h>
QT_BEGIN_HEADER
@@ -123,6 +126,18 @@ public:
}
}
void append(const T *buf, int size);
+ inline QVarLengthArray<T, Prealloc> &operator<<(const T &t)
+ { append(t); return *this; }
+ inline QVarLengthArray<T, Prealloc> &operator+=(const T &t)
+ { append(t); return *this; }
+
+ void prepend(const T &t);
+ void insert(int i, const T &t);
+ void insert(int i, int n, const T &t);
+ void replace(int i, const T &t);
+ void remove(int i);
+ void remove(int i, int n);
+
inline T *data() { return ptr; }
inline const T *data() const { return ptr; }
@@ -135,6 +150,21 @@ public:
typedef const value_type &const_reference;
typedef qptrdiff difference_type;
+
+ typedef T* iterator;
+ typedef const T* const_iterator;
+
+ inline iterator begin() { return ptr; }
+ inline const_iterator begin() const { return ptr; }
+ inline const_iterator constBegin() const { return ptr; }
+ inline iterator end() { return ptr + s; }
+ inline const_iterator end() const { return ptr + s; }
+ inline const_iterator constEnd() const { return ptr + s; }
+ iterator insert(iterator before, int n, const T &x);
+ inline iterator insert(iterator before, const T &x) { return insert(before, 1, x); }
+ iterator erase(iterator begin, iterator end);
+ inline iterator erase(iterator pos) { return erase(pos, pos+1); }
+
private:
friend class QPodList<T, Prealloc>;
void realloc(int size, int alloc);
@@ -272,6 +302,100 @@ Q_OUTOFLINE_TEMPLATE T QVarLengthArray<T, Prealloc>::value(int i, const T &defau
return (i < 0 || i >= size()) ? defaultValue : at(i);
}
+template <class T, int Prealloc>
+inline void QVarLengthArray<T, Prealloc>::insert(int i, const T &t)
+{ Q_ASSERT_X(i >= 0 && i <= s, "QVarLengthArray::insert", "index out of range");
+ insert(begin() + i, 1, t); }
+template <class T, int Prealloc>
+inline void QVarLengthArray<T, Prealloc>::insert(int i, int n, const T &t)
+{ Q_ASSERT_X(i >= 0 && i <= s, "QVarLengthArray::insert", "index out of range");
+ insert(begin() + i, n, t); }
+template <class T, int Prealloc>
+inline void QVarLengthArray<T, Prealloc>::remove(int i, int n)
+{ Q_ASSERT_X(i >= 0 && n >= 0 && i + n <= s, "QVarLengthArray::remove", "index out of range");
+ erase(begin() + i, begin() + i + n); }
+template <class T, int Prealloc>
+inline void QVarLengthArray<T, Prealloc>::remove(int i)
+{ Q_ASSERT_X(i >= 0 && i < s, "QVarLengthArray::remove", "index out of range");
+ erase(begin() + i, begin() + i + 1); }
+template <class T, int Prealloc>
+inline void QVarLengthArray<T, Prealloc>::prepend(const T &t)
+{ insert(begin(), 1, t); }
+
+template <class T, int Prealloc>
+inline void QVarLengthArray<T, Prealloc>::replace(int i, const T &t)
+{
+ Q_ASSERT_X(i >= 0 && i < s, "QVarLengthArray::replace", "index out of range");
+ const T copy(t);
+ data()[i] = copy;
+}
+
+
+template <class T, int Prealloc>
+Q_OUTOFLINE_TEMPLATE typename QVarLengthArray<T, Prealloc>::iterator QVarLengthArray<T, Prealloc>::insert(iterator before, size_type n, const T &t)
+{
+ int offset = int(before - ptr);
+ if (n != 0) {
+ resize(s + n);
+ const T copy(t);
+ if (QTypeInfo<T>::isStatic) {
+ T *b = ptr + offset;
+ T *j = ptr + s;
+ T *i = j - n;
+ while (i != b)
+ *--j = *--i;
+ i = b + n;
+ while (i != b)
+ *--i = copy;
+ } else {
+ T *b = ptr + offset;
+ T *i = b + n;
+ memmove(i, b, (s - offset - n) * sizeof(T));
+ while (i != b)
+ new (--i) T(copy);
+ }
+ }
+ return ptr + offset;
+}
+
+template <class T, int Prealloc>
+Q_OUTOFLINE_TEMPLATE typename QVarLengthArray<T, Prealloc>::iterator QVarLengthArray<T, Prealloc>::erase(iterator abegin, iterator aend)
+{
+ int f = int(abegin - ptr);
+ int l = int(aend - ptr);
+ int n = l - f;
+ if (QTypeInfo<T>::isComplex) {
+ qCopy(ptr + l, ptr + s, ptr + f);
+ T *i = ptr + s;
+ T *b = ptr + s - n;
+ while (i != b) {
+ --i;
+ i->~T();
+ }
+ } else {
+ memmove(ptr + f, ptr + l, (s - l) * sizeof(T));
+ }
+ s -= n;
+ return ptr + f;
+}
+
+template <typename T, int Prealloc1, int Prealloc2>
+bool operator==(const QVarLengthArray<T, Prealloc1> &l, const QVarLengthArray<T, Prealloc2> &r)
+{
+ if (l.size() != r.size())
+ return false;
+ for (int i = 0; i < l.size(); i++) {
+ if (l.at(i) != r.at(i))
+ return false;
+ }
+ return true;
+}
+
+template <typename T, int Prealloc1, int Prealloc2>
+bool operator!=(const QVarLengthArray<T, Prealloc1> &l, const QVarLengthArray<T, Prealloc2> &r)
+{
+ return !(l == r);
+}
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qvarlengtharray.qdoc b/src/corelib/tools/qvarlengtharray.qdoc
index 6f91bccd0d..4d5d5d1412 100644
--- a/src/corelib/tools/qvarlengtharray.qdoc
+++ b/src/corelib/tools/qvarlengtharray.qdoc
@@ -337,3 +337,211 @@
Typedef for const T &. Provided for STL compatibility.
*/
+/*! \fn void QVarLengthArray::prepend(const T &value)
+
+ \since 4.8
+ Inserts \a value at the beginning of the array.
+
+
+ This is the same as vector.insert(0, \a value).
+
+ For large arrays, this operation can be slow (\l{linear time}),
+ because it requires moving all the items in the vector by one
+ position further in memory. If you want a container class that
+ provides a fast prepend() function, use QList or QLinkedList
+ instead.
+
+ \sa append(), insert()
+*/
+
+/*! \fn void QVarLengthArray::replace(int i, const T &value)
+
+ \since 4.8
+ Replaces the item at index position \a i with \a value.
+
+ \a i must be a valid index position in the array (i.e., 0 <= \a
+ i < size()).
+
+ \sa operator[](), remove()
+*/
+
+/*! \fn void QVarLengthArray::remove(int i)
+
+ \overload
+ \since 4.8
+
+ Removes the element at index position \a i.
+
+ \sa insert(), replace()
+*/
+
+/*! \fn void QVarLengthArray::remove(int i, int count)
+
+ \overload
+ \since 4.8
+
+ Removes \a count elements from the middle of the array, starting at
+ index position \a i.
+
+ \sa insert(), replace()
+*/
+
+/*! \fn QVarLengthArray::iterator QVarLengthArray::begin()
+ \since 4.8
+
+ Returns an \l{STL-style iterator} pointing to the first item in
+ the array.
+
+ \sa constBegin(), end()
+*/
+
+/*! \fn QVarLengthArray::const_iterator QVarLengthArray::begin() const
+ \since 4.8
+ \overload
+*/
+
+/*! \fn QVarLengthArray::const_iterator QVarLengthArray::constBegin() const
+ \since 4.8
+
+ Returns a const \l{STL-style iterator} pointing to the first item
+ in the array.
+
+ \sa begin(), constEnd()
+*/
+
+/*! \fn QVarLengthArray::iterator QVarLengthArray::end()
+ \since 4.8
+
+ Returns an \l{STL-style iterator} pointing to the imaginary item
+ after the last item in the array.
+
+ \sa begin(), constEnd()
+*/
+
+/*! \fn QVarLengthArray::const_iterator QVarLengthArray::end() const
+ \since 4.8
+
+ \overload
+*/
+
+/*! \fn QVarLengthArray::const_iterator QVarLengthArray::constEnd() const
+ \since 4.8
+
+ Returns a const \l{STL-style iterator} pointing to the imaginary
+ item after the last item in the array.
+
+ \sa constBegin(), end()
+*/
+
+/*! \fn QVarLengthArray::iterator QVarLengthArray::erase(iterator pos)
+ \since 4.8
+
+ Removes the item pointed to by the iterator \a pos from the
+ vector, and returns an iterator to the next item in the vector
+ (which may be end()).
+
+ \sa insert(), remove()
+*/
+
+/*! \fn QVarLengthArray::iterator QVarLengthArray::erase(iterator begin, iterator end)
+
+ \overload
+ \since 4.8
+
+ Removes all the items from \a begin up to (but not including) \a
+ end. Returns an iterator to the same item that \a end referred to
+ before the call.
+*/
+
+/*! \fn void QVarLengthArray::insert(int i, const T &value)
+ \since 4.8
+
+ Inserts \a value at index position \a i in the array. If \a i is
+ 0, the value is prepended to the vector. If \a i is size(), the
+ value is appended to the vector.
+
+ For large arrays, this operation can be slow (\l{linear time}),
+ because it requires moving all the items at indexes \a i and
+ above by one position further in memory. If you want a container
+ class that provides a fast insert() function, use QLinkedList
+ instead.
+
+ \sa remove()
+*/
+
+/*! \fn void QVarLengthArray::insert(int i, int count, const T &value)
+
+ \overload
+ \since 4.8
+
+ Inserts \a count copies of \a value at index position \a i in the
+ vector.
+*/
+
+/*! \fn QVarLengthArray::iterator QVarLengthArray::insert(iterator before, const T &value)
+
+ \overload
+ \since 4.8
+
+ Inserts \a value in front of the item pointed to by the iterator
+ \a before. Returns an iterator pointing at the inserted item.
+*/
+
+/*! \fn QVarLengthArray::iterator QVarLengthArray::insert(iterator before, int count, const T &value)
+
+ \since 4.8
+ Inserts \a count copies of \a value in front of the item pointed to
+ by the iterator \a before. Returns an iterator pointing at the
+ first of the inserted items.
+*/
+
+
+
+/*! \fn bool operator==(const QVarLengthArray<T, Prealloc1> &left, const QVarLengthArray<T, Prealloc2> &right)
+
+ \relates QVarLengthArray
+ \since 4.8
+ Returns true if the two array are equal;
+
+ Two arrays are considered equal if they contain the same values
+ in the same order.
+
+ This function requires the value type to have an implementation
+ of \c operator==().
+
+ \sa operator!=()
+*/
+
+/*! \fn bool operator!=(const QVarLengthArray<T, Prealloc1> &left, const QVarLengthArray<T, Prealloc2> &right)
+
+ \relates QVarLengthArray
+ \since 4.8
+ Returns true if the two array are different;
+
+ Two arrays are considered equal if they contain the same values
+ in the same order.
+
+ This function requires the value type to have an implementation
+ of \c operator==().
+
+ \sa operator==()
+*/
+
+/*! \fn QVarLengthArray &QVarLengthArray::operator<<(const T &value)
+
+ \since 4.8
+ Appends \a value to the array and returns a reference to this
+ vector.
+
+ \sa append(), operator+=()
+*/
+
+/*! \fn QVarLengthArray &QVarLengthArray::operator+=(const T &value)
+
+ \since 4.8
+ Appends \a value to the array and returns a reference to this
+ vector.
+
+ \sa append(), operator<<()
+*/
+
diff --git a/src/corelib/tools/qvector.cpp b/src/corelib/tools/qvector.cpp
index 3a13540766..0497211690 100644
--- a/src/corelib/tools/qvector.cpp
+++ b/src/corelib/tools/qvector.cpp
@@ -285,6 +285,13 @@ int QVectorData::grow(int sizeofTypedData, int size, int sizeofT, bool excessive
vector.
*/
+/*! \fn void QVector::swap(QVector<T> &other)
+ \since 4.8
+
+ Swaps vector \a other with this vector. This operation is very fast and
+ never fails.
+*/
+
/*! \fn bool QVector::operator==(const QVector<T> &other) const
Returns true if \a other is equal to this vector; otherwise
diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h
index c16aefb2ef..0f7db88c90 100644
--- a/src/corelib/tools/qvector.h
+++ b/src/corelib/tools/qvector.h
@@ -125,6 +125,7 @@ public:
inline QVector<T> operator=(QVector<T> &&other)
{ qSwap(p, other.p); return *this; }
#endif
+ inline void swap(QVector<T> &other) { qSwap(d, other.d); }
#ifdef Q_COMPILER_INITIALIZER_LISTS
inline QVector(std::initializer_list<T> args);
#endif
@@ -303,7 +304,7 @@ public:
#ifndef QT_NO_STL
static inline QVector<T> fromStdVector(const std::vector<T> &vector)
- { QVector<T> tmp; tmp.reserve(vector.size()); qCopy(vector.begin(), vector.end(), std::back_inserter(tmp)); return tmp; }
+ { QVector<T> tmp; tmp.reserve(int(vector.size())); qCopy(vector.begin(), vector.end(), std::back_inserter(tmp)); return tmp; }
inline std::vector<T> toStdVector() const
{ std::vector<T> tmp; tmp.reserve(size()); qCopy(constBegin(), constEnd(), std::back_inserter(tmp)); return tmp; }
#endif
@@ -439,9 +440,9 @@ QVector<T>::QVector(int asize, const T &t)
template <typename T>
QVector<T>::QVector(std::initializer_list<T> args)
{
- d = malloc(args.size());
+ d = malloc(int(args.size()));
d->ref = 1;
- d->alloc = d->size = args.size();
+ d->alloc = d->size = int(args.size());
d->sharable = true;
d->capacity = false;
T* i = p->array + d->size;