summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/animation/qabstractanimation.cpp159
-rw-r--r--src/corelib/animation/qabstractanimation.h12
-rw-r--r--src/corelib/animation/qabstractanimation_p.h6
-rw-r--r--src/corelib/animation/qanimationgroup.cpp28
-rw-r--r--src/corelib/animation/qanimationgroup.h6
-rw-r--r--src/corelib/animation/qparallelanimationgroup.cpp6
-rw-r--r--src/corelib/animation/qparallelanimationgroup.h2
-rw-r--r--src/corelib/animation/qpauseanimation.cpp5
-rw-r--r--src/corelib/animation/qpropertyanimation.cpp16
-rw-r--r--src/corelib/animation/qpropertyanimation.h2
-rw-r--r--src/corelib/animation/qsequentialanimationgroup.cpp30
-rw-r--r--src/corelib/animation/qsequentialanimationgroup.h4
-rw-r--r--src/corelib/animation/qvariantanimation.cpp4
-rw-r--r--src/corelib/animation/qvariantanimation.h2
-rw-r--r--src/corelib/arch/armv6/qatomic_generic_armv6.cpp260
-rw-r--r--src/corelib/arch/qatomic_armv6.h304
-rw-r--r--src/corelib/arch/qatomic_symbian.h241
-rw-r--r--src/corelib/arch/symbian/arch.pri2
-rw-r--r--src/corelib/arch/symbian/qatomic_symbian.cpp167
-rw-r--r--src/corelib/corelib.pro2
-rw-r--r--src/corelib/eval.pri4
-rw-r--r--src/corelib/global/global.pri2
-rw-r--r--src/corelib/global/qconfig-minimal.h6
-rw-r--r--src/corelib/global/qfeatures.h274
-rw-r--r--src/corelib/global/qfeatures.txt108
-rw-r--r--src/corelib/global/qglobal.cpp106
-rw-r--r--src/corelib/global/qglobal.h42
-rw-r--r--src/corelib/global/qlibraryinfo.cpp33
-rw-r--r--src/corelib/global/qlibraryinfo.h4
-rw-r--r--src/corelib/global/qmalloc.cpp58
-rw-r--r--src/corelib/global/qnamespace.h114
-rw-r--r--src/corelib/global/qnamespace.qdoc150
-rw-r--r--src/corelib/io/qdatastream.cpp2
-rw-r--r--src/corelib/io/qdatastream.h2
-rw-r--r--src/corelib/io/qdatastream_p.h2
-rw-r--r--src/corelib/io/qdir.cpp5
-rw-r--r--src/corelib/io/qfile.cpp31
-rw-r--r--src/corelib/io/qfsfileengine.cpp183
-rw-r--r--src/corelib/io/qfsfileengine_p.h10
-rw-r--r--src/corelib/io/qfsfileengine_unix.cpp37
-rw-r--r--src/corelib/io/qfsfileengine_win.cpp153
-rw-r--r--src/corelib/io/qiodevice.cpp212
-rw-r--r--src/corelib/io/qprocess_unix.cpp18
-rw-r--r--src/corelib/io/qsettings.cpp24
-rw-r--r--src/corelib/io/qsettings_p.h1
-rw-r--r--src/corelib/io/qurl.cpp186
-rw-r--r--src/corelib/kernel/qabstractitemmodel.cpp6
-rw-r--r--src/corelib/kernel/qcoreevent.cpp1
-rw-r--r--src/corelib/kernel/qcoreevent.h1
-rw-r--r--src/corelib/kernel/qeventdispatcher_symbian.cpp6
-rw-r--r--src/corelib/kernel/qeventdispatcher_win.cpp206
-rw-r--r--src/corelib/kernel/qfunctions_wince.h4
-rw-r--r--src/corelib/kernel/qmetaobject.cpp9
-rw-r--r--src/corelib/kernel/qobject.cpp158
-rw-r--r--src/corelib/kernel/qsharedmemory_unix.cpp3
-rw-r--r--src/corelib/kernel/qtcore_eval.cpp569
-rw-r--r--src/corelib/kernel/qvariant.h41
-rw-r--r--src/corelib/plugin/qlibrary.cpp3
-rw-r--r--src/corelib/statemachine/qabstractstate.cpp15
-rw-r--r--src/corelib/statemachine/qabstractstate_p.h14
-rw-r--r--src/corelib/statemachine/qfinalstate.cpp1
-rw-r--r--src/corelib/statemachine/qhistorystate.cpp3
-rw-r--r--src/corelib/statemachine/qstate.cpp76
-rw-r--r--src/corelib/statemachine/qstate.h4
-rw-r--r--src/corelib/statemachine/qstate_p.h6
-rw-r--r--src/corelib/statemachine/qstatemachine.cpp194
-rw-r--r--src/corelib/statemachine/qstatemachine.h8
-rw-r--r--src/corelib/statemachine/qstatemachine_p.h20
-rw-r--r--src/corelib/tools/qalgorithms.h42
-rw-r--r--src/corelib/tools/qbytearray.cpp4
-rw-r--r--src/corelib/tools/qbytearray.h2
-rw-r--r--src/corelib/tools/qbytearraymatcher.h8
-rw-r--r--src/corelib/tools/qcontiguouscache.cpp41
-rw-r--r--src/corelib/tools/qcontiguouscache.h147
-rw-r--r--src/corelib/tools/qdatetime.cpp64
-rw-r--r--src/corelib/tools/qhash.cpp28
-rw-r--r--src/corelib/tools/qhash.h37
-rw-r--r--src/corelib/tools/qlocale_symbian.cpp4
-rw-r--r--src/corelib/tools/qmap.cpp32
-rw-r--r--src/corelib/tools/qmap.h21
-rw-r--r--src/corelib/tools/qregexp.cpp18
-rw-r--r--src/corelib/tools/qregexp.h3
-rw-r--r--src/corelib/tools/qringbuffer_p.h27
-rw-r--r--src/corelib/tools/qscopedpointer.cpp14
-rw-r--r--src/corelib/tools/qscopedpointer.h116
-rw-r--r--src/corelib/tools/qscopedpointer_p.h151
-rw-r--r--src/corelib/tools/qstring.cpp10
-rw-r--r--src/corelib/tools/qstring.h3
-rw-r--r--src/corelib/tools/qstringbuilder.cpp24
-rw-r--r--src/corelib/tools/qstringbuilder.h58
-rw-r--r--src/corelib/tools/qstringmatcher.h6
-rw-r--r--src/corelib/tools/qunicodetables_p.h4
-rw-r--r--src/corelib/tools/qvector.cpp29
-rw-r--r--src/corelib/tools/qvector.h23
-rw-r--r--src/corelib/tools/tools.pri3
-rwxr-xr-xsrc/corelib/xml/make-parser.sh2
-rw-r--r--src/corelib/xml/qxmlstream.g5
-rw-r--r--src/corelib/xml/qxmlstream_p.h33
98 files changed, 3744 insertions, 1588 deletions
diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp
index c775a00a6d..ef4989bc4f 100644
--- a/src/corelib/animation/qabstractanimation.cpp
+++ b/src/corelib/animation/qabstractanimation.cpp
@@ -50,7 +50,7 @@
animations that plug into the rest of the animation framework.
The progress of an animation is given by its current time
- (currentTime()), which is measured in milliseconds from the start
+ (currentLoopTime()), which is measured in milliseconds from the start
of the animation (0) to its end (duration()). The value is updated
automatically while the animation is running. It can also be set
directly with setCurrentTime().
@@ -115,7 +115,7 @@
*/
/*!
- \fn QAbstractAnimation::stateChanged(QAbstractAnimation::State oldState, QAbstractAnimation::State newState)
+ \fn QAbstractAnimation::stateChanged(QAbstractAnimation::State newState, QAbstractAnimation::State oldState)
QAbstractAnimation emits this signal whenever the state of the animation has
changed from \a oldState to \a newState. This signal is emitted after the virtual
@@ -157,19 +157,7 @@
#ifndef QT_NO_ANIMATION
#define DEFAULT_TIMER_INTERVAL 16
-
-#ifdef Q_WS_WIN
- /// Fix for Qt 4.7
- //on windows if you're currently dragging a widget an inner eventloop was started by the system
- //to make sure that this timer is getting fired, we need to make sure to use the system timers
- //that will send a WM_TIMER event. We do that by settings the timer interval to 11
- //It is 16 because QEventDispatcherWin32Private::registerTimer specifically checks if the interval
- //is greater than 11 to determine if it should use a system timer (or the multimedia timer).
-#define STARTSTOP_TIMER_DELAY 16
-#else
#define STARTSTOP_TIMER_DELAY 0
-#endif
-
QT_BEGIN_NAMESPACE
@@ -177,8 +165,8 @@ Q_GLOBAL_STATIC(QThreadStorage<QUnifiedTimer *>, unifiedTimer)
QUnifiedTimer::QUnifiedTimer() :
QObject(), lastTick(0), timingInterval(DEFAULT_TIMER_INTERVAL),
- currentAnimationIdx(0), consistentTiming(false), isPauseTimerActive(false),
- runningLeafAnimations(0)
+ currentAnimationIdx(0), consistentTiming(false), slowMode(false),
+ isPauseTimerActive(false), runningLeafAnimations(0)
{
}
@@ -194,22 +182,19 @@ QUnifiedTimer *QUnifiedTimer::instance()
return inst;
}
-void QUnifiedTimer::ensureTimerUpdate(QAbstractAnimation *animation)
+void QUnifiedTimer::ensureTimerUpdate()
{
- if (isPauseTimerActive) {
+ if (isPauseTimerActive)
updateAnimationsTime();
- } else {
- // this code is needed when ensureTimerUpdate is called from setState because we update
- // the currentTime when an animation starts running (otherwise we could remove it)
- animation->setCurrentTime(animation->currentTime());
- }
}
void QUnifiedTimer::updateAnimationsTime()
{
// ignore consistentTiming in case the pause timer is active
- const int delta = (consistentTiming && !isPauseTimerActive) ?
+ int delta = (consistentTiming && !isPauseTimerActive) ?
timingInterval : time.elapsed() - lastTick;
+ if (slowMode)
+ delta /= 5;
lastTick = time.elapsed();
//we make sure we only call update time if the time has actually changed
@@ -230,6 +215,10 @@ void QUnifiedTimer::restartAnimationTimer()
{
if (runningLeafAnimations == 0 && !runningPauseAnimations.isEmpty()) {
int closestTimeToFinish = closestPauseAnimationTimeToFinish();
+ if (closestTimeToFinish < 0) {
+ qDebug() << runningPauseAnimations;
+ qDebug() << closestPauseAnimationTimeToFinish();
+ }
animationTimer.start(closestTimeToFinish, this);
isPauseTimerActive = true;
} else if (!animationTimer.isActive() || isPauseTimerActive) {
@@ -272,7 +261,8 @@ void QUnifiedTimer::registerAnimation(QAbstractAnimation *animation, bool isTopL
Q_ASSERT(!QAbstractAnimationPrivate::get(animation)->hasRegisteredTimer);
QAbstractAnimationPrivate::get(animation)->hasRegisteredTimer = true;
animationsToStart << animation;
- startStopAnimationTimer.start(STARTSTOP_TIMER_DELAY, this);
+ if (!startStopAnimationTimer.isActive())
+ startStopAnimationTimer.start(STARTSTOP_TIMER_DELAY, this);
}
}
@@ -290,7 +280,7 @@ void QUnifiedTimer::unregisterAnimation(QAbstractAnimation *animation)
if (idx <= currentAnimationIdx)
--currentAnimationIdx;
- if (animations.isEmpty())
+ if (animations.isEmpty() && !startStopAnimationTimer.isActive())
startStopAnimationTimer.start(STARTSTOP_TIMER_DELAY, this);
} else {
animationsToStart.removeOne(animation);
@@ -303,9 +293,11 @@ void QUnifiedTimer::registerRunningAnimation(QAbstractAnimation *animation)
if (QAbstractAnimationPrivate::get(animation)->isGroup)
return;
- if (QAbstractAnimationPrivate::get(animation)->isPause)
+ if (QAbstractAnimationPrivate::get(animation)->isPause) {
+ if (animation->duration() == -1)
+ qDebug() << "toto";
runningPauseAnimations << animation;
- else
+ } else
runningLeafAnimations++;
}
@@ -318,6 +310,7 @@ void QUnifiedTimer::unregisterRunningAnimation(QAbstractAnimation *animation)
runningPauseAnimations.removeOne(animation);
else
runningLeafAnimations--;
+ Q_ASSERT(runningLeafAnimations >= 0);
}
int QUnifiedTimer::closestPauseAnimationTimeToFinish()
@@ -328,9 +321,9 @@ int QUnifiedTimer::closestPauseAnimationTimeToFinish()
int timeToFinish;
if (animation->direction() == QAbstractAnimation::Forward)
- timeToFinish = animation->totalDuration() - QAbstractAnimationPrivate::get(animation)->totalCurrentTime;
+ timeToFinish = animation->duration() - animation->currentLoopTime();
else
- timeToFinish = QAbstractAnimationPrivate::get(animation)->totalCurrentTime;
+ timeToFinish = animation->currentLoopTime();
if (timeToFinish < closestTimeToFinish)
closestTimeToFinish = timeToFinish;
@@ -362,59 +355,50 @@ void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState)
state = newState;
QWeakPointer<QAbstractAnimation> guard(q);
- q->updateState(oldState, newState);
- if (!guard)
- return;
+ //(un)registration of the animation must always happen before calls to
+ //virtual function (updateState) to ensure a correct state of the timer
+ bool isTopLevel = !group || group->state() == QAbstractAnimation::Stopped;
+ if (oldState == QAbstractAnimation::Running) {
+ if (newState == QAbstractAnimation::Paused && hasRegisteredTimer)
+ QUnifiedTimer::instance()->ensureTimerUpdate();
+ //the animation, is not running any more
+ QUnifiedTimer::instance()->unregisterAnimation(q);
+ } else if (newState == QAbstractAnimation::Running) {
+ QUnifiedTimer::instance()->registerAnimation(q, isTopLevel);
+ }
- //this is to be safe if updateState changes the state
- if (state == oldState)
+ q->updateState(newState, oldState);
+ if (!guard || newState != state) //this is to be safe if updateState changes the state
return;
// Notify state change
- emit q->stateChanged(oldState, newState);
- if (!guard)
+ emit q->stateChanged(newState, oldState);
+ if (!guard || newState != state) //this is to be safe if updateState changes the state
return;
switch (state) {
case QAbstractAnimation::Paused:
- if (hasRegisteredTimer)
- // currentTime needs to be updated if pauseTimer is active
- QUnifiedTimer::instance()->ensureTimerUpdate(q);
- if (!guard)
- return;
- QUnifiedTimer::instance()->unregisterAnimation(q);
break;
case QAbstractAnimation::Running:
{
- bool isTopLevel = !group || group->state() == QAbstractAnimation::Stopped;
// this ensures that the value is updated now that the animation is running
if (oldState == QAbstractAnimation::Stopped) {
- if (isTopLevel)
+ if (isTopLevel) {
// currentTime needs to be updated if pauseTimer is active
- QUnifiedTimer::instance()->ensureTimerUpdate(q);
- if (!guard)
- return;
- }
-
- // test needed in case we stop in the setCurrentTime inside ensureTimerUpdate (zero duration)
- if (state == QAbstractAnimation::Running) {
- // register timer if our parent is not running
- QUnifiedTimer::instance()->registerAnimation(q, isTopLevel);
+ QUnifiedTimer::instance()->ensureTimerUpdate();
+ q->setCurrentTime(totalCurrentTime);
+ }
}
}
break;
case QAbstractAnimation::Stopped:
// Leave running state.
int dura = q->duration();
- if (!guard)
- return;
if (deleteWhenStopped)
q->deleteLater();
- QUnifiedTimer::instance()->unregisterAnimation(q);
-
if (dura == -1 || loopCount < 0
|| (oldDirection == QAbstractAnimation::Forward && (oldCurrentTime * (oldCurrentLoop + 1)) == (dura * loopCount))
|| (oldDirection == QAbstractAnimation::Backward && oldCurrentTime == 0)) {
@@ -460,7 +444,8 @@ QAbstractAnimation::~QAbstractAnimation()
QAbstractAnimation::State oldState = d->state;
d->state = Stopped;
emit stateChanged(oldState, d->state);
- QUnifiedTimer::instance()->unregisterAnimation(this);
+ if (oldState == QAbstractAnimation::Running)
+ QUnifiedTimer::instance()->unregisterAnimation(this);
}
}
@@ -559,7 +544,7 @@ void QAbstractAnimation::setDirection(Direction direction)
// the commands order below is important: first we need to setCurrentTime with the old direction,
// then update the direction on this and all children and finally restart the pauseTimer if needed
if (d->hasRegisteredTimer)
- QUnifiedTimer::instance()->ensureTimerUpdate(this);
+ QUnifiedTimer::instance()->ensureTimerUpdate();
d->direction = direction;
updateDirection(direction);
@@ -648,13 +633,25 @@ int QAbstractAnimation::currentLoop() const
*/
int QAbstractAnimation::totalDuration() const
{
- Q_D(const QAbstractAnimation);
- if (d->loopCount < 0)
- return -1;
int dura = duration();
- if (dura == -1)
+ if (dura <= 0)
+ return dura;
+ int loopcount = loopCount();
+ if (loopcount < 0)
return -1;
- return dura * d->loopCount;
+ return dura * loopcount;
+}
+
+/*!
+ Returns the current time inside the current loop. It can go from 0 to duration().
+
+ \sa duration(), currentTime
+*/
+
+int QAbstractAnimation::currentLoopTime() const
+{
+ Q_D(const QAbstractAnimation);
+ return d->currentTime;
}
/*!
@@ -666,17 +663,14 @@ int QAbstractAnimation::totalDuration() const
the animation run, setting the current time automatically as the animation
progresses.
- The animation's current time starts at 0, and ends at duration(). If the
- animation's loopCount is larger than 1, the current time will rewind and
- start at 0 again for the consecutive loops. If the animation has a pause.
- currentTime will also include the duration of the pause.
+ The animation's current time starts at 0, and ends at totalDuration().
- \sa loopCount
+ \sa loopCount, currentLoopTime()
*/
int QAbstractAnimation::currentTime() const
{
Q_D(const QAbstractAnimation);
- return d->currentTime;
+ return d->totalCurrentTime;
}
void QAbstractAnimation::setCurrentTime(int msecs)
{
@@ -685,7 +679,7 @@ void QAbstractAnimation::setCurrentTime(int msecs)
// Calculate new time and loop.
int dura = duration();
- int totalDura = (d->loopCount < 0 || dura == -1) ? -1 : dura * d->loopCount;
+ int totalDura = dura <= 0 ? dura : ((d->loopCount < 0) ? -1 : dura * d->loopCount);
if (totalDura != -1)
msecs = qMin(totalDura, msecs);
d->totalCurrentTime = msecs;
@@ -750,7 +744,7 @@ void QAbstractAnimation::start(DeletionPolicy policy)
signal, and state() returns Stopped. The current time is not changed.
If the animation stops by itself after reaching the end (i.e.,
- currentTime() == duration() and currentLoop() > loopCount() - 1), the
+ currentLoopTime() == duration() and currentLoop() > loopCount() - 1), the
finished() signal is emitted.
\sa start(), state()
@@ -800,6 +794,21 @@ void QAbstractAnimation::resume()
}
/*!
+ If \a paused is true, the animation is paused.
+ If \a paused is false, the animation is resumed.
+
+ \sa state(), pause(), resume()
+*/
+void QAbstractAnimation::setPaused(bool paused)
+{
+ if (paused)
+ pause();
+ else
+ resume();
+}
+
+
+/*!
\reimp
*/
bool QAbstractAnimation::event(QEvent *event)
@@ -822,8 +831,8 @@ bool QAbstractAnimation::event(QEvent *event)
\sa start(), stop(), pause(), resume()
*/
-void QAbstractAnimation::updateState(QAbstractAnimation::State oldState,
- QAbstractAnimation::State newState)
+void QAbstractAnimation::updateState(QAbstractAnimation::State newState,
+ QAbstractAnimation::State oldState)
{
Q_UNUSED(oldState);
Q_UNUSED(newState);
diff --git a/src/corelib/animation/qabstractanimation.h b/src/corelib/animation/qabstractanimation.h
index 50b07d771a..3c6e12fab6 100644
--- a/src/corelib/animation/qabstractanimation.h
+++ b/src/corelib/animation/qabstractanimation.h
@@ -59,6 +59,8 @@ class QAbstractAnimationPrivate;
class Q_CORE_EXPORT QAbstractAnimation : public QObject
{
Q_OBJECT
+ Q_ENUMS(State)
+ Q_ENUMS(Direction)
Q_PROPERTY(State state READ state NOTIFY stateChanged)
Q_PROPERTY(int loopCount READ loopCount WRITE setLoopCount)
Q_PROPERTY(int currentTime READ currentTime WRITE setCurrentTime)
@@ -93,6 +95,9 @@ public:
Direction direction() const;
void setDirection(Direction direction);
+ int currentTime() const;
+ int currentLoopTime() const;
+
int loopCount() const;
void setLoopCount(int loopCount);
int currentLoop() const;
@@ -100,11 +105,9 @@ public:
virtual int duration() const = 0;
int totalDuration() const;
- int currentTime() const;
-
Q_SIGNALS:
void finished();
- void stateChanged(QAbstractAnimation::State oldState, QAbstractAnimation::State newState);
+ void stateChanged(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
void currentLoopChanged(int currentLoop);
void directionChanged(QAbstractAnimation::Direction);
@@ -112,6 +115,7 @@ public Q_SLOTS:
void start(QAbstractAnimation::DeletionPolicy policy = KeepWhenStopped);
void pause();
void resume();
+ void setPaused(bool);
void stop();
void setCurrentTime(int msecs);
@@ -120,7 +124,7 @@ protected:
bool event(QEvent *event);
virtual void updateCurrentTime(int currentTime) = 0;
- virtual void updateState(QAbstractAnimation::State oldState, QAbstractAnimation::State newState);
+ virtual void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
virtual void updateDirection(QAbstractAnimation::Direction direction);
private:
diff --git a/src/corelib/animation/qabstractanimation_p.h b/src/corelib/animation/qabstractanimation_p.h
index bef0499624..720e68d193 100644
--- a/src/corelib/animation/qabstractanimation_p.h
+++ b/src/corelib/animation/qabstractanimation_p.h
@@ -138,11 +138,14 @@ public:
*/
void setConsistentTiming(bool consistent) { consistentTiming = consistent; }
+ //this facilitates fine-tuning of complex animations
+ void setSlowModeEnabled(bool enabled) { slowMode = enabled; }
+
/*
this is used for updating the currentTime of all animations in case the pause
timer is active or, otherwise, only of the animation passed as parameter.
*/
- void ensureTimerUpdate(QAbstractAnimation *animation);
+ void ensureTimerUpdate();
/*
this will evaluate the need of restarting the pause timer in case there is still
@@ -164,6 +167,7 @@ private:
int timingInterval;
int currentAnimationIdx;
bool consistentTiming;
+ bool slowMode;
// bool to indicate that only pause animations are active
bool isPauseTimerActive;
diff --git a/src/corelib/animation/qanimationgroup.cpp b/src/corelib/animation/qanimationgroup.cpp
index 40f5936554..64282eab5f 100644
--- a/src/corelib/animation/qanimationgroup.cpp
+++ b/src/corelib/animation/qanimationgroup.cpp
@@ -70,7 +70,7 @@
QAnimationGroup provides methods for adding and retrieving
animations. Besides that, you can remove animations by calling
remove(), and clear the animation group by calling
- clearAnimations(). You may keep track of changes in the group's
+ clear(). You may keep track of changes in the group's
animations by listening to QEvent::ChildAdded and
QEvent::ChildRemoved events.
@@ -151,7 +151,7 @@ int QAnimationGroup::animationCount() const
Returns the index of \a animation. The returned index can be passed
to the other functions that take an index as an argument.
- \sa insertAnimationAt(), animationAt(), takeAnimationAt()
+ \sa insertAnimation(), animationAt(), takeAnimation()
*/
int QAnimationGroup::indexOfAnimation(QAbstractAnimation *animation) const
{
@@ -160,7 +160,7 @@ int QAnimationGroup::indexOfAnimation(QAbstractAnimation *animation) const
}
/*!
- Adds \a animation to this group. This will call insertAnimationAt with
+ Adds \a animation to this group. This will call insertAnimation with
index equals to animationCount().
\note The group takes ownership of the animation.
@@ -170,7 +170,7 @@ int QAnimationGroup::indexOfAnimation(QAbstractAnimation *animation) const
void QAnimationGroup::addAnimation(QAbstractAnimation *animation)
{
Q_D(QAnimationGroup);
- insertAnimationAt(d->animations.count(), animation);
+ insertAnimation(d->animations.count(), animation);
}
/*!
@@ -180,14 +180,14 @@ void QAnimationGroup::addAnimation(QAbstractAnimation *animation)
\note The group takes ownership of the animation.
- \sa takeAnimationAt(), addAnimation(), indexOfAnimation(), removeAnimation()
+ \sa takeAnimation(), addAnimation(), indexOfAnimation(), removeAnimation()
*/
-void QAnimationGroup::insertAnimationAt(int index, QAbstractAnimation *animation)
+void QAnimationGroup::insertAnimation(int index, QAbstractAnimation *animation)
{
Q_D(QAnimationGroup);
if (index < 0 || index > d->animations.size()) {
- qWarning("QAnimationGroup::insertAnimationAt: index is out of bounds");
+ qWarning("QAnimationGroup::insertAnimation: index is out of bounds");
return;
}
@@ -205,7 +205,7 @@ void QAnimationGroup::insertAnimationAt(int index, QAbstractAnimation *animation
Removes \a animation from this group. The ownership of \a animation is
transferred to the caller.
- \sa takeAnimationAt(), insertAnimationAt(), addAnimation()
+ \sa takeAnimation(), insertAnimation(), addAnimation()
*/
void QAnimationGroup::removeAnimation(QAbstractAnimation *animation)
{
@@ -221,7 +221,7 @@ void QAnimationGroup::removeAnimation(QAbstractAnimation *animation)
return;
}
- takeAnimationAt(index);
+ takeAnimation(index);
}
/*!
@@ -229,13 +229,13 @@ void QAnimationGroup::removeAnimation(QAbstractAnimation *animation)
\note The ownership of the animation is transferred to the caller.
- \sa removeAnimation(), addAnimation(), insertAnimationAt(), indexOfAnimation()
+ \sa removeAnimation(), addAnimation(), insertAnimation(), indexOfAnimation()
*/
-QAbstractAnimation *QAnimationGroup::takeAnimationAt(int index)
+QAbstractAnimation *QAnimationGroup::takeAnimation(int index)
{
Q_D(QAnimationGroup);
if (index < 0 || index >= d->animations.size()) {
- qWarning("QAnimationGroup::takeAnimationAt: no animation at index %d", index);
+ qWarning("QAnimationGroup::takeAnimation: no animation at index %d", index);
return 0;
}
QAbstractAnimation *animation = d->animations.at(index);
@@ -254,7 +254,7 @@ QAbstractAnimation *QAnimationGroup::takeAnimationAt(int index)
\sa addAnimation(), removeAnimation()
*/
-void QAnimationGroup::clearAnimations()
+void QAnimationGroup::clear()
{
Q_D(QAnimationGroup);
qDeleteAll(d->animations);
@@ -279,7 +279,7 @@ bool QAnimationGroup::event(QEvent *event)
// case it might be called from the destructor.
int index = d->animations.indexOf(a);
if (index != -1)
- takeAnimationAt(index);
+ takeAnimation(index);
}
return QAbstractAnimation::event(event);
}
diff --git a/src/corelib/animation/qanimationgroup.h b/src/corelib/animation/qanimationgroup.h
index 86368a33b4..416ce3fb47 100644
--- a/src/corelib/animation/qanimationgroup.h
+++ b/src/corelib/animation/qanimationgroup.h
@@ -65,10 +65,10 @@ public:
int animationCount() const;
int indexOfAnimation(QAbstractAnimation *animation) const;
void addAnimation(QAbstractAnimation *animation);
- void insertAnimationAt(int index, QAbstractAnimation *animation);
+ void insertAnimation(int index, QAbstractAnimation *animation);
void removeAnimation(QAbstractAnimation *animation);
- QAbstractAnimation *takeAnimationAt(int index);
- void clearAnimations();
+ QAbstractAnimation *takeAnimation(int index);
+ void clear();
protected:
QAnimationGroup(QAnimationGroupPrivate &dd, QObject *parent);
diff --git a/src/corelib/animation/qparallelanimationgroup.cpp b/src/corelib/animation/qparallelanimationgroup.cpp
index 0a04c14ff9..2d37d10eca 100644
--- a/src/corelib/animation/qparallelanimationgroup.cpp
+++ b/src/corelib/animation/qparallelanimationgroup.cpp
@@ -182,11 +182,11 @@ void QParallelAnimationGroup::updateCurrentTime(int currentTime)
/*!
\reimp
*/
-void QParallelAnimationGroup::updateState(QAbstractAnimation::State oldState,
- QAbstractAnimation::State newState)
+void QParallelAnimationGroup::updateState(QAbstractAnimation::State newState,
+ QAbstractAnimation::State oldState)
{
Q_D(QParallelAnimationGroup);
- QAnimationGroup::updateState(oldState, newState);
+ QAnimationGroup::updateState(newState, oldState);
switch (newState) {
case Stopped:
diff --git a/src/corelib/animation/qparallelanimationgroup.h b/src/corelib/animation/qparallelanimationgroup.h
index 1cab91e5c0..18ec885966 100644
--- a/src/corelib/animation/qparallelanimationgroup.h
+++ b/src/corelib/animation/qparallelanimationgroup.h
@@ -68,7 +68,7 @@ protected:
bool event(QEvent *event);
void updateCurrentTime(int currentTime);
- void updateState(QAbstractAnimation::State oldState, QAbstractAnimation::State newState);
+ void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
void updateDirection(QAbstractAnimation::Direction direction);
private:
diff --git a/src/corelib/animation/qpauseanimation.cpp b/src/corelib/animation/qpauseanimation.cpp
index d90f0013d0..1b3b654b86 100644
--- a/src/corelib/animation/qpauseanimation.cpp
+++ b/src/corelib/animation/qpauseanimation.cpp
@@ -56,7 +56,7 @@
It is not necessary to construct a QPauseAnimation yourself.
QSequentialAnimationGroup provides the convenience functions
\l{QSequentialAnimationGroup::}{addPause()} and
- \l{QSequentialAnimationGroup::}{insertPauseAt()}. These functions
+ \l{QSequentialAnimationGroup::}{insertPause()}. These functions
simply take the number of milliseconds the pause should last.
\sa QSequentialAnimationGroup
@@ -73,7 +73,7 @@ QT_BEGIN_NAMESPACE
class QPauseAnimationPrivate : public QAbstractAnimationPrivate
{
public:
- QPauseAnimationPrivate() : QAbstractAnimationPrivate(), duration(0)
+ QPauseAnimationPrivate() : QAbstractAnimationPrivate(), duration(250)
{
isPause = true;
}
@@ -114,6 +114,7 @@ QPauseAnimation::~QPauseAnimation()
\brief the duration of the pause.
The duration of the pause. The duration should not be negative.
+ The default duration is 250 milliseconds.
*/
int QPauseAnimation::duration() const
{
diff --git a/src/corelib/animation/qpropertyanimation.cpp b/src/corelib/animation/qpropertyanimation.cpp
index 4742e54953..013ff7fe54 100644
--- a/src/corelib/animation/qpropertyanimation.cpp
+++ b/src/corelib/animation/qpropertyanimation.cpp
@@ -58,12 +58,12 @@
an example:
\code
- QPropertyAnimation animation(myWidget, "geometry");
- animation.setDuration(10000);
- animation.setStartValue(QRect(0, 0, 100, 30));
- animation.setEndValue(QRect(250, 250, 100, 30));
+ QPropertyAnimation *animation = new QPropertyAnimation(myWidget, "geometry");
+ animation->setDuration(10000);
+ animation->setStartValue(QRect(0, 0, 100, 30));
+ animation->setEndValue(QRect(250, 250, 100, 30));
- animation.start();
+ animation->start();
\endcode
The property name and the QObject instance of which property
@@ -250,8 +250,8 @@ void QPropertyAnimation::updateCurrentValue(const QVariant &value)
If the startValue is not defined when the state of the animation changes from Stopped to Running,
the current property value is used as the initial value for the animation.
*/
-void QPropertyAnimation::updateState(QAbstractAnimation::State oldState,
- QAbstractAnimation::State newState)
+void QPropertyAnimation::updateState(QAbstractAnimation::State newState,
+ QAbstractAnimation::State oldState)
{
Q_D(QPropertyAnimation);
@@ -260,7 +260,7 @@ void QPropertyAnimation::updateState(QAbstractAnimation::State oldState,
return;
}
- QVariantAnimation::updateState(oldState, newState);
+ QVariantAnimation::updateState(newState, oldState);
QPropertyAnimation *animToStop = 0;
{
diff --git a/src/corelib/animation/qpropertyanimation.h b/src/corelib/animation/qpropertyanimation.h
index 2e2ca3a2c2..61efed9958 100644
--- a/src/corelib/animation/qpropertyanimation.h
+++ b/src/corelib/animation/qpropertyanimation.h
@@ -73,7 +73,7 @@ public:
protected:
bool event(QEvent *event);
void updateCurrentValue(const QVariant &value);
- void updateState(QAbstractAnimation::State oldState, QAbstractAnimation::State newState);
+ void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
private:
Q_DISABLE_COPY(QPropertyAnimation)
diff --git a/src/corelib/animation/qsequentialanimationgroup.cpp b/src/corelib/animation/qsequentialanimationgroup.cpp
index 5ca560a1e5..5dbb8c3d10 100644
--- a/src/corelib/animation/qsequentialanimationgroup.cpp
+++ b/src/corelib/animation/qsequentialanimationgroup.cpp
@@ -50,7 +50,7 @@
another has finished playing. The animations are played in the
order they are added to the group (using
\l{QAnimationGroup::}{addAnimation()} or
- \l{QAnimationGroup::}{insertAnimationAt()}). The animation group
+ \l{QAnimationGroup::}{insertAnimation()}). The animation group
finishes when its last animation has finished.
At each moment there is at most one animation that is active in
@@ -59,16 +59,16 @@
A sequential animation group can be treated as any other
animation, i.e., it can be started, stopped, and added to other
- groups. You can also call addPause() or insertPauseAt() to add a
+ groups. You can also call addPause() or insertPause() to add a
pause to a sequential animation group.
\code
- QSequentialAnimationGroup group;
+ QSequentialAnimationGroup *group = new QSequentialAnimationGroup;
- group.addAnimation(anim1);
- group.addAnimation(anim2);
+ group->addAnimation(anim1);
+ group->addAnimation(anim2);
- group.start();
+ group->start();
\endcode
In this example, \c anim1 and \c anim2 are two already set up
@@ -269,7 +269,7 @@ QSequentialAnimationGroup::~QSequentialAnimationGroup()
\l{QAnimationGroup::animationCount()}{animationCount} will be
increased by one.
- \sa insertPauseAt(), QAnimationGroup::addAnimation()
+ \sa insertPause(), QAnimationGroup::addAnimation()
*/
QPauseAnimation *QSequentialAnimationGroup::addPause(int msecs)
{
@@ -282,19 +282,19 @@ QPauseAnimation *QSequentialAnimationGroup::addPause(int msecs)
Inserts a pause of \a msecs milliseconds at \a index in this animation
group.
- \sa addPause(), QAnimationGroup::insertAnimationAt()
+ \sa addPause(), QAnimationGroup::insertAnimation()
*/
-QPauseAnimation *QSequentialAnimationGroup::insertPauseAt(int index, int msecs)
+QPauseAnimation *QSequentialAnimationGroup::insertPause(int index, int msecs)
{
Q_D(const QSequentialAnimationGroup);
if (index < 0 || index > d->animations.size()) {
- qWarning("QSequentialAnimationGroup::insertPauseAt: index is out of bounds");
+ qWarning("QSequentialAnimationGroup::insertPause: index is out of bounds");
return 0;
}
QPauseAnimation *pause = new QPauseAnimation(msecs);
- insertAnimationAt(index, pause);
+ insertAnimation(index, pause);
return pause;
}
@@ -382,11 +382,11 @@ void QSequentialAnimationGroup::updateCurrentTime(int currentTime)
/*!
\reimp
*/
-void QSequentialAnimationGroup::updateState(QAbstractAnimation::State oldState,
- QAbstractAnimation::State newState)
+void QSequentialAnimationGroup::updateState(QAbstractAnimation::State newState,
+ QAbstractAnimation::State oldState)
{
Q_D(QSequentialAnimationGroup);
- QAnimationGroup::updateState(oldState, newState);
+ QAnimationGroup::updateState(newState, oldState);
if (!d->currentAnimation)
return;
@@ -532,7 +532,7 @@ void QSequentialAnimationGroupPrivate::animationInsertedAt(int index)
currentAnimationIndex = animations.indexOf(currentAnimation);
if (index < currentAnimationIndex || currentLoop != 0) {
- qWarning("QSequentialGroup::insertAnimationAt only supports to add animations after the current one.");
+ qWarning("QSequentialGroup::insertAnimation only supports to add animations after the current one.");
return; //we're not affected because it is added after the current one
}
}
diff --git a/src/corelib/animation/qsequentialanimationgroup.h b/src/corelib/animation/qsequentialanimationgroup.h
index f30f851f8b..97e7e01870 100644
--- a/src/corelib/animation/qsequentialanimationgroup.h
+++ b/src/corelib/animation/qsequentialanimationgroup.h
@@ -65,7 +65,7 @@ public:
~QSequentialAnimationGroup();
QPauseAnimation *addPause(int msecs);
- QPauseAnimation *insertPauseAt(int index, int msecs);
+ QPauseAnimation *insertPause(int index, int msecs);
QAbstractAnimation *currentAnimation() const;
int duration() const;
@@ -78,7 +78,7 @@ protected:
bool event(QEvent *event);
void updateCurrentTime(int);
- void updateState(QAbstractAnimation::State oldState, QAbstractAnimation::State newState);
+ void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
void updateDirection(QAbstractAnimation::Direction direction);
private:
diff --git a/src/corelib/animation/qvariantanimation.cpp b/src/corelib/animation/qvariantanimation.cpp
index de8185bcbb..c7357783f2 100644
--- a/src/corelib/animation/qvariantanimation.cpp
+++ b/src/corelib/animation/qvariantanimation.cpp
@@ -621,8 +621,8 @@ bool QVariantAnimation::event(QEvent *event)
/*!
\reimp
*/
-void QVariantAnimation::updateState(QAbstractAnimation::State oldState,
- QAbstractAnimation::State newState)
+void QVariantAnimation::updateState(QAbstractAnimation::State newState,
+ QAbstractAnimation::State oldState)
{
Q_UNUSED(oldState);
Q_UNUSED(newState);
diff --git a/src/corelib/animation/qvariantanimation.h b/src/corelib/animation/qvariantanimation.h
index bc57b1c076..89d9b3425c 100644
--- a/src/corelib/animation/qvariantanimation.h
+++ b/src/corelib/animation/qvariantanimation.h
@@ -103,7 +103,7 @@ protected:
bool event(QEvent *event);
void updateCurrentTime(int);
- void updateState(QAbstractAnimation::State oldState, QAbstractAnimation::State newState);
+ void updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState);
virtual void updateCurrentValue(const QVariant &value) = 0;
virtual QVariant interpolated(const QVariant &from, const QVariant &to, qreal progress) const;
diff --git a/src/corelib/arch/armv6/qatomic_generic_armv6.cpp b/src/corelib/arch/armv6/qatomic_generic_armv6.cpp
new file mode 100644
index 0000000000..3078662e90
--- /dev/null
+++ b/src/corelib/arch/armv6/qatomic_generic_armv6.cpp
@@ -0,0 +1,260 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+** This file implements the generic atomics interface using ARMv6 assembly
+** instructions. It is more efficent than the inline versions when Qt is
+** built for the THUMB instruction set, as the required instructions are
+** only available in ARM state.
+****************************************************************************/
+
+#include <QtCore/qglobal.h>
+
+#ifdef QT_HAVE_ARMV6
+
+QT_BEGIN_NAMESPACE
+
+QT_USE_NAMESPACE
+
+#ifdef Q_CC_RVCT
+#pragma push
+#pragma arm
+Q_CORE_EXPORT asm
+bool QBasicAtomicInt_testAndSetOrdered(volatile int *_q_value, int expectedValue, int newValue)
+{
+ CODE32
+ //R0 = _q_value
+ //R1 = expectedValue
+ //R2 = newValue
+retry_testAndSetOrdered
+ LDREX r3,[r0] //r3 = *_q_value
+ EORS r3,r3,r1 //if (r3 == expectedValue) {
+ STREXEQ r3,r2,[r0] //*_q_value = newvalue, r3 = error
+ TEQEQ r3,#1 //if error
+ BEQ retry_testAndSetOrdered //then goto retry }
+ RSBS r0,r3,#1 //return (r3 == 0)
+ MOVCC r0,#0
+ BX r14
+}
+
+Q_CORE_EXPORT asm
+int QBasicAtomicInt_fetchAndStoreOrdered(volatile int *_q_value, int newValue)
+{
+ CODE32
+//R0 = _q_value
+//R1 = newValue
+retry_fetchAndStoreOrdered
+ LDREX r3,[r0] //r3 = *_q_value
+ STREX r2,r1,[r0] //*_q_value = newValue, r2 = error
+ TEQ r2,#0 //if error
+ BNE retry_fetchAndStoreOrdered //then goto retry
+ MOV r0,r3 //return r3
+ BX r14
+}
+
+Q_CORE_EXPORT asm
+int QBasicAtomicInt_fetchAndAddOrdered(volatile int *_q_value, int valueToAdd)
+{
+ CODE32
+ //R0 = _q_value
+ //R1 = valueToAdd
+ STMDB sp!,{r12,lr}
+retry_fetchAndAddOrdered
+ LDREX r2,[r0] //r2 = *_q_value
+ ADD r3,r2,r1 //r3 = r2 + r1
+ STREX r12,r3,[r0] //*_q_value = r3, r12 = error
+ TEQ r12,#0 //if error
+ BNE retry_fetchAndAddOrdered //then retry
+ MOV r0,r2 //return r2
+ LDMIA sp!,{r12,pc}
+}
+
+Q_CORE_EXPORT asm
+bool QBasicAtomicPointer_testAndSetOrdered(void * volatile *_q_value,
+ void *expectedValue,
+ void *newValue)
+{
+ CODE32
+ //R0 = _q_value
+ //R1 = expectedValue
+ //R2 = newValue
+retryPointer_testAndSetOrdered
+ LDREX r3,[r0] //r3 = *_q_value
+ EORS r3,r3,r1 //if (r3 == expectedValue) {
+ STREXEQ r3,r2,[r0] //*_q_value = newvalue, r3 = error
+ TEQEQ r3,#1 //if error
+ BEQ retryPointer_testAndSetOrdered //then goto retry }
+ RSBS r0,r3,#1 //return (r3 == 0)
+ MOVCC r0,#0
+ BX r14
+}
+
+Q_CORE_EXPORT asm
+void *QBasicAtomicPointer_fetchAndStoreOrdered(void * volatile *_q_value, void *newValue)
+{
+ CODE32
+ //R0 = _q_value
+ //R1 = newValue
+retryPointer_fetchAndStoreOrdered
+ LDREX r3,[r0] //r3 = *_q_value
+ STREX r2,r1,[r0] //*_q_value = newValue, r2 = error
+ TEQ r2,#0 //if error
+ BNE retryPointer_fetchAndStoreOrdered //then goto retry
+ MOV r0,r3 //return r3
+ BX r14
+}
+
+Q_CORE_EXPORT asm
+void *QBasicAtomicPointer_fetchAndAddOrdered(void * volatile *_q_value, qptrdiff valueToAdd)
+{
+ CODE32
+ //R0 = _q_value
+ //R1 = valueToAdd
+ STMDB sp!,{r12,lr}
+retryPointer_fetchAndAddOrdered
+ LDREX r2,[r0] //r2 = *_q_value
+ ADD r3,r2,r1 //r3 = r2 + r1
+ STREX r12,r3,[r0] //*_q_value = r3, r12 = error
+ TEQ r12,#0 //if error
+ BNE retryPointer_fetchAndAddOrdered //then retry
+ MOV r0,r2 //return r2
+ LDMIA sp!,{r12,pc}
+}
+
+#pragma pop
+#elif defined (Q_CC_GCCE)
+Q_CORE_EXPORT __declspec( naked )
+bool QBasicAtomicInt_testAndSetOrdered(volatile int *_q_value, int expectedValue, int newValue)
+{
+ //R0 = _q_value
+ //R1 = expectedValue
+ //R2 = newValue
+ asm("retry_testAndSetOrdered:");
+ asm(" LDREX r3,[r0]"); //r3 = *_q_value
+ asm(" EORS r3,r3,r1"); //if (r3 == expectedValue) {
+ asm(" STREXEQ r3,r2,[r0]"); //*_q_value = newvalue, r3 = error
+ asm(" TEQEQ r3,#1"); //if error
+ asm(" BEQ retry_testAndSetOrdered"); //then goto retry }
+ asm(" RSBS r0,r3,#1"); //return (r3 == 0)
+ asm(" MOVCC r0,#0");
+ asm(" BX r14");
+}
+
+Q_CORE_EXPORT __declspec( naked )
+int QBasicAtomicInt_fetchAndStoreOrdered(volatile int *_q_value, int newValue)
+{
+//R0 = _q_value
+//R1 = newValue
+ asm("retry_fetchAndStoreOrdered:");
+ asm(" LDREX r3,[r0]"); //r3 = *_q_value
+ asm(" STREX r2,r1,[r0]"); //*_q_value = newValue, r2 = error
+ asm(" TEQ r2,#0"); //if error
+ asm(" BNE retry_fetchAndStoreOrdered"); //then goto retry
+ asm(" MOV r0,r3"); //return r3
+ asm(" BX r14");
+}
+
+Q_CORE_EXPORT __declspec( naked )
+int QBasicAtomicInt_fetchAndAddOrdered(volatile int *_q_value, int valueToAdd)
+{
+ //R0 = _q_value
+ //R1 = valueToAdd
+ asm(" STMDB sp!,{r12,lr}");
+ asm("retry_fetchAndAddOrdered:");
+ asm(" LDREX r2,[r0]"); //r2 = *_q_value
+ asm(" ADD r3,r2,r1 "); //r3 = r2 + r1
+ asm(" STREX r12,r3,[r0]"); //*_q_value = r3, r12 = error
+ asm(" TEQ r12,#0"); //if error
+ asm(" BNE retry_fetchAndAddOrdered"); //then retry
+ asm(" MOV r0,r2"); //return r2
+ asm(" LDMIA sp!,{r12,pc}");
+}
+
+Q_CORE_EXPORT __declspec( naked )
+bool QBasicAtomicPointer_testAndSetOrdered(void * volatile *_q_value,
+ void *expectedValue,
+ void *newValue)
+{
+ //R0 = _q_value
+ //R1 = expectedValue
+ //R2 = newValue
+ asm("retryPointer_testAndSetOrdered:");
+ asm(" LDREX r3,[r0]"); //r3 = *_q_value
+ asm(" EORS r3,r3,r1"); //if (r3 == expectedValue) {
+ asm(" STREXEQ r3,r2,[r0]"); //*_q_value = newvalue, r3 = error
+ asm(" TEQEQ r3,#1"); //if error
+ asm(" BEQ retryPointer_testAndSetOrdered"); //then goto retry }
+ asm(" RSBS r0,r3,#1"); //return (r3 == 0)
+ asm(" MOVCC r0,#0");
+ asm(" BX r14");
+}
+
+Q_CORE_EXPORT __declspec( naked )
+void *QBasicAtomicPointer_fetchAndStoreOrdered(void * volatile *_q_value, void *newValue)
+{
+ //R0 = _q_value
+ //R1 = newValue
+ asm("retryPointer_fetchAndStoreOrdered:");
+ asm(" LDREX r3,[r0]"); //r3 = *_q_value
+ asm(" STREX r2,r1,[r0]"); //*_q_value = newValue, r2 = error
+ asm(" TEQ r2,#0"); //if error
+ asm(" BNE retryPointer_fetchAndStoreOrdered"); //then goto retry
+ asm(" MOV r0,r3"); //return r3
+ asm(" BX r14");
+}
+
+Q_CORE_EXPORT __declspec( naked )
+void *QBasicAtomicPointer_fetchAndAddOrdered(void * volatile *_q_value, qptrdiff valueToAdd)
+{
+ //R0 = _q_value
+ //R1 = valueToAdd
+ asm(" STMDB sp!,{r12,lr}");
+ asm("retryPointer_fetchAndAddOrdered:");
+ asm(" LDREX r2,[r0]"); //r2 = *_q_value
+ asm(" ADD r3,r2,r1"); //r3 = r2 + r1
+ asm(" STREX r12,r3,[r0]"); //*_q_value = r3, r12 = error
+ asm(" TEQ r12,#0"); //if error
+ asm(" BNE retryPointer_fetchAndAddOrdered"); //then retry
+ asm(" MOV r0,r2"); //return r2
+ asm(" LDMIA sp!,{r12,pc}");
+}
+#else
+#error unknown arm compiler
+#endif
+QT_END_NAMESPACE
+#endif
diff --git a/src/corelib/arch/qatomic_armv6.h b/src/corelib/arch/qatomic_armv6.h
index 6862638090..1e9f0c4e30 100644
--- a/src/corelib/arch/qatomic_armv6.h
+++ b/src/corelib/arch/qatomic_armv6.h
@@ -45,7 +45,6 @@
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
-
#define Q_ATOMIC_INT_REFERENCE_COUNTING_IS_ALWAYS_NATIVE
inline bool QBasicAtomicInt::isReferenceCountingNative()
@@ -101,6 +100,8 @@ template <typename T>
Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::isFetchAndAddWaitFree()
{ return false; }
+#ifndef Q_CC_RVCT
+
inline bool QBasicAtomicInt::ref()
{
register int newValue;
@@ -155,21 +156,6 @@ inline bool QBasicAtomicInt::testAndSetOrdered(int expectedValue, int newValue)
return result == 0;
}
-inline bool QBasicAtomicInt::testAndSetRelaxed(int expectedValue, int newValue)
-{
- return testAndSetOrdered(expectedValue, newValue);
-}
-
-inline bool QBasicAtomicInt::testAndSetAcquire(int expectedValue, int newValue)
-{
- return testAndSetOrdered(expectedValue, newValue);
-}
-
-inline bool QBasicAtomicInt::testAndSetRelease(int expectedValue, int newValue)
-{
- return testAndSetOrdered(expectedValue, newValue);
-}
-
inline int QBasicAtomicInt::fetchAndStoreOrdered(int newValue)
{
register int originalValue;
@@ -188,21 +174,6 @@ inline int QBasicAtomicInt::fetchAndStoreOrdered(int newValue)
return originalValue;
}
-inline int QBasicAtomicInt::fetchAndStoreRelaxed(int newValue)
-{
- return fetchAndStoreOrdered(newValue);
-}
-
-inline int QBasicAtomicInt::fetchAndStoreAcquire(int newValue)
-{
- return fetchAndStoreOrdered(newValue);
-}
-
-inline int QBasicAtomicInt::fetchAndStoreRelease(int newValue)
-{
- return fetchAndStoreOrdered(newValue);
-}
-
inline int QBasicAtomicInt::fetchAndAddOrdered(int valueToAdd)
{
register int originalValue;
@@ -224,21 +195,6 @@ inline int QBasicAtomicInt::fetchAndAddOrdered(int valueToAdd)
return originalValue;
}
-inline int QBasicAtomicInt::fetchAndAddRelaxed(int valueToAdd)
-{
- return fetchAndAddOrdered(valueToAdd);
-}
-
-inline int QBasicAtomicInt::fetchAndAddAcquire(int valueToAdd)
-{
- return fetchAndAddOrdered(valueToAdd);
-}
-
-inline int QBasicAtomicInt::fetchAndAddRelease(int valueToAdd)
-{
- return fetchAndAddOrdered(valueToAdd);
-}
-
template <typename T>
Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetOrdered(T *expectedValue, T *newValue)
{
@@ -259,24 +215,6 @@ Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetOrdered(T *expectedValu
}
template <typename T>
-Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelaxed(T *expectedValue, T *newValue)
-{
- return testAndSetOrdered(expectedValue, newValue);
-}
-
-template <typename T>
-Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetAcquire(T *expectedValue, T *newValue)
-{
- return testAndSetOrdered(expectedValue, newValue);
-}
-
-template <typename T>
-Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelease(T *expectedValue, T *newValue)
-{
- return testAndSetOrdered(expectedValue, newValue);
-}
-
-template <typename T>
Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreOrdered(T *newValue)
{
register T *originalValue;
@@ -296,24 +234,6 @@ Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreOrdered(T *newValue)
}
template <typename T>
-Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreRelaxed(T *newValue)
-{
- return fetchAndStoreOrdered(newValue);
-}
-
-template <typename T>
-Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreAcquire(T *newValue)
-{
- return fetchAndStoreOrdered(newValue);
-}
-
-template <typename T>
-Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreRelease(T *newValue)
-{
- return fetchAndStoreOrdered(newValue);
-}
-
-template <typename T>
Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddOrdered(qptrdiff valueToAdd)
{
register T *originalValue;
@@ -335,6 +255,226 @@ Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddOrdered(qptrdiff valueTo
return originalValue;
}
+#else
+// This is Q_CC_RVCT
+
+// RVCT inline assembly documentation:
+// http://www.keil.com/support/man/docs/armcc/armcc_chdcffdb.htm
+// RVCT embedded assembly documentation:
+// http://www.keil.com/support/man/docs/armcc/armcc_chddbeib.htm
+
+// save our pragma state and switch to ARM mode
+#pragma push
+#pragma arm
+
+inline bool QBasicAtomicInt::ref()
+{
+ register int newValue;
+ register int result;
+ retry:
+ __asm {
+ ldrex newValue, [&_q_value]
+ add newValue, newValue, #1
+ strex result, newValue, [&_q_value]
+ teq result, #0
+ bne retry
+ }
+ return newValue != 0;
+}
+
+inline bool QBasicAtomicInt::deref()
+{
+ register int newValue;
+ register int result;
+ retry:
+ __asm {
+ ldrex newValue, [&_q_value]
+ sub newValue, newValue, #1
+ strex result, newValue, [&_q_value]
+ teq result, #0
+ bne retry
+ }
+ return newValue != 0;
+}
+
+inline bool QBasicAtomicInt::testAndSetOrdered(int expectedValue, int newValue)
+{
+ register int result;
+ retry:
+ __asm {
+ ldrex result, [&_q_value]
+ eors result, result, expectedValue
+ strexeq result, newValue, [&_q_value]
+ teqeq result, #1
+ beq retry
+ }
+ return result == 0;
+}
+
+inline int QBasicAtomicInt::fetchAndStoreOrdered(int newValue)
+{
+ register int originalValue;
+ register int result;
+ retry:
+ __asm {
+ ldrex originalValue, [&_q_value]
+ strex result, newValue, [&_q_value]
+ teq result, #0
+ bne retry
+ }
+ return originalValue;
+}
+
+inline int QBasicAtomicInt::fetchAndAddOrdered(int valueToAdd)
+{
+ register int originalValue;
+ register int newValue;
+ register int result;
+ retry:
+ __asm {
+ ldrex originalValue, [&_q_value]
+ add newValue, originalValue, valueToAdd
+ strex result, newValue, [&_q_value]
+ teq result, #0
+ bne retry
+ }
+ return originalValue;
+}
+
+template <typename T>
+Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetOrdered(T *expectedValue, T *newValue)
+{
+ register T *result;
+ retry:
+ __asm {
+ ldrex result, [&_q_value]
+ eors result, result, expectedValue
+ strexeq result, newValue, [&_q_value]
+ teqeq result, #1
+ beq retry
+ }
+ return result == 0;
+}
+
+template <typename T>
+Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreOrdered(T *newValue)
+{
+ register T *originalValue;
+ register int result;
+ retry:
+ __asm {
+ ldrex originalValue, [&_q_value]
+ strex result, newValue, [&_q_value]
+ teq result, #0
+ bne retry
+ }
+ return originalValue;
+}
+
+template <typename T>
+Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddOrdered(qptrdiff valueToAdd)
+{
+ register T *originalValue;
+ register T *newValue;
+ register int result;
+ retry:
+ __asm {
+ ldrex originalValue, [&_q_value]
+ add newValue, originalValue, valueToAdd * sizeof(T)
+ strex result, newValue, [&_q_value]
+ teq result, #0
+ bne retry
+ }
+ return originalValue;
+}
+
+// go back to the previous pragma state (probably Thumb mode)
+#pragma pop
+#endif
+
+// common code
+
+inline bool QBasicAtomicInt::testAndSetRelaxed(int expectedValue, int newValue)
+{
+ return testAndSetOrdered(expectedValue, newValue);
+}
+
+inline bool QBasicAtomicInt::testAndSetAcquire(int expectedValue, int newValue)
+{
+ return testAndSetOrdered(expectedValue, newValue);
+}
+
+inline bool QBasicAtomicInt::testAndSetRelease(int expectedValue, int newValue)
+{
+ return testAndSetOrdered(expectedValue, newValue);
+}
+
+inline int QBasicAtomicInt::fetchAndStoreRelaxed(int newValue)
+{
+ return fetchAndStoreOrdered(newValue);
+}
+
+inline int QBasicAtomicInt::fetchAndStoreAcquire(int newValue)
+{
+ return fetchAndStoreOrdered(newValue);
+}
+
+inline int QBasicAtomicInt::fetchAndStoreRelease(int newValue)
+{
+ return fetchAndStoreOrdered(newValue);
+}
+
+inline int QBasicAtomicInt::fetchAndAddRelaxed(int valueToAdd)
+{
+ return fetchAndAddOrdered(valueToAdd);
+}
+
+inline int QBasicAtomicInt::fetchAndAddAcquire(int valueToAdd)
+{
+ return fetchAndAddOrdered(valueToAdd);
+}
+
+inline int QBasicAtomicInt::fetchAndAddRelease(int valueToAdd)
+{
+ return fetchAndAddOrdered(valueToAdd);
+}
+
+template <typename T>
+Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelaxed(T *expectedValue, T *newValue)
+{
+ return testAndSetOrdered(expectedValue, newValue);
+}
+
+template <typename T>
+Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetAcquire(T *expectedValue, T *newValue)
+{
+ return testAndSetOrdered(expectedValue, newValue);
+}
+
+template <typename T>
+Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelease(T *expectedValue, T *newValue)
+{
+ return testAndSetOrdered(expectedValue, newValue);
+}
+
+template <typename T>
+Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreRelaxed(T *newValue)
+{
+ return fetchAndStoreOrdered(newValue);
+}
+
+template <typename T>
+Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreAcquire(T *newValue)
+{
+ return fetchAndStoreOrdered(newValue);
+}
+
+template <typename T>
+Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreRelease(T *newValue)
+{
+ return fetchAndStoreOrdered(newValue);
+}
+
template <typename T>
Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddRelaxed(qptrdiff valueToAdd)
{
diff --git a/src/corelib/arch/qatomic_symbian.h b/src/corelib/arch/qatomic_symbian.h
index 5880120871..92f6ef99d8 100644
--- a/src/corelib/arch/qatomic_symbian.h
+++ b/src/corelib/arch/qatomic_symbian.h
@@ -42,14 +42,243 @@
#ifndef QATOMIC_SYMBIAN_H
#define QATOMIC_SYMBIAN_H
+#include <qglobal.h>
+#include <e32std.h>
+
QT_BEGIN_HEADER
-#if defined(Q_CC_RVCT)
-# define QT_NO_ARM_EABI
-# include <QtCore/qatomic_arm.h>
-#elif defined(Q_CC_NOKIAX86) || defined(Q_CC_GCCE)
-# include <QtCore/qatomic_generic.h>
-#endif
+QT_BEGIN_NAMESPACE
+
+QT_MODULE(Core)
+
+#define Q_ATOMIC_INT_REFERENCE_COUNTING_IS_SOMETIMES_NATIVE
+
+inline bool QBasicAtomicInt::isReferenceCountingWaitFree()
+{ return false; }
+
+#define Q_ATOMIC_INT_TEST_AND_SET_IS_SOMETIMES_NATIVE
+
+inline bool QBasicAtomicInt::isTestAndSetWaitFree()
+{ return false; }
+
+#define Q_ATOMIC_INT_FETCH_AND_STORE_IS_SOMETIMES_NATIVE
+
+inline bool QBasicAtomicInt::isFetchAndStoreWaitFree()
+{ return false; }
+
+#define Q_ATOMIC_INT_FETCH_AND_ADD_IS_SOMETIMES_NATIVE
+
+inline bool QBasicAtomicInt::isFetchAndAddWaitFree()
+{ return false; }
+
+#define Q_ATOMIC_POINTER_TEST_AND_SET_IS_SOMETIMES_NATIVE
+
+Q_CORE_EXPORT bool QBasicAtomicPointer_isTestAndSetNative();
+template <typename T>
+Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::isTestAndSetNative()
+{ return QBasicAtomicPointer_isTestAndSetNative(); }
+template <typename T>
+Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::isTestAndSetWaitFree()
+{ return false; }
+
+#define Q_ATOMIC_POINTER_FETCH_AND_STORE_IS_SOMETIMES_NATIVE
+
+Q_CORE_EXPORT bool QBasicAtomicPointer_isFetchAndStoreNative();
+template <typename T>
+Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::isFetchAndStoreNative()
+{ return QBasicAtomicPointer_isFetchAndStoreNative(); }
+template <typename T>
+Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::isFetchAndStoreWaitFree()
+{ return false; }
+
+#define Q_ATOMIC_POINTER_FETCH_AND_ADD_IS_SOMETIMES_NATIVE
+
+Q_CORE_EXPORT bool QBasicAtomicPointer_isFetchAndAddNative();
+template <typename T>
+Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::isFetchAndAddNative()
+{ return QBasicAtomicPointer_isFetchAndAddNative(); }
+template <typename T>
+Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::isFetchAndAddWaitFree()
+{ return false; }
+
+Q_CORE_EXPORT bool QBasicAtomicInt_testAndSetOrdered(volatile int *, int, int);
+Q_CORE_EXPORT int QBasicAtomicInt_fetchAndStoreOrdered(volatile int *, int);
+Q_CORE_EXPORT int QBasicAtomicInt_fetchAndAddOrdered(volatile int *, int);
+
+Q_CORE_EXPORT bool QBasicAtomicPointer_testAndSetOrdered(void * volatile *, void *, void *);
+Q_CORE_EXPORT void *QBasicAtomicPointer_fetchAndStoreOrdered(void * volatile *, void *);
+Q_CORE_EXPORT void *QBasicAtomicPointer_fetchAndAddOrdered(void * volatile *, qptrdiff);
+
+// Reference counting
+
+//LockedInc and LockedDec are machine coded for ARMv6 (and future proof)
+inline bool QBasicAtomicInt::ref()
+{
+ int original = User::LockedInc((TInt&)_q_value);
+ return original != -1;
+}
+
+inline bool QBasicAtomicInt::deref()
+{
+ int original = User::LockedDec((TInt&)_q_value);
+ return original != 1;
+}
+
+// Test and set for integers
+
+inline bool QBasicAtomicInt::testAndSetOrdered(int expectedValue, int newValue)
+{
+ return QBasicAtomicInt_testAndSetOrdered(&_q_value, expectedValue, newValue);
+}
+
+inline bool QBasicAtomicInt::testAndSetRelaxed(int expectedValue, int newValue)
+{
+ return testAndSetOrdered(expectedValue, newValue);
+}
+
+inline bool QBasicAtomicInt::testAndSetAcquire(int expectedValue, int newValue)
+{
+ return testAndSetOrdered(expectedValue, newValue);
+}
+
+inline bool QBasicAtomicInt::testAndSetRelease(int expectedValue, int newValue)
+{
+ return testAndSetOrdered(expectedValue, newValue);
+}
+
+// Fetch and store for integers
+
+inline int QBasicAtomicInt::fetchAndStoreOrdered(int newValue)
+{
+ return QBasicAtomicInt_fetchAndStoreOrdered(&_q_value, newValue);
+}
+
+inline int QBasicAtomicInt::fetchAndStoreRelaxed(int newValue)
+{
+ return fetchAndStoreOrdered(newValue);
+}
+
+inline int QBasicAtomicInt::fetchAndStoreAcquire(int newValue)
+{
+ return fetchAndStoreOrdered(newValue);
+}
+
+inline int QBasicAtomicInt::fetchAndStoreRelease(int newValue)
+{
+ return fetchAndStoreOrdered(newValue);
+}
+
+// Fetch and add for integers
+
+inline int QBasicAtomicInt::fetchAndAddOrdered(int valueToAdd)
+{
+ return QBasicAtomicInt_fetchAndAddOrdered(&_q_value, valueToAdd);
+}
+
+inline int QBasicAtomicInt::fetchAndAddRelaxed(int valueToAdd)
+{
+ return fetchAndAddOrdered(valueToAdd);
+}
+
+inline int QBasicAtomicInt::fetchAndAddAcquire(int valueToAdd)
+{
+ return fetchAndAddOrdered(valueToAdd);
+}
+
+inline int QBasicAtomicInt::fetchAndAddRelease(int valueToAdd)
+{
+ return fetchAndAddOrdered(valueToAdd);
+}
+
+// Test and set for pointers
+
+template <typename T>
+Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetOrdered(T *expectedValue, T *newValue)
+{
+ union { T * volatile * typed; void * volatile * voidp; } pointer;
+ pointer.typed = &_q_value;
+ return QBasicAtomicPointer_testAndSetOrdered(pointer.voidp, expectedValue, newValue);
+}
+
+template <typename T>
+Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelaxed(T *expectedValue, T *newValue)
+{
+ return testAndSetOrdered(expectedValue, newValue);
+}
+
+template <typename T>
+Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetAcquire(T *expectedValue, T *newValue)
+{
+ return testAndSetOrdered(expectedValue, newValue);
+}
+
+template <typename T>
+Q_INLINE_TEMPLATE bool QBasicAtomicPointer<T>::testAndSetRelease(T *expectedValue, T *newValue)
+{
+ return testAndSetOrdered(expectedValue, newValue);
+}
+
+// Fetch and store for pointers
+
+template <typename T>
+Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreOrdered(T *newValue)
+{
+ union { T * volatile * typed; void * volatile * voidp; } pointer;
+ union { T *typed; void *voidp; } returnValue;
+ pointer.typed = &_q_value;
+ returnValue.voidp = QBasicAtomicPointer_fetchAndStoreOrdered(pointer.voidp, newValue);
+ return returnValue.typed;
+}
+
+template <typename T>
+Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreRelaxed(T *newValue)
+{
+ return fetchAndStoreOrdered(newValue);
+}
+
+template <typename T>
+Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreAcquire(T *newValue)
+{
+ return fetchAndStoreOrdered(newValue);
+}
+
+template <typename T>
+Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndStoreRelease(T *newValue)
+{
+ return fetchAndStoreOrdered(newValue);
+}
+
+// Fetch and add for pointers
+
+template <typename T>
+Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddOrdered(qptrdiff valueToAdd)
+{
+ union { T * volatile *typed; void * volatile *voidp; } pointer;
+ union { T *typed; void *voidp; } returnValue;
+ pointer.typed = &_q_value;
+ returnValue.voidp = QBasicAtomicPointer_fetchAndAddOrdered(pointer.voidp, valueToAdd * sizeof(T));
+ return returnValue.typed;
+}
+
+template <typename T>
+Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddRelaxed(qptrdiff valueToAdd)
+{
+ return fetchAndAddOrdered(valueToAdd);
+}
+
+template <typename T>
+Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddAcquire(qptrdiff valueToAdd)
+{
+ return fetchAndAddOrdered(valueToAdd);
+}
+
+template <typename T>
+Q_INLINE_TEMPLATE T *QBasicAtomicPointer<T>::fetchAndAddRelease(qptrdiff valueToAdd)
+{
+ return fetchAndAddOrdered(valueToAdd);
+}
+
+QT_END_NAMESPACE
QT_END_HEADER
diff --git a/src/corelib/arch/symbian/arch.pri b/src/corelib/arch/symbian/arch.pri
index deb94b15e7..3ef1c9e6a9 100644
--- a/src/corelib/arch/symbian/arch.pri
+++ b/src/corelib/arch/symbian/arch.pri
@@ -2,4 +2,4 @@
# Symbian architecture
#
SOURCES += $$QT_ARCH_CPP/qatomic_symbian.cpp \
- $$QT_ARCH_CPP/../generic/qatomic_generic_unix.cpp
+ $$QT_ARCH_CPP/../armv6/qatomic_generic_armv6.cpp
diff --git a/src/corelib/arch/symbian/qatomic_symbian.cpp b/src/corelib/arch/symbian/qatomic_symbian.cpp
index 8f0215544a..91b49c7426 100644
--- a/src/corelib/arch/symbian/qatomic_symbian.cpp
+++ b/src/corelib/arch/symbian/qatomic_symbian.cpp
@@ -50,7 +50,7 @@ QT_BEGIN_NAMESPACE
// This way we can report on heap cells and handles that are really not owned by anything which still exists.
// This information can be used to detect whether memory leaks are happening, particularly if these numbers grow as the app is used more.
// This code is placed here as it happens to make it the very last static to be destroyed in a Qt app. The
-// reason assumed is that this file appears before any other file declaring static data in the generated
+// reason assumed is that this file appears before any other file declaring static data in the generated
// Symbian MMP file. This particular file was chosen as it is the earliest symbian specific file.
struct QSymbianPrintExitInfo
{
@@ -77,37 +77,158 @@ struct QSymbianPrintExitInfo
TInt initThreadHandleCount;
} symbian_printExitInfo;
-QT_END_NAMESPACE
+Q_CORE_EXPORT bool QBasicAtomicInt::isReferenceCountingNative()
+{
+#ifdef QT_HAVE_ARMV6
+ return true;
+#else
+ return false;
+#endif
+}
+Q_CORE_EXPORT bool QBasicAtomicInt::isTestAndSetNative()
+{
+#ifdef QT_HAVE_ARMV6
+ return true;
+#else
+ return false;
+#endif
+}
-#if defined(Q_CC_RVCT)
+Q_CORE_EXPORT bool QBasicAtomicInt::isFetchAndStoreNative()
+{
+#ifdef QT_HAVE_ARMV6
+ return true;
+#else
+ return false;
+#endif
+}
-#include "../arm/qatomic_arm.cpp"
+Q_CORE_EXPORT bool QBasicAtomicInt::isFetchAndAddNative()
+{
+#ifdef QT_HAVE_ARMV6
+ return true;
+#else
+ return false;
+#endif
+}
-QT_BEGIN_NAMESPACE
+Q_CORE_EXPORT bool QBasicAtomicPointer_isTestAndSetNative()
+{
+#ifdef QT_HAVE_ARMV6
+ return true;
+#else
+ return false;
+#endif
+}
-Q_CORE_EXPORT __asm char q_atomic_swp(volatile char *ptr, char newval)
+Q_CORE_EXPORT bool QBasicAtomicPointer_isFetchAndStoreNative()
{
- add r2, pc, #0
- bx r2
- arm
- swpb r2,r1,[r0]
- mov r0, r2
- bx lr
- thumb
+#ifdef QT_HAVE_ARMV6
+ return true;
+#else
+ return false;
+#endif
}
-Q_CORE_EXPORT __asm int QBasicAtomicInt::fetchAndStoreOrdered(int newValue)
+Q_CORE_EXPORT bool QBasicAtomicPointer_isFetchAndAddNative()
{
- add r2, pc, #0
- bx r2
- arm
- swp r2,r1,[r0]
- mov r0, r2
- bx lr
- thumb
+#ifdef QT_HAVE_ARMV6
+ return true;
+#else
+ return false;
+#endif
}
-QT_END_NAMESPACE
+//For ARMv6, the generic atomics are machine coded
+#ifndef QT_HAVE_ARMV6
+
+class QCriticalSection
+{
+public:
+ QCriticalSection() { fastlock.CreateLocal(); }
+ ~QCriticalSection() { fastlock.Close(); }
+ void lock() { fastlock.Wait(); }
+ void unlock() { fastlock.Signal(); }
-#endif // Q_CC_RVCT
+private:
+ RFastLock fastlock;
+};
+
+QCriticalSection qAtomicCriticalSection;
+
+Q_CORE_EXPORT
+bool QBasicAtomicInt_testAndSetOrdered(volatile int *_q_value, int expectedValue, int newValue)
+{
+ bool returnValue = false;
+ qAtomicCriticalSection.lock();
+ if (*_q_value == expectedValue) {
+ *_q_value = newValue;
+ returnValue = true;
+ }
+ qAtomicCriticalSection.unlock();
+ return returnValue;
+}
+
+Q_CORE_EXPORT
+int QBasicAtomicInt_fetchAndStoreOrdered(volatile int *_q_value, int newValue)
+{
+ int returnValue;
+ qAtomicCriticalSection.lock();
+ returnValue = *_q_value;
+ *_q_value = newValue;
+ qAtomicCriticalSection.unlock();
+ return returnValue;
+}
+
+Q_CORE_EXPORT
+int QBasicAtomicInt_fetchAndAddOrdered(volatile int *_q_value, int valueToAdd)
+{
+ int returnValue;
+ qAtomicCriticalSection.lock();
+ returnValue = *_q_value;
+ *_q_value += valueToAdd;
+ qAtomicCriticalSection.unlock();
+ return returnValue;
+}
+
+Q_CORE_EXPORT
+bool QBasicAtomicPointer_testAndSetOrdered(void * volatile *_q_value,
+ void *expectedValue,
+ void *newValue)
+{
+ bool returnValue = false;
+ qAtomicCriticalSection.lock();
+ if (*_q_value == expectedValue) {
+ *_q_value = newValue;
+ returnValue = true;
+ }
+ qAtomicCriticalSection.unlock();
+ return returnValue;
+}
+
+Q_CORE_EXPORT
+void *QBasicAtomicPointer_fetchAndStoreOrdered(void * volatile *_q_value, void *newValue)
+{
+ void *returnValue;
+ qAtomicCriticalSection.lock();
+ returnValue = *_q_value;
+ *_q_value = newValue;
+ qAtomicCriticalSection.unlock();
+ return returnValue;
+}
+
+Q_CORE_EXPORT
+void *QBasicAtomicPointer_fetchAndAddOrdered(void * volatile *_q_value, qptrdiff valueToAdd)
+{
+ void *returnValue;
+ qAtomicCriticalSection.lock();
+ returnValue = *_q_value;
+ *_q_value = reinterpret_cast<char *>(returnValue) + valueToAdd;
+ qAtomicCriticalSection.unlock();
+ return returnValue;
+}
+
+#endif // QT_HAVE_ARMV6
+
+QT_END_NAMESPACE
diff --git a/src/corelib/corelib.pro b/src/corelib/corelib.pro
index f835bee564..9a15bf12c5 100644
--- a/src/corelib/corelib.pro
+++ b/src/corelib/corelib.pro
@@ -35,4 +35,4 @@ symbian: {
# Workaroud for problems with paging this dll
MMP_RULES -= PAGED
MMP_RULES *= UNPAGED
-} \ No newline at end of file
+}
diff --git a/src/corelib/eval.pri b/src/corelib/eval.pri
new file mode 100644
index 0000000000..efda56b16a
--- /dev/null
+++ b/src/corelib/eval.pri
@@ -0,0 +1,4 @@
+SOURCES += \
+ $$QT_SOURCE_TREE/src/corelib/kernel/qtcore_eval.cpp
+INCLUDEPATH += \
+ $$QT_BUILD_TREE/src/corelib/global
diff --git a/src/corelib/global/global.pri b/src/corelib/global/global.pri
index 0fe757d281..b916b4d950 100644
--- a/src/corelib/global/global.pri
+++ b/src/corelib/global/global.pri
@@ -19,7 +19,7 @@ INCLUDEPATH += $$QT_BUILD_TREE/src/corelib/global
# Only used on platforms with CONFIG += precompile_header
PRECOMPILED_HEADER = global/qt_pch.h
-linux-g++*:!static {
+linux*-g++*:!static {
QMAKE_LFLAGS += -Wl,-e,qt_core_boilerplate
prog=$$quote(if (/program interpreter: (.*)]/) { print $1; })
DEFINES += ELF_INTERPRETER=\\\"$$system(readelf -l /bin/ls | perl -n -e \'$$prog\')\\\"
diff --git a/src/corelib/global/qconfig-minimal.h b/src/corelib/global/qconfig-minimal.h
index 3d9539ed24..58565d6a37 100644
--- a/src/corelib/global/qconfig-minimal.h
+++ b/src/corelib/global/qconfig-minimal.h
@@ -123,9 +123,6 @@
#endif
/* Images */
-#ifndef QT_NO_ICON
-# define QT_NO_ICON
-#endif
#ifndef QT_NO_IMAGEFORMATPLUGIN
# define QT_NO_IMAGEFORMATPLUGIN
#endif
@@ -258,9 +255,6 @@
#ifndef QT_NO_TEXTHTMLPARSER
# define QT_NO_TEXTHTMLPARSER
#endif
-#ifndef QT_NO_THREAD
-# define QT_NO_THREAD
-#endif
#ifndef QT_NO_CONCURRENT
# define QT_NO_CONCURRENT
#endif
diff --git a/src/corelib/global/qfeatures.h b/src/corelib/global/qfeatures.h
index 36c2cf936c..1c52d4cf62 100644
--- a/src/corelib/global/qfeatures.h
+++ b/src/corelib/global/qfeatures.h
@@ -43,6 +43,7 @@
* All features and their dependencies.
*
* This list is generated from $QTDIR/src/corelib/global/qfeatures.txt
+ * by $QTSRCDIR/util/scripts/make_qfeatures_dot_h
*/
// QAction
@@ -54,6 +55,9 @@
// Color Names
//#define QT_NO_COLORNAMES
+// QtConcurrent
+//#define QT_NO_CONCURRENT
+
// QCopChannel
//#define QT_NO_COP
@@ -75,15 +79,15 @@
// Effects
//#define QT_NO_EFFECTS
+// QFileSystemWatcher
+//#define QT_NO_FILESYSTEMWATCHER
+
// Freetype Font Engine
//#define QT_NO_FREETYPE
// QGroupBox
//#define QT_NO_GROUPBOX
-// QIcon
-//#define QT_NO_ICON
-
// QImageIOPlugin
//#define QT_NO_IMAGEFORMATPLUGIN
@@ -147,15 +151,15 @@
// Phonon::ObjectDescriptionModel
//#define QT_NO_PHONON_OBJECTDESCRIPTIONMODEL
-// Phonon::PlatformPlugin
-//#define QT_NO_PHONON_PLATFORMPLUGIN
-
// Phonon::VideoWidget
//#define QT_NO_PHONON_VIDEO
// QPicture
//#define QT_NO_PICTURE
+// QProcess
+//#define QT_NO_PROCESS
+
// QProgressBar
//#define QT_NO_PROGRESSBAR
@@ -174,9 +178,6 @@
// Decoration
//#define QT_NO_QWS_DECORATION_DEFAULT
-// QWSInputMethod
-//#define QT_NO_QWS_INPUTMETHODS
-
// Keyboard
//#define QT_NO_QWS_KEYBOARD
@@ -216,6 +217,9 @@
// Session Manager
//#define QT_NO_SESSIONMANAGER
+// QSettings
+//#define QT_NO_SETTINGS
+
// QSharedMemory
//#define QT_NO_SHAREDMEMORY
@@ -261,6 +265,9 @@
// QSystemSemaphore
//#define QT_NO_SYSTEMSEMAPHORE
+// QSystemTrayIcon
+//#define QT_NO_SYSTEMTRAYICON
+
// QTabletEvent
//#define QT_NO_TABLETEVENT
@@ -279,9 +286,6 @@
// QTextStream
//#define QT_NO_TEXTSTREAM
-// QThread
-//#define QT_NO_THREAD
-
// QToolTip
//#define QT_NO_TOOLTIP
@@ -306,11 +310,6 @@
//
//#define QT_NO_XMLSTREAM
-// Accessibility
-#if !defined(QT_NO_ACCESSIBILITY) && (defined(QT_NO_PROPERTIES))
-#define QT_NO_ACCESSIBILITY
-#endif
-
// Animation
#if !defined(QT_NO_ANIMATION) && (defined(QT_NO_PROPERTIES))
#define QT_NO_ANIMATION
@@ -331,11 +330,6 @@
#define QT_NO_CODECS
#endif
-// QtConcurrent
-#if !defined(QT_NO_CONCURRENT) && (defined(QT_NO_THREAD))
-#define QT_NO_CONCURRENT
-#endif
-
// QDate/QTime/QDateTime
#if !defined(QT_NO_DATESTRING) && (defined(QT_NO_TEXTDATE))
#define QT_NO_DATESTRING
@@ -346,9 +340,9 @@
#define QT_NO_DIAL
#endif
-// QFileSystemWatcher
-#if !defined(QT_NO_FILESYSTEMWATCHER) && (defined(QT_NO_THREAD))
-#define QT_NO_FILESYSTEMWATCHER
+// QFileSystemModel
+#if !defined(QT_NO_FILESYSTEMMODEL) && (defined(QT_NO_FILESYSTEMWATCHER))
+#define QT_NO_FILESYSTEMMODEL
#endif
// QHostInfo
@@ -361,6 +355,11 @@
#define QT_NO_IMAGEFORMAT_XPM
#endif
+// QLibrary
+#if !defined(QT_NO_LIBRARY) && (defined(QT_NO_SETTINGS))
+#define QT_NO_LIBRARY
+#endif
+
// QMenu
#if !defined(QT_NO_MENU) && (defined(QT_NO_ACTION))
#define QT_NO_MENU
@@ -376,6 +375,11 @@
#define QT_NO_PHONON_SEEKSLIDER
#endif
+// Phonon::AbstractMediaStream
+#if !defined(QT_NO_PHONON_SETTINGSGROUP) && (defined(QT_NO_SETTINGS))
+#define QT_NO_PHONON_SETTINGSGROUP
+#endif
+
// Phonon::VideoPlayer
#if !defined(QT_NO_PHONON_VIDEOPLAYER) && (defined(QT_NO_PHONON_VIDEO))
#define QT_NO_PHONON_VIDEOPLAYER
@@ -386,16 +390,6 @@
#define QT_NO_PHONON_VOLUMEFADEREFFECT
#endif
-// Phonon::VolumeSlider
-#if !defined(QT_NO_PHONON_VOLUMESLIDER) && (defined(QT_NO_SLIDER))
-#define QT_NO_PHONON_VOLUMESLIDER
-#endif
-
-// QProcess
-#if !defined(QT_NO_PROCESS) && (defined(QT_NO_THREAD))
-#define QT_NO_PROCESS
-#endif
-
// QProgressDialog
#if !defined(QT_NO_PROGRESSDIALOG) && (defined(QT_NO_PROGRESSBAR))
#define QT_NO_PROGRESSDIALOG
@@ -426,21 +420,31 @@
#define QT_NO_QWS_MANAGER
#endif
+// QVncTransformed
+#if !defined(QT_NO_QWS_TRANSFORMED) && (defined(QT_NO_QWS_PROXYSCREEN))
+#define QT_NO_QWS_TRANSFORMED
+#endif
+
+// QVncScreen
+#if !defined(QT_NO_QWS_VNC) && (defined(QT_NO_QWS_PROXYSCREEN))
+#define QT_NO_QWS_VNC
+#endif
+
// QScrollBar
#if !defined(QT_NO_SCROLLBAR) && (defined(QT_NO_SLIDER))
#define QT_NO_SCROLLBAR
#endif
-// QSettings
-#if !defined(QT_NO_SETTINGS) && (defined(QT_NO_TEXTSTREAM))
-#define QT_NO_SETTINGS
-#endif
-
// SOCKS5
#if !defined(QT_NO_SOCKS5) && (defined(QT_NO_NETWORKPROXY))
#define QT_NO_SOCKS5
#endif
+// QSoftKeyManager
+#if !defined(QT_NO_SOFTKEYMANAGER) && (defined(QT_NO_ACTION))
+#define QT_NO_SOFTKEYMANAGER
+#endif
+
// QSplitter
#if !defined(QT_NO_SPLITTER) && (defined(QT_NO_RUBBERBAND))
#define QT_NO_SPLITTER
@@ -466,9 +470,9 @@
#define QT_NO_SXE
#endif
-// QSystemTrayIcon
-#if !defined(QT_NO_SYSTEMTRAYICON) && (defined(QT_NO_ICON))
-#define QT_NO_SYSTEMTRAYICON
+// QToolButton
+#if !defined(QT_NO_TOOLBUTTON) && (defined(QT_NO_ACTION))
+#define QT_NO_TOOLBUTTON
#endif
// QUndoStack
@@ -501,11 +505,6 @@
#define QT_NO_CONTEXTMENU
#endif
-// QFileSystemModel
-#if !defined(QT_NO_FILESYSTEMMODEL) && (defined(QT_NO_FILESYSTEMWATCHER))
-#define QT_NO_FILESYSTEMMODEL
-#endif
-
// File Transfer Protocol
#if !defined(QT_NO_FTP) && (defined(QT_NO_URLINFO) || defined(QT_NO_TEXTDATE))
#define QT_NO_FTP
@@ -516,14 +515,14 @@
#define QT_NO_HTTP
#endif
-// QLibrary
-#if !defined(QT_NO_LIBRARY) && (defined(QT_NO_SETTINGS))
-#define QT_NO_LIBRARY
+// QInputContext
+#if !defined(QT_NO_IM) && (defined(QT_NO_LIBRARY))
+#define QT_NO_IM
#endif
-// QPrinter
-#if !defined(QT_NO_PRINTER) && (defined(QT_NO_TEXTSTREAM) || defined(QT_NO_PICTURE))
-#define QT_NO_PRINTER
+// Phonon::PlatformPlugin
+#if !defined(QT_NO_PHONON_PLATFORMPLUGIN) && (defined(QT_NO_LIBRARY))
+#define QT_NO_PHONON_PLATFORMPLUGIN
#endif
// QScrollArea
@@ -531,21 +530,36 @@
#define QT_NO_SCROLLAREA
#endif
+// QWindowsVistaStyle
+#if !defined(QT_NO_STYLE_WINDOWSVISTA) && (defined(QT_NO_STYLE_WINDOWSXP))
+#define QT_NO_STYLE_WINDOWSVISTA
+#endif
+
+// QTabBar
+#if !defined(QT_NO_TABBAR) && (defined(QT_NO_TOOLBUTTON))
+#define QT_NO_TABBAR
+#endif
+
// OdfWriter
#if !defined(QT_NO_TEXTODFWRITER) && (defined(QT_NO_XMLSTREAMWRITER))
#define QT_NO_TEXTODFWRITER
#endif
-// QToolButton
-#if !defined(QT_NO_TOOLBUTTON) && (defined(QT_NO_ICON) || defined(QT_NO_ACTION))
-#define QT_NO_TOOLBUTTON
-#endif
-
// Translation (UTF-8 representation)
#if !defined(QT_NO_TRANSLATION_UTF8) && (defined(QT_NO_TRANSLATION) || defined(QT_NO_TEXTCODEC))
#define QT_NO_TRANSLATION_UTF8
#endif
+// QUndoGroup
+#if !defined(QT_NO_UNDOGROUP) && (defined(QT_NO_UNDOSTACK))
+#define QT_NO_UNDOGROUP
+#endif
+
+// QWhatsThis
+#if !defined(QT_NO_WHATSTHIS) && (defined(QT_NO_TOOLBUTTON))
+#define QT_NO_WHATSTHIS
+#endif
+
// Drag and drop
#if !defined(QT_NO_DRAGANDDROP) && (defined(QT_NO_QWS_PROPERTIES) || defined(QT_NO_IMAGEFORMAT_XPM))
#define QT_NO_DRAGANDDROP
@@ -561,6 +575,21 @@
#define QT_NO_MDIAREA
#endif
+// Phonon::VolumeSlider
+#if !defined(QT_NO_PHONON_VOLUMESLIDER) && (defined(QT_NO_SLIDER) || defined(QT_NO_TOOLBUTTON))
+#define QT_NO_PHONON_VOLUMESLIDER
+#endif
+
+// QPrinter
+#if !defined(QT_NO_PRINTER) && (defined(QT_NO_TEXTSTREAM) || defined(QT_NO_PICTURE) || defined(QT_NO_TEMPORARYFILE))
+#define QT_NO_PRINTER
+#endif
+
+// QWSInputMethod
+#if !defined(QT_NO_QWS_INPUTMETHODS) && (defined(QT_NO_IM))
+#define QT_NO_QWS_INPUTMETHODS
+#endif
+
// QSpinBox
#if !defined(QT_NO_SPINBOX) && (defined(QT_NO_SPINWIDGET) || defined(QT_NO_LINEEDIT) || defined(QT_NO_VALIDATOR))
#define QT_NO_SPINBOX
@@ -591,24 +620,29 @@
#define QT_NO_STYLE_WINDOWSMOBILE
#endif
-// QWindowsVistaStyle
-#if !defined(QT_NO_STYLE_WINDOWSVISTA) && (defined(QT_NO_STYLE_WINDOWS) || defined(QT_NO_STYLE_WINDOWSXP))
-#define QT_NO_STYLE_WINDOWSVISTA
-#endif
-
// QtSvg module
#if !defined(QT_NO_SVG) && (defined(QT_NO_XMLSTREAMREADER) || defined(QT_NO_CSSPARSER))
#define QT_NO_SVG
#endif
-// QTabBar
-#if !defined(QT_NO_TABBAR) && (defined(QT_NO_TOOLBUTTON))
-#define QT_NO_TABBAR
+// Q3TabDialog
+#if !defined(QT_NO_TABDIALOG) && (defined(QT_NO_TABBAR))
+#define QT_NO_TABDIALOG
#endif
-// QUndoGroup
-#if !defined(QT_NO_UNDOGROUP) && (defined(QT_NO_UNDOCOMMAND) || defined(QT_NO_UNDOSTACK))
-#define QT_NO_UNDOGROUP
+// QTextCodecPlugin
+#if !defined(QT_NO_TEXTCODECPLUGIN) && (defined(QT_NO_TEXTCODEC) || defined(QT_NO_LIBRARY))
+#define QT_NO_TEXTCODECPLUGIN
+#endif
+
+// QColorDialog
+#if !defined(QT_NO_COLORDIALOG) && (defined(QT_NO_SPINBOX))
+#define QT_NO_COLORDIALOG
+#endif
+
+// QGraphicsEffect
+#if !defined(QT_NO_GRAPHICSEFFECT) && (defined(QT_NO_GRAPHICSVIEW))
+#define QT_NO_GRAPHICSEFFECT
#endif
// The Model/View Framework
@@ -616,6 +650,11 @@
#define QT_NO_ITEMVIEWS
#endif
+// QMenuBar
+#if !defined(QT_NO_MENUBAR) && (defined(QT_NO_MENU) || defined(QT_NO_TOOLBUTTON))
+#define QT_NO_MENUBAR
+#endif
+
// Sound Server
#if !defined(QT_NO_QWS_SOUNDSERVER) && (defined(QT_NO_SOUND) || defined(QT_NO_HOSTINFO) || defined(QT_NO_QWS_MULTIPROCESS))
#define QT_NO_QWS_SOUNDSERVER
@@ -631,14 +670,9 @@
#define QT_NO_SVGRENDERER
#endif
-// Q3TabDialog
-#if !defined(QT_NO_TABDIALOG) && (defined(QT_NO_TABBAR))
-#define QT_NO_TABDIALOG
-#endif
-
-// QTextCodecPlugin
-#if !defined(QT_NO_TEXTCODECPLUGIN) && (defined(QT_NO_TEXTCODEC) || defined(QT_NO_LIBRARY))
-#define QT_NO_TEXTCODECPLUGIN
+// QTabWidget
+#if !defined(QT_NO_TABWIDGET) && (defined(QT_NO_TABBAR) || defined(QT_NO_STACKEDWIDGET))
+#define QT_NO_TABWIDGET
#endif
// QTextEdit
@@ -646,16 +680,6 @@
#define QT_NO_TEXTEDIT
#endif
-// QWhatsThis
-#if !defined(QT_NO_WHATSTHIS) && (defined(QT_NO_TOOLBUTTON) || defined(QT_NO_ACTION))
-#define QT_NO_WHATSTHIS
-#endif
-
-// QDirModel
-#if !defined(QT_NO_DIRMODEL) && (defined(QT_NO_ITEMVIEWS))
-#define QT_NO_DIRMODEL
-#endif
-
// QErrorMessage
#if !defined(QT_NO_ERRORMESSAGE) && (defined(QT_NO_TEXTEDIT))
#define QT_NO_ERRORMESSAGE
@@ -666,9 +690,9 @@
#define QT_NO_LISTVIEW
#endif
-// QMenuBar
-#if !defined(QT_NO_MENUBAR) && (defined(QT_NO_MENU) || defined(QT_NO_TOOLBUTTON))
-#define QT_NO_MENUBAR
+// QMainWindow
+#if !defined(QT_NO_MAINWINDOW) && (defined(QT_NO_MENU) || defined(QT_NO_RESIZEHANDLER) || defined(QT_NO_TOOLBUTTON))
+#define QT_NO_MAINWINDOW
#endif
// QAbstractProxyModel
@@ -701,24 +725,24 @@
#define QT_NO_TABLEVIEW
#endif
-// QTabWidget
-#if !defined(QT_NO_TABWIDGET) && (defined(QT_NO_TABBAR) || defined(QT_NO_STACKEDWIDGET))
-#define QT_NO_TABWIDGET
-#endif
-
// QTextBrowser
#if !defined(QT_NO_TEXTBROWSER) && (defined(QT_NO_TEXTEDIT))
#define QT_NO_TEXTBROWSER
#endif
+// QToolBox
+#if !defined(QT_NO_TOOLBOX) && (defined(QT_NO_TOOLBUTTON) || defined(QT_NO_SCROLLAREA))
+#define QT_NO_TOOLBOX
+#endif
+
// QTreeView
#if !defined(QT_NO_TREEVIEW) && (defined(QT_NO_ITEMVIEWS))
#define QT_NO_TREEVIEW
#endif
-// QColorDialog
-#if !defined(QT_NO_COLORDIALOG) && (defined(QT_NO_LINEEDIT) || defined(QT_NO_VALIDATOR) || defined(QT_NO_SPINBOX))
-#define QT_NO_COLORDIALOG
+// Accessibility
+#if !defined(QT_NO_ACCESSIBILITY) && (defined(QT_NO_PROPERTIES) || defined(QT_NO_MENUBAR))
+#define QT_NO_ACCESSIBILITY
#endif
// QColumnView
@@ -746,11 +770,6 @@
#define QT_NO_LISTWIDGET
#endif
-// QMainWindow
-#if !defined(QT_NO_MAINWINDOW) && (defined(QT_NO_MENU) || defined(QT_NO_RESIZEHANDLER) || defined(QT_NO_TOOLBUTTON))
-#define QT_NO_MAINWINDOW
-#endif
-
// QSortFilterProxyModel
#if !defined(QT_NO_SORTFILTERPROXYMODEL) && (defined(QT_NO_PROXYMODEL))
#define QT_NO_SORTFILTERPROXYMODEL
@@ -761,24 +780,19 @@
#define QT_NO_TABLEWIDGET
#endif
-// QTreeWidget
-#if !defined(QT_NO_TREEWIDGET) && (defined(QT_NO_TREEVIEW))
-#define QT_NO_TREEWIDGET
-#endif
-
-// QPrintPreviewWidget
-#if !defined(QT_NO_PRINTPREVIEWWIDGET) && (defined(QT_NO_GRAPHICSVIEW) || defined(QT_NO_PRINTER))
-#define QT_NO_PRINTPREVIEWWIDGET
-#endif
-
// QToolBar
#if !defined(QT_NO_TOOLBAR) && (defined(QT_NO_MAINWINDOW))
#define QT_NO_TOOLBAR
#endif
-// QToolBox
-#if !defined(QT_NO_TOOLBOX) && (defined(QT_NO_ICON) || defined(QT_NO_TOOLBUTTON) || defined(QT_NO_SCROLLAREA))
-#define QT_NO_TOOLBOX
+// QTreeWidget
+#if !defined(QT_NO_TREEWIDGET) && (defined(QT_NO_TREEVIEW))
+#define QT_NO_TREEWIDGET
+#endif
+
+// QDirModel
+#if !defined(QT_NO_DIRMODEL) && (defined(QT_NO_ITEMVIEWS) || defined(QT_NO_FILESYSTEMMODEL))
+#define QT_NO_DIRMODEL
#endif
// QDockwidget
@@ -791,6 +805,11 @@
#define QT_NO_UNDOVIEW
#endif
+// QCompleter
+#if !defined(QT_NO_FSCOMPLETER) && (defined(QT_NO_FILESYSTEMMODEL) || defined(QT_NO_COMPLETER))
+#define QT_NO_FSCOMPLETER
+#endif
+
// QGraphicsSvgItem
#if !defined(QT_NO_GRAPHICSSVGITEM) && (defined(QT_NO_SVGRENDERER) || defined(QT_NO_GRAPHICSVIEW))
#define QT_NO_GRAPHICSSVGITEM
@@ -801,6 +820,16 @@
#define QT_NO_COMBOBOX
#endif
+// QWorkSpace
+#if !defined(QT_NO_WORKSPACE) && (defined(QT_NO_SCROLLBAR) || defined(QT_NO_MAINWINDOW) || defined(QT_NO_MENUBAR))
+#define QT_NO_WORKSPACE
+#endif
+
+// QPrintPreviewWidget
+#if !defined(QT_NO_PRINTPREVIEWWIDGET) && (defined(QT_NO_GRAPHICSVIEW) || defined(QT_NO_PRINTER) || defined(QT_NO_MAINWINDOW))
+#define QT_NO_PRINTPREVIEWWIDGET
+#endif
+
// QCalendarWidget
#if !defined(QT_NO_CALENDARWIDGET) && (defined(QT_NO_TABLEVIEW) || defined(QT_NO_MENU) || defined(QT_NO_TEXTDATE) || defined(QT_NO_SPINBOX) || defined(QT_NO_TOOLBUTTON))
#define QT_NO_CALENDARWIDGET
@@ -831,23 +860,18 @@
#define QT_NO_FONTDIALOG
#endif
-// QWorkSpace
-#if !defined(QT_NO_WORKSPACE) && (defined(QT_NO_SCROLLBAR) || defined(QT_NO_RESIZEHANDLER) || defined(QT_NO_MENU) || defined(QT_NO_TOOLBUTTON) || defined(QT_NO_MAINWINDOW) || defined(QT_NO_TOOLBAR) || defined(QT_NO_MENUBAR))
-#define QT_NO_WORKSPACE
-#endif
-
// QPrintDialog
-#if !defined(QT_NO_PRINTDIALOG) && (defined(QT_NO_PRINTER) || defined(QT_NO_COMBOBOX) || defined(QT_NO_BUTTONGROUP) || defined(QT_NO_SPINBOX) || defined(QT_NO_TREEVIEW) || defined(QT_NO_STACKEDWIDGET) || defined(QT_NO_TABWIDGET))
+#if !defined(QT_NO_PRINTDIALOG) && (defined(QT_NO_PRINTER) || defined(QT_NO_COMBOBOX) || defined(QT_NO_BUTTONGROUP) || defined(QT_NO_SPINBOX) || defined(QT_NO_TREEVIEW) || defined(QT_NO_TABWIDGET))
#define QT_NO_PRINTDIALOG
#endif
// QFileDialog
-#if !defined(QT_NO_FILEDIALOG) && (defined(QT_NO_DIRMODEL) || defined(QT_NO_TREEVIEW) || defined(QT_NO_COMBOBOX) || defined(QT_NO_TOOLBUTTON) || defined(QT_NO_BUTTONGROUP) || defined(QT_NO_TOOLTIP) || defined(QT_NO_SPLITTER) || defined(QT_NO_STACKEDWIDGET) || defined(QT_NO_FILESYSTEMMODEL))
+#if !defined(QT_NO_FILEDIALOG) && (defined(QT_NO_DIRMODEL) || defined(QT_NO_TREEVIEW) || defined(QT_NO_COMBOBOX) || defined(QT_NO_TOOLBUTTON) || defined(QT_NO_BUTTONGROUP) || defined(QT_NO_TOOLTIP) || defined(QT_NO_SPLITTER) || defined(QT_NO_STACKEDWIDGET) || defined(QT_NO_PROXYMODEL))
#define QT_NO_FILEDIALOG
#endif
// QPrintPreviewDialog
-#if !defined(QT_NO_PRINTPREVIEWDIALOG) && (defined(QT_NO_PRINTPREVIEWWIDGET) || defined(QT_NO_PRINTDIALOG) || defined(QT_NO_MAINWINDOW))
+#if !defined(QT_NO_PRINTPREVIEWDIALOG) && (defined(QT_NO_PRINTPREVIEWWIDGET) || defined(QT_NO_PRINTDIALOG) || defined(QT_NO_TOOLBAR))
#define QT_NO_PRINTPREVIEWDIALOG
#endif
diff --git a/src/corelib/global/qfeatures.txt b/src/corelib/global/qfeatures.txt
index ec478836f6..251391ef1d 100644
--- a/src/corelib/global/qfeatures.txt
+++ b/src/corelib/global/qfeatures.txt
@@ -28,17 +28,10 @@ Requires:
Name: CssParser
SeeAlso: ???
-Feature: THREAD
-Description: Supports multithreaded programming.
-Section: Kernel
-Requires:
-Name: QThread
-SeeAlso: ???
-
Feature: CONCURRENT
Description: Provides a high-level multi-threaded APIs
Section: Kernel
-Requires: THREAD
+Requires:
Name: QtConcurrent
SeeAlso: ???
@@ -70,6 +63,13 @@ Requires:
Name: QAction
SeeAlso: ???
+Feature: SOFTKEYMANAGER
+Description: Supports softkeys.
+Section: Gui
+Requires: ACTION
+Name: QSoftKeyManager
+SeeAlso: ???
+
Feature: CURSOR
Description: Supports mouse cursors.
Section: Kernel
@@ -147,6 +147,12 @@ Requires: XMLSTREAM
Name: QXmlStreamWriter
SeeAlso: ???
+Feature: IM
+Description: Inputmethods with QInputContext
+Section: Kernel
+Requires: LIBRARY
+Name: QInputContext
+SeeAlso: ???
# Data structures
Feature: STL
@@ -182,7 +188,7 @@ SeeAlso: ???
Feature: PROCESS
Description: Supports external process invocation.
Section: File I/O
-Requires: THREAD
+Requires:
Name: QProcess
SeeAlso: ???
@@ -210,7 +216,7 @@ SeeAlso: ???
Feature: SETTINGS
Description: Supports persistent application settings.
Section: File I/O
-Requires: TEXTSTREAM
+Requires:
Name: QSettings
SeeAlso: ???
@@ -232,7 +238,7 @@ Feature: FILESYSTEMWATCHER
Description: Provides an interface for monitoring files and directories
for modications.
Section: File I/O
-Requires: THREAD
+Requires:
Name: QFileSystemWatcher
SeeAlso: ???
@@ -339,7 +345,7 @@ SeeAlso: ???
Feature: COMBOBOX
Description: Supports comboboxes presenting a list of options to the user.
Section: Widgets
-Requires: LINEEDIT STANDARDITEMMODEL LISTVIEW
+Requires: LINEEDIT STANDARDITEMMODEL LISTVIEW
Name: QComboBox
SeeAlso: ???
@@ -353,7 +359,7 @@ SeeAlso: ???
Feature: TOOLBUTTON
Description: Supports quick-access buttons to commands and options.
Section: Widgets
-Requires: ICON ACTION
+Requires: ACTION
Name: QToolButton
SeeAlso: ???
@@ -367,7 +373,7 @@ SeeAlso: ???
Feature: TOOLBOX
Description: Supports columns of tabbed widget items.
Section: Widgets
-Requires: ICON TOOLBUTTON SCROLLAREA
+Requires: TOOLBUTTON SCROLLAREA
Name: QToolBox
SeeAlso: ???
@@ -403,7 +409,7 @@ SeeAlso: ???
Feature: WORKSPACE
Description: Supports workspace windows, e.g. used in an MDI application.
Section: Widgets
-Requires: SCROLLBAR RESIZEHANDLER MENU TOOLBUTTON MAINWINDOW TOOLBAR MENUBAR
+Requires: SCROLLBAR MAINWINDOW MENUBAR
Name: QWorkSpace
SeeAlso: ???
@@ -485,6 +491,13 @@ Requires: SCROLLAREA
Name: QGraphicsView
SeeAlso: ???
+Feature: GRAPHICSEFFECT
+Description: Supports the graphicseffect classes.
+Section: Widgets
+Requires: GRAPHICSVIEW
+Name: QGraphicsEffect
+SeeAlso: ???
+
Feature: SPINWIDGET
Description: Supports spinbox control widgets.
Section: Widgets
@@ -537,7 +550,7 @@ SeeAlso: ???
Feature: WHATSTHIS
Description: Supports displaying "What's this" help.
Section: Widgets
-Requires: TOOLBUTTON ACTION
+Requires: TOOLBUTTON
Name: QWhatsThis
SeeAlso: ???
@@ -567,7 +580,7 @@ Feature: PRINTPREVIEWWIDGET
Description: Provides a widget for previewing page layouts for printer output.
a date.
Section: Widgets
-Requires: GRAPHICSVIEW PRINTER
+Requires: GRAPHICSVIEW PRINTER MAINWINDOW
Name: QPrintPreviewWidget
SeeAlso: ???
@@ -584,14 +597,14 @@ SeeAlso: ???
Feature: COLORDIALOG
Description: Supports a dialog widget for specifying colors.
Section: Dialogs
-Requires: LINEEDIT VALIDATOR SPINBOX
+Requires: SPINBOX
Name: QColorDialog
SeeAlso: ???
Feature: FILEDIALOG
Description: Supports a dialog widget for selecting files or directories.
Section: Dialogs
-Requires: DIRMODEL TREEVIEW COMBOBOX TOOLBUTTON BUTTONGROUP TOOLTIP SPLITTER STACKEDWIDGET FILESYSTEMMODEL
+Requires: DIRMODEL TREEVIEW COMBOBOX TOOLBUTTON BUTTONGROUP TOOLTIP SPLITTER STACKEDWIDGET PROXYMODEL
Name: QFileDialog
SeeAlso: ???
@@ -605,14 +618,14 @@ SeeAlso: ???
Feature: PRINTDIALOG
Description: Supports a dialog widget for specifying printer configuration.
Section: Dialogs
-Requires: PRINTER COMBOBOX BUTTONGROUP SPINBOX TREEVIEW STACKEDWIDGET TABWIDGET
+Requires: PRINTER COMBOBOX BUTTONGROUP SPINBOX TREEVIEW TABWIDGET
Name: QPrintDialog
SeeAlso: ???
Feature: PRINTPREVIEWDIALOG
Description: Provides a dialog for previewing and configuring page layouts for printer output.
Section: Dialogs
-Requires: PRINTPREVIEWWIDGET PRINTDIALOG MAINWINDOW
+Requires: PRINTPREVIEWWIDGET PRINTDIALOG TOOLBAR
Name: QPrintPreviewDialog
SeeAlso: ???
@@ -664,7 +677,7 @@ SeeAlso: ???
Feature: DIRMODEL
Description: Supports a data model for the local filesystem.
Section: ItemViews
-Requires: ITEMVIEWS
+Requires: ITEMVIEWS FILESYSTEMMODEL
Name: QDirModel
SeeAlso: ???
@@ -772,7 +785,7 @@ SeeAlso: ???
Feature: STYLE_WINDOWSVISTA
Description: Supports a Microsoft WindowsVista-like look and feel.
Section: Styles
-Requires: STYLE_WINDOWS STYLE_WINDOWSXP
+Requires: STYLE_WINDOWSXP
Name: QWindowsVistaStyle
SeeAlso: ???
@@ -813,13 +826,6 @@ Requires:
Name: QImageIOPlugin
SeeAlso: ???
-Feature: ICON
-Description: Supports scalable icons in different modes and states.
-Section: Images
-Requires:
-Name: QIcon
-SeeAlso: ???
-
Feature: MOVIE
Description: Supports animated images.
Section: Images
@@ -910,7 +916,7 @@ SeeAlso: ???
Feature: PRINTER
Description: Supports printing
Section: Painting
-Requires: TEXTSTREAM PICTURE
+Requires: TEXTSTREAM PICTURE TEMPORARYFILE
Name: QPrinter
SeeAlso: ???
@@ -1014,7 +1020,7 @@ SeeAlso: ???
Feature: QWS_INPUTMETHODS
Description: Supports international input methods.
Section: Internationalization
-Requires:
+Requires: IM
Name: QWSInputMethod
SeeAlso: ???
@@ -1101,6 +1107,13 @@ Requires: PROXYMODEL
Name: QCompleter
SeeAlso: ???
+Feature: FSCOMPLETER
+Description: Provides completions based on an item model.
+Section: Utilities
+Requires: FILESYSTEMMODEL COMPLETER
+Name: QCompleter
+SeeAlso: ???
+
Feature: DESKTOPSERVICES
Description: Provides methods for accessing common desktop services.
Section: Utilities
@@ -1111,7 +1124,7 @@ SeeAlso: ???
Feature: SYSTEMTRAYICON
Description: Provides an icon for an application in the system tray.
Section: Utilities
-Requires: ICON
+Requires:
Name: QSystemTrayIcon
SeeAlso: ???
@@ -1132,7 +1145,7 @@ SeeAlso: ???
Feature: UNDOGROUP
Description:
Section: Utilities
-Requires: UNDOCOMMAND UNDOSTACK
+Requires: UNDOSTACK
Name: QUndoGroup
SeeAlso: ???
@@ -1146,7 +1159,7 @@ SeeAlso: ???
Feature: ACCESSIBILITY
Description: Provides accessibility support.
Section: Utilities
-Requires: PROPERTIES
+Requires: PROPERTIES MENUBAR
Name: Accessibility
SeeAlso: ???
@@ -1317,6 +1330,20 @@ Requires:
Name: QProxyScreen
SeeAlso: ???
+Feature: QWS_VNC
+Description: Provides VNC screen driver
+Section: Qt for Embedded Linux
+Requires: QWS_PROXYSCREEN
+Name: QVncScreen
+SeeAlso: ???
+
+Feature: QWS_TRANSFORMED
+Description: Provides Transformed screen driver
+Section: Qt for Embedded Linux
+Requires: QWS_PROXYSCREEN
+Name: QVncTransformed
+SeeAlso: ???
+
Feature: QWS_DYNAMICSCREENTRANSFORMATION
Description: Enables dynamic setting of screen transformation/rotation.
Section: Qt for Embedded Linux
@@ -1338,7 +1365,7 @@ SeeAlso: ???
Feature: PHONON_PLATFORMPLUGIN
Description: Support for platform plugin
Section: Phonon
-Requires:
+Requires: LIBRARY
Name: Phonon::PlatformPlugin
SeeAlso: ???
@@ -1403,7 +1430,7 @@ SeeAlso: ???
Feature: PHONON_VOLUMESLIDER
Description: Support for the Volume Slider class
Section: Phonon
-Requires: SLIDER
+Requires: SLIDER TOOLBUTTON
Name: Phonon::VolumeSlider
SeeAlso: ???
@@ -1420,3 +1447,10 @@ Section: Phonon
Requires:
Name: Phonon::AbstractMediaStream
SeeAlso: ???
+
+Feature: PHONON_SETTINGSGROUP
+Description: Phonon settingsgroup
+Section: Phonon
+Requires: SETTINGS
+Name: Phonon::AbstractMediaStream
+SeeAlso: ???
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 1a563ba70c..0e4a74668a 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -960,7 +960,7 @@ QT_BEGIN_NAMESPACE
\relates <QtGlobal>
Turns the major, minor and patch numbers of a version into an
- integer, 0xMMNNPP (MM = major, NN = minor, PP = patch). This can
+ integer, 0xMMNNPP (MM = major, NN = minor, PP = patch). This can
be compared with another similarly processed version id.
\sa QT_VERSION
@@ -1191,6 +1191,10 @@ bool qSharedBuild()
\value SV_9_2 Symbian OS v9.2
\value SV_9_3 Symbian OS v9.3
\value SV_9_4 Symbian OS v9.4
+ \value SV_SF_1 Symbian^1
+ \value SV_SF_2 Symbian^2
+ \value SV_SF_3 Symbian^3
+ \value SV_SF_4 Symbian^4
\value SV_Unknown An unknown and currently unsupported platform
\sa S60Version, WinVersion, MacVersion
@@ -1207,6 +1211,8 @@ bool qSharedBuild()
\value SV_S60_3_1 S60 3rd Edition Feature Pack 1
\value SV_S60_3_2 S60 3rd Edition Feature Pack 2
\value SV_S60_5_0 S60 5th Edition
+ \value SV_S60_5_1 S60 5th Edition Feature Pack 1
+ \value SV_S60_5_2 S60 5th Edition Feature Pack 2
\value SV_S60_Unknown An unknown and currently unsupported platform
\omitvalue SV_S60_None
@@ -1804,7 +1810,7 @@ QSysInfo::S60Version QSysInfo::s60Version()
TInt err = fileFinder.FindWildByDir(qt_S60Filter, qt_S60SystemInstallDir, contents);
if (err == KErrNone) {
err = contents->Sort(EDescending|ESortByName);
- if (err == KErrNone) {
+ if (err == KErrNone && contents->Count() > 0 && (*contents)[0].iName.Length() >= 12) {
TInt major = (*contents)[0].iName[9] - '0';
TInt minor = (*contents)[0].iName[11] - '0';
if (major == 3) {
@@ -1817,6 +1823,12 @@ QSysInfo::S60Version QSysInfo::s60Version()
if (minor == 0) {
return cachedS60Version = SV_S60_5_0;
}
+ else if (minor == 1) {
+ return cachedS60Version = SV_S60_5_1;
+ }
+ else if (minor == 2) {
+ return cachedS60Version = SV_S60_5_2;
+ }
}
}
delete contents;
@@ -1831,12 +1843,10 @@ QSysInfo::S60Version QSysInfo::s60Version()
return cachedS60Version = SV_S60_3_2;
# elif defined(__S60_50__)
return cachedS60Version = SV_S60_5_0;
-# else
- return cachedS60Version = SV_S60_Unknown;
# endif
-# else
- return cachedS60Version = SV_S60_Unknown;
# endif
+ //If reaching here, it was not possible to determine the version
+ return cachedS60Version = SV_S60_Unknown;
}
QSysInfo::SymbianVersion QSysInfo::symbianVersion()
{
@@ -1847,6 +1857,10 @@ QSysInfo::SymbianVersion QSysInfo::symbianVersion()
return SV_9_3;
case SV_S60_5_0:
return SV_9_4;
+ case SV_S60_5_1:
+ return SV_9_4;
+ case SV_S60_5_2:
+ return SV_9_4;
default:
return SV_Unknown;
}
@@ -2488,7 +2502,7 @@ bool qputenv(const char *varName, const QByteArray& value)
#endif
}
-#if defined(Q_OS_UNIX) && !defined(QT_NO_THREAD) && !defined(Q_OS_SYMBIAN)
+#if (defined(Q_OS_UNIX) || defined(Q_OS_WIN)) && !defined(QT_NO_THREAD) && !defined(Q_OS_SYMBIAN)
# if defined(Q_OS_INTEGRITY) && defined(__GHS_VERSION_NUMBER) && (__GHS_VERSION_NUMBER < 500)
// older versions of INTEGRITY used a long instead of a uint for the seed.
@@ -2522,10 +2536,19 @@ Q_GLOBAL_STATIC(SeedStorage, randTLS) // Thread Local Storage for seed value
void qsrand(uint seed)
{
#if defined(Q_OS_UNIX) && !defined(QT_NO_THREAD) && !defined(Q_OS_SYMBIAN)
- SeedStorageType *pseed = randTLS()->localData();
- if (!pseed)
- randTLS()->setLocalData(pseed = new SeedStorageType);
- *pseed = seed;
+ SeedStorage *seedStorage = randTLS();
+ if (seedStorage) {
+ SeedStorageType *pseed = seedStorage->localData();
+ if (!pseed)
+ seedStorage->setLocalData(pseed = new SeedStorageType);
+ *pseed = seed;
+ } else {
+ //golbal static seed storage should always exist,
+ //except after being deleted by QGlobalStaticDeleter.
+ //But since it still can be called from destructor of another
+ //global static object, fallback to sqrand(seed)
+ srand(seed);
+ }
#else
// On Windows srand() and rand() already use Thread-Local-Storage
// to store the seed between calls
@@ -2544,20 +2567,38 @@ void qsrand(uint seed)
*/
void qsrand()
{
-#if defined(Q_OS_UNIX) && !defined(QT_NO_THREAD) && !defined(Q_OS_SYMBIAN)
- SeedStorageType *pseed = randTLS()->localData();
- if (pseed) {
- // already seeded
- return;
+#if (defined(Q_OS_UNIX) || defined(Q_OS_WIN)) && !defined(QT_NO_THREAD) && !defined(Q_OS_SYMBIAN)
+ SeedStorage *seedStorage = randTLS();
+ if (seedStorage) {
+ SeedStorageType *pseed = seedStorage->localData();
+ if (pseed) {
+ // already seeded
+ return;
+ }
+ seedStorage->setLocalData(pseed = new SeedStorageType);
+ // start beyond 1 to avoid the sequence reset
+ static QBasicAtomicInt serial = Q_BASIC_ATOMIC_INITIALIZER(2);
+ *pseed = QDateTime::currentDateTime().toTime_t()
+ + quintptr(&pseed)
+ + serial.fetchAndAddRelaxed(1);
+#if defined(Q_OS_WIN)
+ // for Windows the srand function must still be called.
+ srand(*pseed);
+#endif
}
- randTLS()->setLocalData(pseed = new SeedStorageType);
- static QBasicAtomicInt serial = Q_BASIC_ATOMIC_INITIALIZER(0);
- *pseed = QDateTime::currentDateTime().toTime_t()
- + quintptr(&pseed)
- + serial.fetchAndAddRelaxed(1);
+
+#elif defined(Q_OS_WIN)
+ static unsigned int seed = 0;
+
+ if (seed)
+ return;
+
+ seed = GetTickCount();
+ srand(seed);
#else
- // On Windows, we assume that rand() already does the right thing
-#endif
+ // Symbian?
+
+#endif // defined(Q_OS_UNIX) || defined(Q_OS_WIN)) && !defined(QT_NO_THREAD) && !defined(Q_OS_SYMBIAN)
}
/*!
@@ -2578,12 +2619,21 @@ void qsrand()
int qrand()
{
#if defined(Q_OS_UNIX) && !defined(QT_NO_THREAD) && !defined(Q_OS_SYMBIAN)
- SeedStorageType *pseed = randTLS()->localData();
- if (!pseed) {
- randTLS()->setLocalData(pseed = new SeedStorageType);
- *pseed = 1;
+ SeedStorage *seedStorage = randTLS();
+ if (seedStorage) {
+ SeedStorageType *pseed = seedStorage->localData();
+ if (!pseed) {
+ seedStorage->setLocalData(pseed = new SeedStorageType);
+ *pseed = 1;
+ }
+ return rand_r(pseed);
+ } else {
+ //golbal static seed storage should always exist,
+ //except after being deleted by QGlobalStaticDeleter.
+ //But since it still can be called from destructor of another
+ //global static object, fallback to qrand()
+ return rand();
}
- return rand_r(pseed);
#else
// On Windows srand() and rand() already use Thread-Local-Storage
// to store the seed between calls
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index efed8c5abc..2cb1d4d111 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -437,13 +437,18 @@ namespace QT_NAMESPACE {}
#elif defined(__GCCE__)
# define Q_CC_GCCE
# define QT_VISIBILITY_AVAILABLE
+# if defined(__ARM_ARCH_6__) || defined(__ARM_ARCH_7__) || defined(__ARM_ARCH_7A__)
+# define QT_HAVE_ARMV6
+# endif
/* ARM Realview Compiler Suite
RVCT compiler also defines __EDG__ and __GNUC__ (if --gnu flag is given),
so check for it before that */
#elif defined(__ARMCC__) || defined(__CC_ARM)
# define Q_CC_RVCT
-
+# if __TARGET_ARCH_ARM >= 6
+# define QT_HAVE_ARMV6
+# endif
#elif defined(__GNUC__)
# define Q_CC_GNU
# define Q_C_CALLBACKS
@@ -466,7 +471,7 @@ namespace QT_NAMESPACE {}
# define Q_NO_USING_KEYWORD
# define QT_NO_STL_WCHAR
# endif
-# if __GNUC__ >= 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
+# if __GNUC__ > 2 || (__GNUC__ == 2 && __GNUC_MINOR__ >= 95)
# define Q_ALIGNOF(type) __alignof__(type)
# define Q_TYPEOF(expr) __typeof__(expr)
# define Q_DECL_ALIGN(n) __attribute__((__aligned__(n)))
@@ -1207,6 +1212,11 @@ class QDataStream;
# else
# define Q_SVG_EXPORT Q_DECL_IMPORT
# endif
+# if defined(QT_BUILD_DECLARATIVE_LIB)
+# define Q_DECLARATIVE_EXPORT Q_DECL_EXPORT
+# else
+# define Q_DECLARATIVE_EXPORT Q_DECL_IMPORT
+# endif
# if defined(QT_BUILD_OPENGL_LIB)
# define Q_OPENGL_EXPORT Q_DECL_EXPORT
# else
@@ -1259,6 +1269,7 @@ class QDataStream;
# define Q_SQL_EXPORT Q_DECL_IMPORT
# define Q_NETWORK_EXPORT Q_DECL_IMPORT
# define Q_SVG_EXPORT Q_DECL_IMPORT
+# define Q_DECLARATIVE_EXPORT Q_DECL_IMPORT
# define Q_CANVAS_EXPORT Q_DECL_IMPORT
# define Q_OPENGL_EXPORT Q_DECL_IMPORT
# define Q_MULTIMEDIA_EXPORT Q_DECL_IMPORT
@@ -1287,6 +1298,7 @@ class QDataStream;
# define Q_SQL_EXPORT Q_DECL_EXPORT
# define Q_NETWORK_EXPORT Q_DECL_EXPORT
# define Q_SVG_EXPORT Q_DECL_EXPORT
+# define Q_DECLARATIVE_EXPORT Q_DECL_EXPORT
# define Q_OPENGL_EXPORT Q_DECL_EXPORT
# define Q_MULTIMEDIA_EXPORT Q_DECL_EXPORT
# define Q_OPENVG_EXPORT Q_DECL_EXPORT
@@ -1301,6 +1313,7 @@ class QDataStream;
# define Q_SQL_EXPORT
# define Q_NETWORK_EXPORT
# define Q_SVG_EXPORT
+# define Q_DECLARATIVE_EXPORT
# define Q_OPENGL_EXPORT
# define Q_MULTIMEDIA_EXPORT
# define Q_XML_EXPORT
@@ -1478,17 +1491,26 @@ public:
#ifdef Q_OS_SYMBIAN
enum SymbianVersion {
SV_Unknown = 0x0000,
+ //These are the Symbian Ltd versions 9.2-9.4
SV_9_2 = 10,
SV_9_3 = 20,
- SV_9_4 = 30
+ SV_9_4 = 30,
+ //Following values are the symbian foundation versions, i.e. Symbian^1 == SV_SF_1
+ SV_SF_1 = SV_9_4,
+ SV_SF_2 = 40,
+ SV_SF_3 = 50,
+ SV_SF_4 = 60
};
static SymbianVersion symbianVersion();
enum S60Version {
SV_S60_None = 0,
SV_S60_Unknown = 1,
- SV_S60_3_1 = 10,
- SV_S60_3_2 = 20,
- SV_S60_5_0 = 30
+ SV_S60_3_1 = SV_9_2,
+ SV_S60_3_2 = SV_9_3,
+ SV_S60_5_0 = SV_9_4,
+ //versions beyond 5.0 are to be confirmed - it is better to use symbian version
+ SV_S60_5_1 = SV_SF_2,
+ SV_S60_5_2 = SV_SF_3
};
static S60Version s60Version();
#endif
@@ -2065,6 +2087,9 @@ Q_DECLARE_TYPEINFO(long double, Q_PRIMITIVE_TYPE);
Q_CORE_EXPORT void *qMalloc(size_t size);
Q_CORE_EXPORT void qFree(void *ptr);
Q_CORE_EXPORT void *qRealloc(void *ptr, size_t size);
+Q_CORE_EXPORT void *qMallocAligned(size_t size, size_t alignment);
+Q_CORE_EXPORT void *qReallocAligned(void *ptr, size_t size, size_t oldsize, size_t alignment);
+Q_CORE_EXPORT void qFreeAligned(void *ptr);
Q_CORE_EXPORT void *qMemCopy(void *dest, const void *src, size_t n);
Q_CORE_EXPORT void *qMemSet(void *dest, int c, size_t n);
@@ -2459,6 +2484,7 @@ Q_CORE_EXPORT int qt_symbian_exception2Error(const std::exception& ex);
#define QT_MODULE_SCRIPTTOOLS 0x10000
#define QT_MODULE_OPENVG 0x20000
#define QT_MODULE_MULTIMEDIA 0x40000
+#define QT_MODULE_DECLARATIVE 0x80000
/* Qt editions */
#define QT_EDITION_CONSOLE (QT_MODULE_CORE \
@@ -2489,6 +2515,7 @@ Q_CORE_EXPORT int qt_symbian_exception2Error(const std::exception& ex);
| QT_MODULE_QT3SUPPORTLIGHT \
| QT_MODULE_QT3SUPPORT \
| QT_MODULE_SVG \
+ | QT_MODULE_DECLARATIVE \
| QT_MODULE_GRAPHICSVIEW \
| QT_MODULE_HELP \
| QT_MODULE_TEST \
@@ -2560,6 +2587,9 @@ QT_LICENSED_MODULE(Qt3Support)
#if (QT_EDITION & QT_MODULE_SVG)
QT_LICENSED_MODULE(Svg)
#endif
+#if (QT_EDITION & QT_MODULE_DECLARATIVE)
+QT_LICENSED_MODULE(Declarative)
+#endif
#if (QT_EDITION & QT_MODULE_ACTIVEQT)
QT_LICENSED_MODULE(ActiveQt)
#endif
diff --git a/src/corelib/global/qlibraryinfo.cpp b/src/corelib/global/qlibraryinfo.cpp
index e2274039ba..77a86bb4b9 100644
--- a/src/corelib/global/qlibraryinfo.cpp
+++ b/src/corelib/global/qlibraryinfo.cpp
@@ -46,7 +46,11 @@
#include "qlibraryinfo.h"
#include "qscopedpointer.h"
-#ifdef QT_BUILD_QMAKE
+#if defined(QT_BUILD_QMAKE) || defined(QT_BOOTSTRAPPED)
+# define BOOTSTRAPPING
+#endif
+
+#ifdef BOOTSTRAPPING
QT_BEGIN_NAMESPACE
extern QString qmake_libraryInfoFile();
QT_END_NAMESPACE
@@ -91,7 +95,7 @@ public:
QLibrarySettings::QLibrarySettings()
: settings(QLibraryInfoPrivate::findConfiguration())
{
-#ifndef QT_BUILD_QMAKE
+#ifndef BOOTSTRAPPING
qAddPostRoutine(QLibraryInfoPrivate::cleanup);
#endif
}
@@ -99,7 +103,7 @@ QLibrarySettings::QLibrarySettings()
QSettings *QLibraryInfoPrivate::findConfiguration()
{
QString qtconfig = QLatin1String(":/qt/etc/qt.conf");
-#ifdef QT_BUILD_QMAKE
+#ifdef BOOTSTRAPPING
if(!QFile::exists(qtconfig))
qtconfig = qmake_libraryInfoFile();
#else
@@ -208,6 +212,19 @@ QLibraryInfo::buildKey()
}
/*!
+ \since 4.6
+ Returns the installation date for this build of Qt. The install date will
+ usually be the last time that Qt sources were configured.
+*/
+#ifndef QT_NO_DATESTRING
+QDate
+QLibraryInfo::buildDate()
+{
+ return QDate::fromString(QString::fromLatin1(qt_configure_installation + 12), Qt::ISODate);
+}
+#endif //QT_NO_DATESTRING
+
+/*!
Returns the location specified by \a loc.
*/
@@ -412,7 +429,7 @@ QLibraryInfo::location(LibraryLocation loc)
if (QDir::isRelativePath(ret)) {
if (loc == PrefixPath) {
// we make the prefix path absolute to the executable's directory
-#ifdef QT_BUILD_QMAKE
+#ifdef BOOTSTRAPPING
return QFileInfo(qmake_libraryInfoFile()).absolutePath();
#else
if (QCoreApplication::instance()) {
@@ -481,12 +498,20 @@ void qt_core_boilerplate()
"Contact: Nokia Corporation (qt-info@nokia.com)\n"
"\n"
"Build key: " QT_BUILD_KEY "\n"
+ "Build date: %s\n"
"Installation prefix: %s\n"
"Library path: %s\n"
"Include path: %s\n",
+ qt_configure_installation + 12,
qt_configure_prefix_path_str + 12,
qt_configure_libraries_path_str + 12,
qt_configure_headers_path_str + 12);
+
+#ifdef QT_EVAL
+ extern void qt_core_eval_init(uint);
+ qt_core_eval_init(1);
+#endif
+
exit(0);
}
diff --git a/src/corelib/global/qlibraryinfo.h b/src/corelib/global/qlibraryinfo.h
index 319577763d..f65051d7c7 100644
--- a/src/corelib/global/qlibraryinfo.h
+++ b/src/corelib/global/qlibraryinfo.h
@@ -43,6 +43,7 @@
#define QLIBRARYINFO_H
#include <QtCore/qstring.h>
+#include <QtCore/QDate>
QT_BEGIN_HEADER
@@ -59,6 +60,9 @@ public:
static QString licensedProducts();
static QString buildKey();
+#ifndef QT_NO_DATESTRING
+ static QDate buildDate();
+#endif //QT_NO_DATESTRING
enum LibraryLocation
{
diff --git a/src/corelib/global/qmalloc.cpp b/src/corelib/global/qmalloc.cpp
index a9f103cba1..4aab1bd49a 100644
--- a/src/corelib/global/qmalloc.cpp
+++ b/src/corelib/global/qmalloc.cpp
@@ -65,4 +65,62 @@ void *qRealloc(void *ptr, size_t size)
return ::realloc(ptr, size);
}
+void *qMallocAligned(size_t size, size_t alignment)
+{
+ return qReallocAligned(0, size, 0, alignment);
+}
+
+void *qReallocAligned(void *oldptr, size_t newsize, size_t oldsize, size_t alignment)
+{
+ // fake an aligned allocation
+ Q_UNUSED(oldsize);
+
+ void *actualptr = oldptr ? static_cast<void **>(oldptr)[-1] : 0;
+ if (alignment <= sizeof(void*)) {
+ // special, fast case
+ void **newptr = static_cast<void **>(qRealloc(actualptr, newsize + sizeof(void*)));
+ if (!newptr)
+ return 0;
+ if (newptr == actualptr) {
+ // realloc succeeded without reallocating
+ return oldptr;
+ }
+
+ *newptr = newptr;
+ 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
+ // somewhere within the first alignment-sizeof(size_t) that is properly aligned.
+
+ // 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)
+ return 0;
+
+ faked.n = real.n + alignment;
+ faked.n &= ~(alignment - 1);
+
+ // 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;
+
+ return faked.ptr;
+}
+
+void qFreeAligned(void *ptr)
+{
+ if (!ptr)
+ return;
+ void **ptr2 = static_cast<void **>(ptr);
+ free(ptr2[-1]);
+}
+
QT_END_NAMESPACE
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index 8f0048b35c..5fcdd5e131 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -44,10 +44,6 @@
#include <QtCore/qglobal.h>
-#ifdef Q_OS_SYMBIAN
-# include <e32def.h>
-#endif
-
QT_BEGIN_HEADER
QT_BEGIN_NAMESPACE
@@ -913,12 +909,10 @@ public:
Key_Dead_Horn = 0x01001262,
// multimedia/internet keys - ignored by default - see QKeyEvent c'tor
-
Key_Back = 0x01000061,
Key_Forward = 0x01000062,
Key_Stop = 0x01000063,
Key_Refresh = 0x01000064,
-
Key_VolumeDown = 0x01000070,
Key_VolumeMute = 0x01000071,
Key_VolumeUp = 0x01000072,
@@ -927,7 +921,6 @@ public:
Key_BassDown = 0x01000075,
Key_TrebleUp = 0x01000076,
Key_TrebleDown = 0x01000077,
-
Key_MediaPlay = 0x01000080,
Key_MediaStop = 0x01000081,
Key_MediaPrevious = 0x01000082,
@@ -936,13 +929,11 @@ public:
#endif
Key_MediaNext = 0x01000083,
Key_MediaRecord = 0x01000084,
-
Key_HomePage = 0x01000090,
Key_Favorites = 0x01000091,
Key_Search = 0x01000092,
Key_Standby = 0x01000093,
Key_OpenUrl = 0x01000094,
-
Key_LaunchMail = 0x010000a0,
Key_LaunchMedia = 0x010000a1,
Key_Launch0 = 0x010000a2,
@@ -961,6 +952,98 @@ public:
Key_LaunchD = 0x010000af,
Key_LaunchE = 0x010000b0,
Key_LaunchF = 0x010000b1,
+ Key_MonBrightnessUp = 0x010000b2,
+ Key_MonBrightnessDown = 0x010000b3,
+ Key_KeyboardLightOnOff = 0x010000b4,
+ Key_KeyboardBrightnessUp = 0x010000b5,
+ Key_KeyboardBrightnessDown = 0x010000b6,
+ Key_PowerOff = 0x010000b7,
+ Key_WakeUp = 0x010000b8,
+ Key_Eject = 0x010000b9,
+ Key_ScreenSaver = 0x010000ba,
+ Key_WWW = 0x010000bb,
+ Key_Memo = 0x010000bc,
+ Key_LightBulb = 0x010000bd,
+ Key_Shop = 0x010000be,
+ Key_History = 0x010000bf,
+ Key_AddFavorite = 0x010000c0,
+ Key_HotLinks = 0x010000c1,
+ Key_BrightnessAdjust = 0x010000c2,
+ Key_Finance = 0x010000c3,
+ Key_Community = 0x010000c4,
+ Key_AudioRewind = 0x010000c5,
+ Key_BackForward = 0x010000c6,
+ Key_ApplicationLeft = 0x010000c7,
+ Key_ApplicationRight = 0x010000c8,
+ Key_Book = 0x010000c9,
+ Key_CD = 0x010000ca,
+ Key_Calculator = 0x010000cb,
+ Key_ToDoList = 0x010000cc,
+ Key_ClearGrab = 0x010000cd,
+ Key_Close = 0x010000ce,
+ Key_Copy = 0x010000cf,
+ Key_Cut = 0x010000d0,
+ Key_Display = 0x010000d1,
+ Key_DOS = 0x010000d2,
+ Key_Documents = 0x010000d3,
+ Key_Excel = 0x010000d4,
+ Key_Explorer = 0x010000d5,
+ Key_Game = 0x010000d6,
+ Key_Go = 0x010000d7,
+ Key_iTouch = 0x010000d8,
+ Key_LogOff = 0x010000d9,
+ Key_Market = 0x010000da,
+ Key_Meeting = 0x010000db,
+ Key_MenuKB = 0x010000dc,
+ Key_MenuPB = 0x010000dd,
+ Key_MySites = 0x010000de,
+ Key_News = 0x010000df,
+ Key_OfficeHome = 0x010000e0,
+ Key_Option = 0x010000e1,
+ Key_Paste = 0x010000e2,
+ Key_Phone = 0x010000e3,
+ Key_Calendar = 0x010000e4,
+ Key_Reply = 0x010000e5,
+ Key_Reload = 0x010000e6,
+ Key_RotateWindows = 0x010000e7,
+ Key_RotationPB = 0x010000e8,
+ Key_RotationKB = 0x010000e9,
+ Key_Save = 0x010000ea,
+ Key_Send = 0x010000eb,
+ Key_Spell = 0x010000ec,
+ Key_SplitScreen = 0x010000ed,
+ Key_Support = 0x010000ee,
+ Key_TaskPane = 0x010000ef,
+ Key_Terminal = 0x010000f0,
+ Key_Tools = 0x010000f1,
+ Key_Travel = 0x010000f2,
+ Key_Video = 0x010000f3,
+ Key_Word = 0x010000f4,
+ Key_Xfer = 0x010000f5,
+ Key_ZoomIn = 0x010000f6,
+ Key_ZoomOut = 0x010000f7,
+ Key_Away = 0x010000f8,
+ Key_Messenger = 0x010000f9,
+ Key_WebCam = 0x010000fa,
+ Key_MailForward = 0x010000fb,
+ Key_Pictures = 0x010000fc,
+ Key_Music = 0x010000fd,
+ Key_Battery = 0x010000fe,
+ Key_Bluetooth = 0x010000ff,
+ Key_WLAN = 0x01000100,
+ Key_UWB = 0x01000101,
+ Key_AudioForward = 0x01000102,
+ Key_AudioRepeat = 0x01000103,
+ Key_AudioRandomPlay = 0x01000104,
+ Key_Subtitle = 0x01000105,
+ Key_AudioCycleTrack = 0x01000106,
+ Key_Time = 0x01000107,
+ Key_Hibernate = 0x01000108,
+ Key_View = 0x01000109,
+ Key_TopMenu = 0x0100010a,
+ Key_PowerDown = 0x0100010b,
+ Key_Suspend = 0x0100010c,
+ Key_ContrastAdjust = 0x0100010d,
Key_MediaLast = 0x0100ffff,
@@ -1632,11 +1715,12 @@ public:
LastGestureType = ~0u
};
- enum GestureContext
+ enum GestureFlag
{
- WidgetGesture = 0,
- WidgetWithChildrenGesture = 3
+ DontStartGestureOnChildren = 0x01,
+ ReceivePartialGestures = 0x02
};
+ Q_DECLARE_FLAGS(GestureFlags, GestureFlag)
enum NavigationMode
{
@@ -1646,11 +1730,6 @@ public:
NavigationModeCursorAuto,
NavigationModeCursorForceVisible
};
-
- enum RenderHint {
- QualityHint,
- PerformanceHint
- };
}
#ifdef Q_MOC_RUN
;
@@ -1671,6 +1750,7 @@ Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::MatchFlags)
Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::TextInteractionFlags)
Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::InputMethodHints)
Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::TouchPointStates)
+Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::GestureFlags)
typedef bool (*qInternalCallback)(void **);
diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc
index ba05b00ec5..7ee7a76740 100644
--- a/src/corelib/global/qnamespace.qdoc
+++ b/src/corelib/global/qnamespace.qdoc
@@ -884,7 +884,7 @@
\value WA_InputMethodEnabled Enables input methods for Asian languages.
Must be set when creating custom text editing widgets.
- On Windows CE this flag can be used in addition to
+ On Windows CE and Symbian this flag can be used in addition to
QApplication::autoSipEnabled to automatically display the SIP when
entering a widget.
@@ -1609,6 +1609,98 @@
\value Key_LaunchD
\value Key_LaunchE
\value Key_LaunchF
+ \value Key_MonBrightnessUp
+ \value Key_MonBrightnessDown
+ \value Key_KeyboardLightOnOff
+ \value Key_KeyboardBrightnessUp
+ \value Key_KeyboardBrightnessDown
+ \value Key_PowerOff
+ \value Key_WakeUp
+ \value Key_Eject
+ \value Key_ScreenSaver
+ \value Key_WWW
+ \value Key_Memo
+ \value Key_LightBulb
+ \value Key_Shop
+ \value Key_History
+ \value Key_AddFavorite
+ \value Key_HotLinks
+ \value Key_BrightnessAdjust
+ \value Key_Finance
+ \value Key_Community
+ \value Key_AudioRewind
+ \value Key_BackForward
+ \value Key_ApplicationLeft
+ \value Key_ApplicationRight
+ \value Key_Book
+ \value Key_CD
+ \value Key_Calculator
+ \value Key_ToDoList
+ \value Key_ClearGrab
+ \value Key_Close
+ \value Key_Copy
+ \value Key_Cut
+ \value Key_Display
+ \value Key_DOS
+ \value Key_Documents
+ \value Key_Excel
+ \value Key_Explorer
+ \value Key_Game
+ \value Key_Go
+ \value Key_iTouch
+ \value Key_LogOff
+ \value Key_Market
+ \value Key_Meeting
+ \value Key_MenuKB
+ \value Key_MenuPB
+ \value Key_MySites
+ \value Key_News
+ \value Key_OfficeHome
+ \value Key_Option
+ \value Key_Paste
+ \value Key_Phone
+ \value Key_Calendar
+ \value Key_Reply
+ \value Key_Reload
+ \value Key_RotateWindows
+ \value Key_RotationPB
+ \value Key_RotationKB
+ \value Key_Save
+ \value Key_Send
+ \value Key_Spell
+ \value Key_SplitScreen
+ \value Key_Support
+ \value Key_TaskPane
+ \value Key_Terminal
+ \value Key_Tools
+ \value Key_Travel
+ \value Key_Video
+ \value Key_Word
+ \value Key_Xfer
+ \value Key_ZoomIn
+ \value Key_ZoomOut
+ \value Key_Away
+ \value Key_Messenger
+ \value Key_WebCam
+ \value Key_MailForward
+ \value Key_Pictures
+ \value Key_Music
+ \value Key_Battery
+ \value Key_Bluetooth
+ \value Key_WLAN
+ \value Key_UWB
+ \value Key_AudioForward
+ \value Key_AudioRepeat
+ \value Key_AudioRandomPlay
+ \value Key_Subtitle
+ \value Key_AudioCycleTrack
+ \value Key_Time
+ \value Key_Hibernate
+ \value Key_View
+ \value Key_TopMenu
+ \value Key_PowerDown
+ \value Key_Suspend
+ \value Key_ContrastAdjust
\value Key_MediaLast
\value Key_unknown
@@ -1827,7 +1919,9 @@
\value TabFocus the widget accepts focus by tabbing.
\value ClickFocus the widget accepts focus by clicking.
\value StrongFocus the widget accepts focus by both tabbing
- and clicking.
+ and clicking. On Mac OS X this will also
+ be indicate that the widget accepts tab focus
+ when in 'Text/List focus mode'.
\value WheelFocus like Qt::StrongFocus plus the widget accepts
focus by using the mouse wheel.
\value NoFocus the widget does not accept focus.
@@ -1909,7 +2003,7 @@
\value Tool Indicates that the widget is a tool window. A tool
window is often a small window with a smaller than
usual title bar and decoration, typically used for
- collections of tool buttons. It there is a parent,
+ collections of tool buttons. If there is a parent,
the tool window will always be kept on top of it.
If there isn't a parent, you may consider using
Qt::WindowStaysOnTopHint as well. If the window
@@ -2507,7 +2601,7 @@
\value DisplayRole The key data to be rendered in the form of text. (QString)
\value DecorationRole The data to be rendered as a decoration in the form
- of an icon. (QColor)
+ of an icon. (QColor, QIcon or QPixmap)
\value EditRole The data in a form suitable for editing in an
editor. (QString)
\value ToolTipRole The data displayed in the item's tooltip. (QString)
@@ -2816,31 +2910,36 @@
\value PanGesture A Pan gesture.
\value PinchGesture A Pinch gesture.
\value SwipeGesture A Swipe gesture.
- \value CustomGesture User-defined gesture ID.
- \value LastGestureType Last user gesture ID.
+ \value CustomGesture A flag that can be used to test if the gesture is a
+ user-defined gesture ID.
+ \omitvalue LastGestureType
User-defined gestures are registered with the
- QApplication::registerGestureRecognizer() function which generates a custom gesture ID
- in the range of values from CustomGesture to LastGestureType.
+ QGestureRecognizer::registerRecognizer() function which generates a custom
+ gesture ID with the Qt::CustomGesture flag set.
- \sa QGesture, QWidget::grabGesture()
+ \sa QGesture, QWidget::grabGesture(), QGraphicsObject::grabGesture()
*/
/*!
- \enum Qt::GestureContext
+ \enum Qt::GestureFlag
\since 4.6
- This enum type describes the context of a gesture.
+ This enum type describes additional flags that can be used when subscribing
+ to a gesture.
- For a QGesture to trigger, the gesture recognizer should filter events for
- a widget tree. This enum describes for which widget the gesture recognizer
- should filter events:
+ \value DontStartGestureOnChildren By default gestures can start on the
+ widget or over any of its children. Use this flag to disable this and allow
+ a gesture to start on the widget only.
- \value WidgetGesture Gestures can only start over the widget itself.
- \value WidgetWithChildrenGesture Gestures can start on the widget or over
- any of its children.
+ \value ReceivePartialGestures Allows any ignored gesture events to be
+ propagated to parent widgets which have specified this hint. By default
+ only gestures that are in the Qt::GestureStarted state are propagated and
+ the widget always gets the full gesture sequence starting with a gesture in
+ the Qt::GestureStarted state and ending with a gesture in the
+ Qt::GestureFinished or Qt::GestureCanceled states.
- \sa QWidget::grabGesture()
+ \sa QWidget::grabGesture(), QGraphicsObject::grabGesture()
*/
/*!
@@ -2868,18 +2967,3 @@
\sa QApplication::setNavigationMode()
\sa QApplication::navigationMode()
*/
-
-/*!
- \enum Qt::RenderHint
- \since 4.6
-
- This enum describes the possible hints that can be used to control various
- rendering operations.
-
- \value QualityHint Indicates that rendering quality is the most important factor,
- at the potential cost of lower performance.
-
- \value PerformanceHint Indicates that rendering performance is the most important factor,
- at the potential cost of lower quality.
-*/
-
diff --git a/src/corelib/io/qdatastream.cpp b/src/corelib/io/qdatastream.cpp
index 19e86a6e14..b10d603c01 100644
--- a/src/corelib/io/qdatastream.cpp
+++ b/src/corelib/io/qdatastream.cpp
@@ -42,7 +42,7 @@
#include "qdatastream.h"
#include "qdatastream_p.h"
-#ifndef QT_NO_DATASTREAM
+#if !defined(QT_NO_DATASTREAM) || defined(QT_BOOTSTRAPPED)
#include "qbuffer.h"
#include "qstring.h"
#include <stdio.h>
diff --git a/src/corelib/io/qdatastream.h b/src/corelib/io/qdatastream.h
index f61a59cd93..2e4e7c1895 100644
--- a/src/corelib/io/qdatastream.h
+++ b/src/corelib/io/qdatastream.h
@@ -66,7 +66,7 @@ template <typename T> class QSet;
template <class Key, class T> class QHash;
template <class Key, class T> class QMap;
-#ifndef QT_NO_DATASTREAM
+#if !defined(QT_NO_DATASTREAM) || defined(QT_BOOTSTRAPPED)
class QDataStreamPrivate;
class Q_CORE_EXPORT QDataStream
{
diff --git a/src/corelib/io/qdatastream_p.h b/src/corelib/io/qdatastream_p.h
index 157fee9fae..98dd21f362 100644
--- a/src/corelib/io/qdatastream_p.h
+++ b/src/corelib/io/qdatastream_p.h
@@ -57,7 +57,7 @@
QT_BEGIN_NAMESPACE
-#ifndef QT_NO_DATASTREAM
+#if !defined(QT_NO_DATASTREAM) || defined(QT_BOOTSTRAPPED)
class QDataStreamPrivate
{
public:
diff --git a/src/corelib/io/qdir.cpp b/src/corelib/io/qdir.cpp
index a67b3bda91..59db9a61db 100644
--- a/src/corelib/io/qdir.cpp
+++ b/src/corelib/io/qdir.cpp
@@ -1930,7 +1930,7 @@ QString QDir::currentPath()
Under non-Windows operating systems the \c HOME environment
variable is used if it exists, otherwise the path returned by the
- rootPath().
+ rootPath(). On Symbian always the same as the path returned by the rootPath().
\sa home(), currentPath(), rootPath(), tempPath()
*/
@@ -2002,7 +2002,8 @@ QString QDir::tempPath()
Returns the absolute path of the root directory.
For Unix operating systems this returns "/". For Windows file
- systems this normally returns "c:/".
+ systems this normally returns "c:/". On Symbian this typically returns
+ "c:/data", i.e. the same as native PathInfo::PhoneMemoryRootPath().
\sa root(), drives(), currentPath(), homePath(), tempPath()
*/
diff --git a/src/corelib/io/qfile.cpp b/src/corelib/io/qfile.cpp
index 134c4b8b6d..d4077bcb23 100644
--- a/src/corelib/io/qfile.cpp
+++ b/src/corelib/io/qfile.cpp
@@ -1020,14 +1020,15 @@ bool QFile::open(OpenMode mode)
\bold{Warning:}
\list 1
- \o If \a fh is \c stdin, \c stdout, or \c stderr, you may not be able
- to seek(). See QIODevice::isSequential() for more information.
+ \o If \a fh does not refer to a regular file, e.g., it is \c stdin,
+ \c stdout, or \c stderr, you may not be able to seek(). size()
+ returns \c 0 in those cases. See QIODevice::isSequential() for
+ more information.
\o Since this function opens the file without specifying the file name,
you cannot use this QFile with a QFileInfo.
\endlist
- \note For Windows CE you may not be able to call seek() and resize().
- Also, size() is set to \c 0.
+ \note For Windows CE you may not be able to call resize().
\sa close(), {qmake Variable Reference#CONFIG}{qmake Variable Reference}
@@ -1064,7 +1065,7 @@ bool QFile::open(FILE *fh, OpenMode mode)
if (mode & Append) {
seek(size());
} else {
- long pos = ftell(fh);
+ qint64 pos = (qint64)QT_FTELL(fh);
if (pos != -1)
seek(pos);
}
@@ -1081,7 +1082,7 @@ bool QFile::open(FILE *fh, OpenMode mode)
/*!
\overload
- Opens the existing file descripter \a fd in the given \a mode.
+ Opens the existing file descriptor \a fd in the given \a mode.
Returns true if successful; otherwise returns false.
When a QFile is opened using this function, close() does not
@@ -1092,12 +1093,13 @@ bool QFile::open(FILE *fh, OpenMode mode)
are slow. If you run into performance issues, you should try to
use one of the other open functions.
- \warning If \a fd is 0 (\c stdin), 1 (\c stdout), or 2 (\c
- stderr), you may not be able to seek(). size() is set to \c
- LLONG_MAX (in \c <climits>).
+ \warning If \a fd is not a regular file, e.g, it is 0 (\c stdin),
+ 1 (\c stdout), or 2 (\c stderr), you may not be able to seek(). In
+ those cases, size() returns \c 0. See QIODevice::isSequential()
+ for more information.
\warning For Windows CE you may not be able to call seek(), setSize(),
- fileTime(). size() is set to \c 0.
+ fileTime(). size() returns \c 0.
\warning Since this function opens the file without specifying the file name,
you cannot use this QFile with a QFileInfo.
@@ -1120,8 +1122,13 @@ bool QFile::open(int fd, OpenMode mode)
}
if(d->openExternalFile(mode, fd)) {
QIODevice::open(mode);
- if (mode & Append)
+ if (mode & Append) {
seek(size());
+ } else {
+ qint64 pos = (qint64)QT_LSEEK(fd, QT_OFF_T(0), SEEK_CUR);
+ if (pos != -1)
+ seek(pos);
+ }
return true;
}
return false;
@@ -1332,7 +1339,7 @@ QFile::setPermissions(const QString &fileName, Permissions permissions)
static inline qint64 _qfile_writeData(QAbstractFileEngine *engine, QRingBuffer *buffer)
{
- qint64 ret = engine->write(buffer->readPointer(), buffer->size());
+ qint64 ret = engine->write(buffer->readPointer(), buffer->nextDataBlockSize());
if (ret > 0)
buffer->free(ret);
return ret;
diff --git a/src/corelib/io/qfsfileengine.cpp b/src/corelib/io/qfsfileengine.cpp
index fb096a77f8..3cf9b7ec15 100644
--- a/src/corelib/io/qfsfileengine.cpp
+++ b/src/corelib/io/qfsfileengine.cpp
@@ -76,7 +76,6 @@ QT_BEGIN_NAMESPACE
# endif
#endif
-
/*! \class QFSFileEngine
\brief The QFSFileEngine class implements Qt's default file engine.
\since 4.1
@@ -122,11 +121,9 @@ void QFSFileEnginePrivate::init()
#ifdef Q_OS_WIN
fileAttrib = INVALID_FILE_ATTRIBUTES;
fileHandle = INVALID_HANDLE_VALUE;
+ mapHandle = INVALID_HANDLE_VALUE;
cachedFd = -1;
#endif
-#ifdef Q_USE_DEPRECATED_MAP_API
- fileMapHandle = INVALID_HANDLE_VALUE;
-#endif
}
/*!
@@ -160,11 +157,11 @@ QString QFSFileEnginePrivate::canonicalized(const QString &path)
if (
#ifdef Q_OS_SYMBIAN
// Symbian doesn't support directory symlinks, so do not check for link unless we
- // are handling the last path element. This not only slightly improves performance,
+ // are handling the last path element. This not only slightly improves performance,
// but also saves us from lot of unnecessary platform security check failures
// when dealing with files under *:/private directories.
separatorPos == -1 &&
-#endif
+#endif
!nonSymlinks.contains(prefix)) {
fi.setFile(prefix);
if (fi.isSymLink()) {
@@ -319,9 +316,9 @@ bool QFSFileEnginePrivate::openFh(QIODevice::OpenMode openMode, FILE *fh)
int ret;
do {
ret = QT_FSEEK(fh, 0, SEEK_END);
- } while (ret == -1 && errno == EINTR);
+ } while (ret != 0 && errno == EINTR);
- if (ret == -1) {
+ if (ret != 0) {
q->setError(errno == EMFILE ? QFile::ResourceError : QFile::OpenError,
qt_error_string(int(errno)));
@@ -566,20 +563,23 @@ bool QFSFileEnginePrivate::seekFdFh(qint64 pos)
if (lastIOCommand != QFSFileEnginePrivate::IOFlushCommand && !q->flush())
return false;
+ if (pos < 0 || pos != qint64(QT_OFF_T(pos)))
+ return false;
+
if (fh) {
// Buffered stdlib mode.
int ret;
do {
ret = QT_FSEEK(fh, QT_OFF_T(pos), SEEK_SET);
- } while (ret == -1 && errno == EINTR);
+ } while (ret != 0 && errno == EINTR);
- if (ret == -1) {
+ if (ret != 0) {
q->setError(QFile::ReadError, qt_error_string(int(errno)));
return false;
}
} else {
// Unbuffered stdio mode.
- if (QT_LSEEK(fd, pos, SEEK_SET) == -1) {
+ if (QT_LSEEK(fd, QT_OFF_T(pos), SEEK_SET) == -1) {
qWarning() << "QFile::at: Cannot set file position" << pos;
q->setError(QFile::PositionError, qt_error_string(errno));
return false;
@@ -622,71 +622,55 @@ qint64 QFSFileEnginePrivate::readFdFh(char *data, qint64 len)
{
Q_Q(QFSFileEngine);
- // Buffered stdlib mode.
+ if (len < 0 || len != qint64(size_t(len))) {
+ q->setError(QFile::ReadError, qt_error_string(EINVAL));
+ return -1;
+ }
+
+ qint64 readBytes = 0;
+ bool eof = false;
+
if (fh) {
- qint64 readBytes = 0;
- qint64 read = 0;
- int retry = 0;
+ // Buffered stdlib mode.
- // Read in blocks of 4k to avoid platform limitations (Windows
- // commonly bails out if you read or write too large blocks at once).
- qint64 bytesToRead;
+ size_t result;
+ bool retry = true;
do {
- if (retry == 1)
- retry = 2;
-
- bytesToRead = qMin<qint64>(4096, len - read);
- do {
- readBytes = fread(data + read, 1, size_t(bytesToRead), fh);
- } while (readBytes == 0 && !feof(fh) && errno == EINTR);
-
- if (readBytes > 0) {
- read += readBytes;
- } else if (!retry && feof(fh)) {
- // Synchronize and try again (just once though).
- if (++retry == 1)
- QT_FSEEK(fh, QT_FTELL(fh), SEEK_SET);
+ result = fread(data + readBytes, 1, size_t(len - readBytes), fh);
+ eof = feof(fh);
+ if (retry && eof && result == 0) {
+ // On Mac OS, this is needed, e.g., if a file was written to
+ // through another stream since our last read. See test
+ // tst_QFile::appendAndRead
+ QT_FSEEK(fh, QT_FTELL(fh), SEEK_SET); // re-sync stream.
+ retry = false;
+ continue;
}
- } while (retry == 1 || (readBytes == bytesToRead && read < len));
+ readBytes += result;
+ } while (!eof && (result == 0 ? errno == EINTR : readBytes < len));
- // Return the number of bytes read, or if nothing was read, return -1
- // if an error occurred, or 0 if we detected EOF.
- if (read == 0) {
- q->setError(QFile::ReadError, qt_error_string(int(errno)));
- if (!feof(fh))
- read = -1;
- }
- return read;
- }
+ } else if (fd != -1) {
+ // Unbuffered stdio mode.
- // Unbuffered stdio mode.
- qint64 ret = 0;
- if (len) {
+#ifdef Q_OS_WIN
int result;
- qint64 read = 0;
- errno = 0;
-
- // Read in blocks of 4k to avoid platform limitations (Windows
- // commonly bails out if you read or write too large blocks at once).
+#else
+ ssize_t result;
+#endif
do {
- qint64 bytesToRead = qMin<qint64>(4096, len - read);
- do {
- result = QT_READ(fd, data + read, int(bytesToRead));
- } while (result == -1 && errno == EINTR);
- if (result > 0)
- read += result;
- } while (result > 0 && read < len);
-
- // Return the number of bytes read, or if nothing was read, return -1
- // if an error occurred.
- if (read > 0) {
- ret += read;
- } else if (read == 0 && result < 0) {
- ret = -1;
- q->setError(QFile::ReadError, qt_error_string(errno));
- }
+ result = QT_READ(fd, data + readBytes, size_t(len - readBytes));
+ } while ((result == -1 && errno == EINTR)
+ || (result > 0 && (readBytes += result) < len));
+
+ eof = !(result == -1);
}
- return ret;
+
+ if (!eof && readBytes == 0) {
+ readBytes = -1;
+ q->setError(QFile::ReadError, qt_error_string(errno));
+ }
+
+ return readBytes;
}
/*!
@@ -766,36 +750,43 @@ qint64 QFSFileEngine::write(const char *data, qint64 len)
qint64 QFSFileEnginePrivate::writeFdFh(const char *data, qint64 len)
{
Q_Q(QFSFileEngine);
- qint64 result;
- qint64 written = 0;
- do {
- // Write blocks of 4k to avoid platform limitations (Windows commonly
- // bails out if you read or write too large blocks at once).
- qint64 bytesToWrite = qMin<qint64>(4096, len - written);
- if (fh) {
- do {
- // Buffered stdlib mode.
- result = qint64(fwrite(data + written, 1, size_t(bytesToWrite), fh));
- } while (result == 0 && errno == EINTR);
- if (bytesToWrite > 0 && result == 0)
- result = -1;
- } else {
- do {
- // Unbuffered stdio mode.
- result = QT_WRITE(fd, data + written, bytesToWrite);
- } while (result == -1 && errno == EINTR);
- }
- if (result > 0)
- written += qint64(result);
- } while (written < len && result > 0);
+ if (len < 0 || len != qint64(size_t(len))) {
+ q->setError(QFile::WriteError, qt_error_string(EINVAL));
+ return -1;
+ }
+
+ qint64 writtenBytes = 0;
+
+ if (fh) {
+ // Buffered stdlib mode.
- // If we read anything, return that with success. Otherwise, set an error,
- // and return the last return value.
- if (result > 0)
- return written;
- q->setError(errno == ENOSPC ? QFile::ResourceError : QFile::WriteError, qt_error_string(errno));
- return result;
+ size_t result;
+ do {
+ result = fwrite(data + writtenBytes, 1, size_t(len - writtenBytes), fh);
+ writtenBytes += result;
+ } while (result == 0 ? errno == EINTR : writtenBytes < len);
+
+ } else if (fd != -1) {
+ // Unbuffered stdio mode.
+
+#ifdef Q_OS_WIN
+ int result;
+#else
+ ssize_t result;
+#endif
+ do {
+ result = QT_WRITE(fd, data + writtenBytes, size_t(len - writtenBytes));
+ } while ((result == -1 && errno == EINTR)
+ || (result > 0 && (writtenBytes += result) < len));
+ }
+
+ if (len && writtenBytes == 0) {
+ writtenBytes = -1;
+ q->setError(errno == ENOSPC ? QFile::ResourceError : QFile::WriteError, qt_error_string(errno));
+ }
+
+ return writtenBytes;
}
/*!
@@ -903,7 +894,7 @@ bool QFSFileEngine::supportsExtension(Extension extension) const
/*! \fn QString QFSFileEngine::currentPath(const QString &fileName)
For Unix, returns the current working directory for the file
engine.
-
+
For Windows, returns the canonicalized form of the current path used
by the file engine for the drive specified by \a fileName. On
Windows, each drive has its own current directory, so a different
diff --git a/src/corelib/io/qfsfileengine_p.h b/src/corelib/io/qfsfileengine_p.h
index 66e0219889..87f0737c1e 100644
--- a/src/corelib/io/qfsfileengine_p.h
+++ b/src/corelib/io/qfsfileengine_p.h
@@ -110,20 +110,16 @@ public:
FILE *fh;
#ifdef Q_WS_WIN
HANDLE fileHandle;
- QHash<uchar *, QPair<int /*offset*/, HANDLE /*handle*/> > maps;
+ HANDLE mapHandle;
+ QHash<uchar *, DWORD /* offset % AllocationGranularity */> maps;
mutable int cachedFd;
mutable DWORD fileAttrib;
#else
- QHash<uchar *, QPair<int /*offset*/, int /*handle|len*/> > maps;
+ QHash<uchar *, QPair<int /*offset % PageSize*/, size_t /*length + offset % PageSize*/> > maps;
mutable QT_STATBUF st;
#endif
int fd;
-#ifdef Q_USE_DEPRECATED_MAP_API
- void mapHandleClose();
- HANDLE fileMapHandle;
-#endif
-
enum LastIOCommand
{
IOFlushCommand,
diff --git a/src/corelib/io/qfsfileengine_unix.cpp b/src/corelib/io/qfsfileengine_unix.cpp
index b0cddaaae1..05e6fabecf 100644
--- a/src/corelib/io/qfsfileengine_unix.cpp
+++ b/src/corelib/io/qfsfileengine_unix.cpp
@@ -1243,34 +1243,51 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size, QFile::MemoryMapFla
q->setError(QFile::PermissionsError, qt_error_string(int(EACCES)));
return 0;
}
- if (offset < 0) {
+
+ if (offset < 0 || offset != qint64(QT_OFF_T(offset))
+ || size < 0 || size > qint64(size_t(-1))) {
q->setError(QFile::UnspecifiedError, qt_error_string(int(EINVAL)));
return 0;
}
+
+ // If we know the mapping will extend beyond EOF, fail early to avoid
+ // undefined behavior. Otherwise, let mmap have its say.
+ if (doStat()
+ && (QT_OFF_T(size) > st.st_size - QT_OFF_T(offset)))
+ return 0;
+
int access = 0;
if (openMode & QIODevice::ReadOnly) access |= PROT_READ;
if (openMode & QIODevice::WriteOnly) access |= PROT_WRITE;
- int pagesSize = getpagesize();
- int realOffset = offset / pagesSize;
- int extra = offset % pagesSize;
+ int pageSize = getpagesize();
+ int extra = offset % pageSize;
+
+ if (size + extra > (size_t)-1) {
+ q->setError(QFile::UnspecifiedError, qt_error_string(int(EINVAL)));
+ return 0;
+ }
+
+ size_t realSize = (size_t)size + extra;
+ QT_OFF_T realOffset = QT_OFF_T(offset);
+ realOffset &= ~(QT_OFF_T(pageSize - 1));
#ifdef Q_OS_SYMBIAN
void *mapAddress;
- TRAPD(err, mapAddress = mmap((void*)0, (size_t)size + extra,
- access, MAP_SHARED, nativeHandle(), realOffset * pagesSize));
+ TRAPD(err, mapAddress = QT_MMAP((void*)0, realSize,
+ access, MAP_SHARED, nativeHandle(), realOffset));
if (err != KErrNone) {
qWarning("OpenC bug: leave from mmap %d", err);
mapAddress = MAP_FAILED;
errno = EINVAL;
}
#else
- void *mapAddress = mmap((void*)0, (size_t)size + extra,
- access, MAP_SHARED, nativeHandle(), realOffset * pagesSize);
+ void *mapAddress = QT_MMAP((void*)0, realSize,
+ access, MAP_SHARED, nativeHandle(), realOffset);
#endif
if (MAP_FAILED != mapAddress) {
uchar *address = extra + static_cast<uchar*>(mapAddress);
- maps[address] = QPair<int,int>(extra, size);
+ maps[address] = QPair<int,size_t>(extra, realSize);
return address;
}
@@ -1300,7 +1317,7 @@ bool QFSFileEnginePrivate::unmap(uchar *ptr)
}
uchar *start = ptr - maps[ptr].first;
- int len = maps[ptr].second;
+ size_t len = maps[ptr].second;
if (-1 == munmap(start, len)) {
q->setError(QFile::UnspecifiedError, qt_error_string(errno));
return false;
diff --git a/src/corelib/io/qfsfileengine_win.cpp b/src/corelib/io/qfsfileengine_win.cpp
index 898447cc2e..a6cb5a9f7a 100644
--- a/src/corelib/io/qfsfileengine_win.cpp
+++ b/src/corelib/io/qfsfileengine_win.cpp
@@ -455,17 +455,10 @@ bool QFSFileEnginePrivate::nativeClose()
// Windows native mode.
bool ok = true;
- if ((fileHandle == INVALID_HANDLE_VALUE || !CloseHandle(fileHandle))
-#ifdef Q_USE_DEPRECATED_MAP_API
- && (fileMapHandle == INVALID_HANDLE_VALUE || !CloseHandle(fileMapHandle))
-#endif
- ) {
+ if ((fileHandle == INVALID_HANDLE_VALUE || !::CloseHandle(fileHandle))) {
q->setError(QFile::UnspecifiedError, qt_error_string());
ok = false;
}
-#ifdef Q_USE_DEPRECATED_MAP_API
- fileMapHandle = INVALID_HANDLE_VALUE;
-#endif
fileHandle = INVALID_HANDLE_VALUE;
cachedFd = -1; // gets closed by CloseHandle above
@@ -504,14 +497,30 @@ qint64 QFSFileEnginePrivate::nativeSize() const
// ### Don't flush; for buffered files, we should get away with ftell.
thatQ->flush();
+#if !defined(Q_OS_WINCE)
+ // stdlib/stdio mode.
+ if (fh || fd != -1) {
+ qint64 fileSize = _filelengthi64(fh ? QT_FILENO(fh) : fd);
+ if (fileSize == -1) {
+ fileSize = 0;
+ thatQ->setError(QFile::UnspecifiedError, qt_error_string(errno));
+ }
+ return fileSize;
+ }
+#else // Q_OS_WINCE
// Buffered stdlib mode.
if (fh) {
QT_OFF_T oldPos = QT_FTELL(fh);
QT_FSEEK(fh, 0, SEEK_END);
- QT_OFF_T fileSize = QT_FTELL(fh);
+ qint64 fileSize = (qint64)QT_FTELL(fh);
QT_FSEEK(fh, oldPos, SEEK_SET);
- return qint64(fileSize);
+ if (fileSize == -1) {
+ fileSize = 0;
+ thatQ->setError(QFile::UnspecifiedError, qt_error_string(errno));
+ }
+ return fileSize;
}
+#endif
// Not-open mode, where the file name is known: We'll check the
// file system directly.
@@ -551,23 +560,13 @@ qint64 QFSFileEnginePrivate::nativeSize() const
return 0;
}
- // Unbuffed stdio mode.
- if(fd != -1) {
-#if !defined(Q_OS_WINCE)
- HANDLE handle = (HANDLE)_get_osfhandle(fd);
- if (handle != INVALID_HANDLE_VALUE) {
- BY_HANDLE_FILE_INFORMATION fileInfo;
- if (GetFileInformationByHandle(handle, &fileInfo)) {
- qint64 size = fileInfo.nFileSizeHigh;
- size <<= 32;
- size += fileInfo.nFileSizeLow;
- return size;
- }
- }
-#endif
- thatQ->setError(QFile::UnspecifiedError, qt_error_string());
+#if defined(Q_OS_WINCE)
+ // Unbuffed stdio mode
+ if (fd != -1) {
+ thatQ->setError(QFile::UnspecifiedError, QLatin1String("Not implemented!"));
return 0;
}
+#endif
// Windows native mode.
if (fileHandle == INVALID_HANDLE_VALUE)
@@ -799,27 +798,18 @@ int QFSFileEnginePrivate::nativeHandle() const
bool QFSFileEnginePrivate::nativeIsSequential() const
{
#if !defined(Q_OS_WINCE)
- // stdlib / Windows native mode.
- if (fh || fileHandle != INVALID_HANDLE_VALUE) {
- if (fh == stdin || fh == stdout || fh == stderr)
- return true;
-
- HANDLE handle = fileHandle;
- if (fileHandle == INVALID_HANDLE_VALUE) {
- // Rare case: using QFile::open(FILE*) to open a pipe.
- handle = (HANDLE)_get_osfhandle(QT_FILENO(fh));
- return false;
- }
-
- DWORD fileType = GetFileType(handle);
- return fileType == FILE_TYPE_PIPE;
- }
+ HANDLE handle = fileHandle;
+ if (fh || fd != -1)
+ handle = (HANDLE)_get_osfhandle(fh ? QT_FILENO(fh) : fd);
+ if (handle == INVALID_HANDLE_VALUE)
+ return false;
- // stdio mode.
- if (fd != -1)
- return isSequentialFdFh();
-#endif
+ DWORD fileType = GetFileType(handle);
+ return (fileType == FILE_TYPE_CHAR)
+ || (fileType == FILE_TYPE_PIPE);
+#else
return false;
+#endif
}
bool QFSFileEngine::remove()
@@ -1931,42 +1921,42 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size,
return 0;
}
+ if (mapHandle == INVALID_HANDLE_VALUE) {
+ // get handle to the file
+ HANDLE handle = fileHandle;
- // get handle to the file
- HANDLE handle = fileHandle;
#ifndef Q_OS_WINCE
- if (handle == INVALID_HANDLE_VALUE && fh)
- handle = (HANDLE)_get_osfhandle(QT_FILENO(fh));
+ if (handle == INVALID_HANDLE_VALUE && fh)
+ handle = (HANDLE)::_get_osfhandle(QT_FILENO(fh));
#endif
#ifdef Q_USE_DEPRECATED_MAP_API
- if (fileMapHandle == INVALID_HANDLE_VALUE) {
nativeClose();
- fileMapHandle = CreateFileForMapping((const wchar_t*)nativeFilePath.constData(),
+ // handle automatically closed by kernel with mapHandle (below).
+ handle = ::CreateFileForMapping((const wchar_t*)nativeFilePath.constData(),
GENERIC_READ | (openMode & QIODevice::WriteOnly ? GENERIC_WRITE : 0),
0,
NULL,
OPEN_EXISTING,
FILE_ATTRIBUTE_NORMAL,
NULL);
- }
- handle = fileMapHandle;
#endif
- if (handle == INVALID_HANDLE_VALUE) {
- q->setError(QFile::PermissionsError, qt_error_string(ERROR_ACCESS_DENIED));
- return 0;
- }
+ if (handle == INVALID_HANDLE_VALUE) {
+ q->setError(QFile::PermissionsError, qt_error_string(ERROR_ACCESS_DENIED));
+ return 0;
+ }
- // first create the file mapping handle
- DWORD protection = (openMode & QIODevice::WriteOnly) ? PAGE_READWRITE : PAGE_READONLY;
- HANDLE mapHandle = ::CreateFileMapping(handle, 0, protection, 0, 0, 0);
- if (mapHandle == NULL) {
- q->setError(QFile::PermissionsError, qt_error_string());
+ // first create the file mapping handle
+ DWORD protection = (openMode & QIODevice::WriteOnly) ? PAGE_READWRITE : PAGE_READONLY;
+ mapHandle = ::CreateFileMapping(handle, 0, protection, 0, 0, 0);
+ if (mapHandle == INVALID_HANDLE_VALUE) {
+ q->setError(QFile::PermissionsError, qt_error_string());
#ifdef Q_USE_DEPRECATED_MAP_API
- mapHandleClose();
+ ::CloseHandle(handle);
#endif
- return 0;
+ return 0;
+ }
}
// setup args to map
@@ -1978,17 +1968,17 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size,
DWORD offsetLo = offset & Q_UINT64_C(0xffffffff);
SYSTEM_INFO sysinfo;
::GetSystemInfo(&sysinfo);
- int mask = sysinfo.dwAllocationGranularity - 1;
- int extra = offset & mask;
+ DWORD mask = sysinfo.dwAllocationGranularity - 1;
+ DWORD extra = offset & mask;
if (extra)
offsetLo &= ~mask;
// attempt to create the map
- LPVOID mapAddress = MapViewOfFile(mapHandle, access,
+ LPVOID mapAddress = ::MapViewOfFile(mapHandle, access,
offsetHi, offsetLo, size + extra);
if (mapAddress) {
uchar *address = extra + static_cast<uchar*>(mapAddress);
- maps[address] = QPair<int, HANDLE>(extra, mapHandle);
+ maps[address] = extra;
return address;
}
@@ -2001,10 +1991,8 @@ uchar *QFSFileEnginePrivate::map(qint64 offset, qint64 size,
default:
q->setError(QFile::UnspecifiedError, qt_error_string());
}
- CloseHandle(mapHandle);
-#ifdef Q_USE_DEPRECATED_MAP_API
- mapHandleClose();
-#endif
+
+ ::CloseHandle(mapHandle);
return 0;
}
@@ -2015,32 +2003,19 @@ bool QFSFileEnginePrivate::unmap(uchar *ptr)
q->setError(QFile::PermissionsError, qt_error_string(ERROR_ACCESS_DENIED));
return false;
}
- uchar *start = ptr - maps[ptr].first;
+ uchar *start = ptr - maps[ptr];
if (!UnmapViewOfFile(start)) {
q->setError(QFile::PermissionsError, qt_error_string());
return false;
}
- if (!CloseHandle((HANDLE)maps[ptr].second)) {
- q->setError(QFile::UnspecifiedError, qt_error_string());
- return false;
- }
maps.remove(ptr);
-
-#ifdef Q_USE_DEPRECATED_MAP_API
- mapHandleClose();
-#endif
- return true;
-}
-
-#ifdef Q_USE_DEPRECATED_MAP_API
-void QFSFileEnginePrivate::mapHandleClose()
-{
if (maps.isEmpty()) {
- CloseHandle(fileMapHandle);
- fileMapHandle = INVALID_HANDLE_VALUE;
+ ::CloseHandle(mapHandle);
+ mapHandle = INVALID_HANDLE_VALUE;
}
+
+ return true;
}
-#endif
QT_END_NAMESPACE
diff --git a/src/corelib/io/qiodevice.cpp b/src/corelib/io/qiodevice.cpp
index 4494d2ad07..e4e6a15671 100644
--- a/src/corelib/io/qiodevice.cpp
+++ b/src/corelib/io/qiodevice.cpp
@@ -619,7 +619,8 @@ qint64 QIODevice::size() const
*/
bool QIODevice::seek(qint64 pos)
{
- if (d_func()->openMode == NotOpen) {
+ Q_D(QIODevice);
+ if (d->openMode == NotOpen) {
qWarning("QIODevice::seek: The device is not open");
return false;
}
@@ -628,7 +629,6 @@ bool QIODevice::seek(qint64 pos)
return false;
}
- Q_D(QIODevice);
#if defined QIODEVICE_DEBUG
printf("%p QIODevice::seek(%d), before: d->pos = %d, d->buffer.size() = %d\n",
this, int(pos), int(d->pos), d->buffer.size());
@@ -640,21 +640,16 @@ bool QIODevice::seek(qint64 pos)
d->devicePos = pos;
}
- if (offset > 0 && !d->buffer.isEmpty()) {
- // When seeking forwards, we need to pop bytes off the front of the
- // buffer.
- do {
- int bytesToSkip = int(qMin<qint64>(offset, INT_MAX));
- d->buffer.skip(bytesToSkip);
- offset -= bytesToSkip;
- } while (offset > 0);
- } else if (offset < 0) {
+ if (offset < 0
+ || offset >= qint64(d->buffer.size()))
// When seeking backwards, an operation that is only allowed for
// random-access devices, the buffer is cleared. The next read
// operation will then refill the buffer. We can optimize this, if we
// find that seeking backwards becomes a significant performance hit.
d->buffer.clear();
- }
+ else if (!d->buffer.isEmpty())
+ d->buffer.skip(int(offset));
+
#if defined QIODEVICE_DEBUG
printf("%p \tafter: d->pos == %d, d->buffer.size() == %d\n", this, int(d->pos),
d->buffer.size());
@@ -762,22 +757,20 @@ qint64 QIODevice::read(char *data, qint64 maxSize)
// Short circuit for getChar()
if (maxSize == 1) {
- int chint = d->buffer.getChar();
- if (chint != -1) {
+ int chint;
+ while ((chint = d->buffer.getChar()) != -1) {
+ if (!sequential)
+ ++d->pos;
+
char c = char(uchar(chint));
- if (c == '\r' && (d->openMode & Text)) {
- d->buffer.ungetChar(c);
- } else {
- if (data)
- *data = c;
- if (!sequential)
- ++d->pos;
+ if (c == '\r' && (d->openMode & Text))
+ continue;
+ *data = c;
#if defined QIODEVICE_DEBUG
- printf("%p \tread 0x%hhx (%c) returning 1 (shortcut)\n", this,
- int(c), isprint(c) ? c : '?');
+ printf("%p \tread 0x%hhx (%c) returning 1 (shortcut)\n", this,
+ int(c), isprint(c) ? c : '?');
#endif
- return qint64(1);
- }
+ return qint64(1);
}
}
@@ -911,10 +904,10 @@ qint64 QIODevice::read(char *data, qint64 maxSize)
QByteArray QIODevice::read(qint64 maxSize)
{
Q_D(QIODevice);
- CHECK_MAXLEN(read, QByteArray());
- QByteArray tmp;
- qint64 readSoFar = 0;
- char buffer[4096];
+ QByteArray result;
+
+ CHECK_MAXLEN(read, result);
+
#if defined QIODEVICE_DEBUG
printf("%p QIODevice::read(%d), d->pos = %d, d->buffer.size() = %d\n",
this, int(maxSize), int(d->pos), int(d->buffer.size()));
@@ -922,16 +915,34 @@ QByteArray QIODevice::read(qint64 maxSize)
Q_UNUSED(d);
#endif
- do {
- qint64 bytesToRead = qMin(int(maxSize - readSoFar), int(sizeof(buffer)));
- qint64 readBytes = read(buffer, bytesToRead);
- if (readBytes <= 0)
- break;
- tmp.append(buffer, (int) readBytes);
- readSoFar += readBytes;
- } while (readSoFar < maxSize && bytesAvailable() > 0);
+ if (maxSize != qint64(int(maxSize))) {
+ qWarning("QIODevice::read: maxSize argument exceeds QByteArray size limit");
+ maxSize = INT_MAX;
+ }
+
+ qint64 readBytes = 0;
+ if (maxSize) {
+ result.resize(int(maxSize));
+ if (!result.size()) {
+ // If resize fails, read incrementally.
+ qint64 readResult;
+ do {
+ result.resize(int(qMin(maxSize, result.size() + QIODEVICE_BUFFERSIZE)));
+ readResult = read(result.data() + readBytes, result.size() - readBytes);
+ if (readResult > 0 || readBytes == 0)
+ readBytes += readResult;
+ } while (readResult == QIODEVICE_BUFFERSIZE);
+ } else {
+ readBytes = read(result.data(), result.size());
+ }
+ }
+
+ if (readBytes <= 0)
+ result.clear();
+ else
+ result.resize(int(readBytes));
- return tmp;
+ return result;
}
/*!
@@ -952,28 +963,30 @@ QByteArray QIODevice::readAll()
this, int(d->pos), int(d->buffer.size()));
#endif
- QByteArray tmp;
- if (d->isSequential() || size() == 0) {
- // Read it in chunks. Use bytesAvailable() as an unreliable hint for
- // sequential devices, but try to read 4K as a minimum.
- int chunkSize = qMax(qint64(4096), bytesAvailable());
- qint64 totalRead = 0;
- forever {
- tmp.resize(tmp.size() + chunkSize);
- qint64 readBytes = read(tmp.data() + totalRead, chunkSize);
- tmp.chop(chunkSize - (readBytes < 0 ? 0 : readBytes));
- if (readBytes <= 0)
- return tmp;
- totalRead += readBytes;
- chunkSize = qMax(qint64(4096), bytesAvailable());
- }
+ QByteArray result;
+ qint64 readBytes = 0;
+ if (d->isSequential() || (readBytes = size()) == 0) {
+ // Size is unknown, read incrementally.
+ qint64 readResult;
+ do {
+ result.resize(result.size() + QIODEVICE_BUFFERSIZE);
+ readResult = read(result.data() + readBytes, result.size() - readBytes);
+ if (readResult > 0 || readBytes == 0)
+ readBytes += readResult;
+ } while (readResult > 0);
} else {
// Read it all in one go.
- tmp.resize(int(bytesAvailable()));
- qint64 readBytes = read(tmp.data(), tmp.size());
- tmp.resize(readBytes < 0 ? 0 : int(readBytes));
+ // If resize fails, don't read anything.
+ result.resize(int(readBytes - d->pos));
+ readBytes = read(result.data(), result.size());
}
- return tmp;
+
+ if (readBytes <= 0)
+ result.clear();
+ else
+ result.resize(int(readBytes));
+
+ return result;
}
/*!
@@ -1122,11 +1135,9 @@ qint64 QIODevice::readLine(char *data, qint64 maxSize)
QByteArray QIODevice::readLine(qint64 maxSize)
{
Q_D(QIODevice);
- CHECK_MAXLEN(readLine, QByteArray());
- QByteArray tmp;
- const int BufferGrowth = 4096;
- qint64 readSoFar = 0;
- qint64 readBytes = 0;
+ QByteArray result;
+
+ CHECK_MAXLEN(readLine, result);
#if defined QIODEVICE_DEBUG
printf("%p QIODevice::readLine(%d), d->pos = %d, d->buffer.size() = %d\n",
@@ -1135,25 +1146,34 @@ QByteArray QIODevice::readLine(qint64 maxSize)
Q_UNUSED(d);
#endif
- do {
- if (maxSize != 0)
- tmp.resize(int(readSoFar + qMin(int(maxSize), BufferGrowth)));
- else
- tmp.resize(int(readSoFar + BufferGrowth));
- readBytes = readLine(tmp.data() + readSoFar, tmp.size() - readSoFar);
- if (readBytes <= 0)
- break;
-
- readSoFar += readBytes;
- } while ((!maxSize || readSoFar < maxSize) &&
- readSoFar + 1 == tmp.size() && // +1 due to the ending null
- tmp.at(readSoFar - 1) != '\n');
+ if (maxSize > INT_MAX) {
+ qWarning("QIODevice::read: maxSize argument exceeds QByteArray size limit");
+ maxSize = INT_MAX;
+ }
- if (readSoFar == 0 && readBytes == -1)
- tmp.clear(); // return Null if we found an error
+ result.resize(int(maxSize));
+ qint64 readBytes = 0;
+ if (!result.size()) {
+ // If resize fails or maxSize == 0, read incrementally
+ if (maxSize == 0)
+ maxSize = INT_MAX;
+ qint64 readResult;
+ do {
+ result.resize(int(qMin(maxSize, result.size() + QIODEVICE_BUFFERSIZE)));
+ readResult = readLine(result.data() + readBytes, result.size() - readBytes);
+ if (readResult > 0 || readBytes == 0)
+ readBytes += readResult;
+ } while (readResult == QIODEVICE_BUFFERSIZE
+ && result[int(readBytes)] != '\n');
+ } else
+ readBytes = readLine(result.data(), result.size());
+
+ if (readBytes <= 0)
+ result.clear();
else
- tmp.resize(int(readSoFar));
- return tmp;
+ result.resize(readBytes);
+
+ return result;
}
/*!
@@ -1384,40 +1404,8 @@ bool QIODevicePrivate::putCharHelper(char c)
*/
bool QIODevice::getChar(char *c)
{
- Q_D(QIODevice);
- const OpenMode openMode = d->openMode;
- if (!(openMode & ReadOnly)) {
- if (openMode == NotOpen)
- qWarning("QIODevice::getChar: Closed device");
- else
- qWarning("QIODevice::getChar: WriteOnly device");
- return false;
- }
-
- // Shortcut for QIODevice::read(c, 1)
- QRingBuffer *buffer = &d->buffer;
- const int chint = buffer->getChar();
- if (chint != -1) {
- char ch = char(uchar(chint));
- if ((openMode & Text) && ch == '\r') {
- buffer->ungetChar(ch);
- } else {
- if (c)
- *c = ch;
- if (!d->isSequential())
- ++d->pos;
- return true;
- }
- }
-
- // Fall back to read().
char ch;
- if (read(&ch, 1) == 1) {
- if (c)
- *c = ch;
- return true;
- }
- return false;
+ return (1 == read(c ? c : &ch, 1));
}
/*!
diff --git a/src/corelib/io/qprocess_unix.cpp b/src/corelib/io/qprocess_unix.cpp
index 99296c7b2c..f040d169a7 100644
--- a/src/corelib/io/qprocess_unix.cpp
+++ b/src/corelib/io/qprocess_unix.cpp
@@ -108,6 +108,10 @@ QT_END_NAMESPACE
QT_BEGIN_NAMESPACE
+// POSIX requires PIPE_BUF to be 512 or larger
+// so we will use 512
+static const int errorBufferMax = 512;
+
#ifdef Q_OS_INTEGRITY
static inline char *strdup(const char *data)
{
@@ -752,18 +756,19 @@ void QProcessPrivate::execChild(const char *workingDir, char **path, char **argv
}
// notify failure
+ QString error = qt_error_string(errno);
#if defined (QPROCESS_DEBUG)
- fprintf(stderr, "QProcessPrivate::execChild() failed, notifying parent process\n");
+ fprintf(stderr, "QProcessPrivate::execChild() failed (%s), notifying parent process\n", qPrintable(error));
#endif
- qt_safe_write(childStartedPipe[1], "", 1);
+ qt_safe_write(childStartedPipe[1], error.data(), error.length() * sizeof(QChar));
qt_safe_close(childStartedPipe[1]);
childStartedPipe[1] = -1;
}
bool QProcessPrivate::processStarted()
{
- char c;
- int i = qt_safe_read(childStartedPipe[0], &c, 1);
+ ushort buf[errorBufferMax];
+ int i = qt_safe_read(childStartedPipe[0], &buf, sizeof buf);
if (startupSocketNotifier) {
startupSocketNotifier->setEnabled(false);
startupSocketNotifier->deleteLater();
@@ -775,6 +780,11 @@ bool QProcessPrivate::processStarted()
#if defined (QPROCESS_DEBUG)
qDebug("QProcessPrivate::processStarted() == %s", i <= 0 ? "true" : "false");
#endif
+
+ // did we read an error message?
+ if (i > 0)
+ q_func()->setErrorString(QString::fromUtf16(buf, i / sizeof(QChar)));
+
return i <= 0;
}
diff --git a/src/corelib/io/qsettings.cpp b/src/corelib/io/qsettings.cpp
index aecd964386..3a74c3942d 100644
--- a/src/corelib/io/qsettings.cpp
+++ b/src/corelib/io/qsettings.cpp
@@ -2565,8 +2565,9 @@ void QConfFileSettingsPrivate::ensureSectionParsed(QConfFile *confFile,
Example:
\snippet doc/src/snippets/code/src_corelib_io_qsettings.cpp 10
- The scope is QSettings::UserScope and the format is
- QSettings::NativeFormat.
+ The scope is set to QSettings::UserScope, and the format is
+ set to QSettings::NativeFormat (i.e. calling setDefaultFormat()
+ before calling this constructor has no effect).
\sa setDefaultFormat(), {Fallback Mechanism}
*/
@@ -2583,11 +2584,12 @@ QSettings::QSettings(const QString &organization, const QString &application, QO
If \a scope is QSettings::UserScope, the QSettings object searches
user-specific settings first, before it searches system-wide
- settings as a fallback. If \a scope is
- QSettings::SystemScope, the QSettings object ignores user-specific
- settings and provides access to system-wide settings.
+ settings as a fallback. If \a scope is QSettings::SystemScope, the
+ QSettings object ignores user-specific settings and provides
+ access to system-wide settings.
- The storage format is QSettings::NativeFormat.
+ The storage format is set to QSettings::NativeFormat (i.e. calling
+ setDefaultFormat() before calling this constructor has no effect).
If no application name is given, the QSettings object will
only access the organization-wide \l{Fallback Mechanism}{locations}.
@@ -2668,6 +2670,8 @@ QSettings::QSettings(const QString &fileName, Format format, QObject *parent)
The scope is QSettings::UserScope and the format is
defaultFormat() (QSettings::NativeFormat by default).
+ Use setDefaultFormat() before calling this constructor
+ to change the default format used by this constructor.
The code
@@ -3352,10 +3356,12 @@ QVariant QSettings::value(const QString &key, const QVariant &defaultValue) cons
/*!
\since 4.4
- Sets the default file format to the given \a format, used for storing
- settings for the QSettings(QObject *) constructor.
+ Sets the default file format to the given \a format, which is used
+ for storing settings for the QSettings(QObject *) constructor.
- If no default format is set, QSettings::NativeFormat is used.
+ If no default format is set, QSettings::NativeFormat is used. See
+ the documentation for the QSettings constructor you are using to
+ see if that constructor will ignore this function.
\sa format()
*/
diff --git a/src/corelib/io/qsettings_p.h b/src/corelib/io/qsettings_p.h
index ec40085752..7a0e837320 100644
--- a/src/corelib/io/qsettings_p.h
+++ b/src/corelib/io/qsettings_p.h
@@ -62,6 +62,7 @@
#ifndef QT_NO_QOBJECT
#include "private/qobject_p.h"
#endif
+#include "private/qscopedpointer_p.h"
#ifdef Q_OS_WIN
#include "QtCore/qt_windows.h"
diff --git a/src/corelib/io/qurl.cpp b/src/corelib/io/qurl.cpp
index 22d0019220..fd51bcf50b 100644
--- a/src/corelib/io/qurl.cpp
+++ b/src/corelib/io/qurl.cpp
@@ -3874,10 +3874,15 @@ QByteArray QUrlPrivate::toEncoded(QUrl::FormattingOptions options) const
}
}
- if (host.startsWith(QLatin1Char('[')))
+ if (host.startsWith(QLatin1Char('['))) {
url += host.toLatin1();
- else
+ } else if (host.contains(QLatin1Char(':'))) {
+ url += '[';
+ url += host.toLatin1();
+ url += ']';
+ } else {
url += QUrl::toAce(host);
+ }
if (!(options & QUrl::RemovePort) && port != -1) {
url += ':';
url += QString::number(port).toAscii();
@@ -5551,79 +5556,6 @@ QUrl QUrl::fromEncoded(const QByteArray &input, ParsingMode parsingMode)
}
/*!
- Returns a valid URL from a user supplied \a userInput string if one can be
- deducted. In the case that is not possible, an invalid QUrl() is returned.
-
- \since 4.6
-
- Most applications that can browse the web, allow the user to input a URL
- in the form of a plain string. This string can be manually typed into
- a location bar, obtained from the clipboard, or passed in via command
- line arguments.
-
- When the string is not already a valid URL, a best guess is performed,
- making various web related assumptions.
-
- In the case the string corresponds to a valid file path on the system,
- a file:// URL is constructed, using QUrl::fromLocalFile().
-
- If that is not the case, an attempt is made to turn the string into a
- http:// or ftp:// URL. The latter in the case the string starts with
- 'ftp'. The result is then passed through QUrl's tolerant parser, and
- in the case or success, a valid QUrl is returned, or else a QUrl().
-
- \section1 Examples:
-
- \list
- \o qt.nokia.com becomes http://qt.nokia.com
- \o ftp.qt.nokia.com becomes ftp://ftp.qt.nokia.com
- \o localhost becomes http://localhost
- \o /home/user/test.html becomes file:///home/user/test.html (if exists)
- \endlist
-
- \section2 Tips to avoid erroneous character conversion when dealing with
- URLs and strings:
-
- \list
- \o When creating an URL QString from a QByteArray or a char*, always use
- QString::fromUtf8().
- \o Favor the use of QUrl::fromEncoded() and QUrl::toEncoded() instead of
- QUrl(string) and QUrl::toString() when converting QUrl to/from string.
- \endlist
-*/
-QUrl QUrl::fromUserInput(const QString &userInput)
-{
- QString trimmedString = userInput.trimmed();
-
- // Absolute files
- if (QDir::isAbsolutePath(trimmedString))
- return QUrl::fromLocalFile(trimmedString);
-
- // Check the most common case of a valid url with scheme and host first
- QUrl url = QUrl::fromEncoded(trimmedString.toUtf8(), QUrl::TolerantMode);
- if (url.isValid() && !url.scheme().isEmpty() && !url.host().isEmpty())
- return url;
-
- // If the string is missing the scheme or the scheme is not valid, prepend a scheme
- QString scheme = url.scheme();
- if (scheme.isEmpty() || scheme.contains(QLatin1Char('.')) || scheme == QLatin1String("localhost")) {
- // Do not do anything for strings such as "foo", only "foo.com"
- int dotIndex = trimmedString.indexOf(QLatin1Char('.'));
- if (dotIndex != -1 || trimmedString.startsWith(QLatin1String("localhost"))) {
- const QString hostscheme = trimmedString.left(dotIndex).toLower();
- QByteArray scheme = (hostscheme == QLatin1String("ftp")) ? "ftp" : "http";
- trimmedString = QLatin1String(scheme) + QLatin1String("://") + trimmedString;
- }
- url = QUrl::fromEncoded(trimmedString.toUtf8(), QUrl::TolerantMode);
- }
-
- if (url.isValid())
- return url;
-
- return QUrl();
-}
-
-/*!
Returns a decoded copy of \a input. \a input is first decoded from
percent encoding, then converted from UTF-8 to unicode.
*/
@@ -6222,4 +6154,108 @@ QString QUrl::errorString() const
\internal
*/
+// The following code has the following copyright:
+/*
+ Copyright (C) Research In Motion Limited 2009. All rights reserved.
+
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions are met:
+ * Redistributions of source code must retain the above copyright
+ notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above copyright
+ notice, this list of conditions and the following disclaimer in the
+ documentation and/or other materials provided with the distribution.
+ * Neither the name of Research In Motion Limited nor the
+ names of its contributors may be used to endorse or promote products
+ derived from this software without specific prior written permission.
+
+THIS SOFTWARE IS PROVIDED BY Research In Motion Limited ''AS IS'' AND ANY
+EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+DISCLAIMED. IN NO EVENT SHALL Research In Motion Limited BE LIABLE FOR ANY
+DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+
+*/
+
+
+/*!
+ Returns a valid URL from a user supplied \a userInput string if one can be
+ deducted. In the case that is not possible, an invalid QUrl() is returned.
+
+ \since 4.6
+
+ Most applications that can browse the web, allow the user to input a URL
+ in the form of a plain string. This string can be manually typed into
+ a location bar, obtained from the clipboard, or passed in via command
+ line arguments.
+
+ When the string is not already a valid URL, a best guess is performed,
+ making various web related assumptions.
+
+ In the case the string corresponds to a valid file path on the system,
+ a file:// URL is constructed, using QUrl::fromLocalFile().
+
+ If that is not the case, an attempt is made to turn the string into a
+ http:// or ftp:// URL. The latter in the case the string starts with
+ 'ftp'. The result is then passed through QUrl's tolerant parser, and
+ in the case or success, a valid QUrl is returned, or else a QUrl().
+
+ \section1 Examples:
+
+ \list
+ \o qt.nokia.com becomes http://qt.nokia.com
+ \o ftp.qt.nokia.com becomes ftp://ftp.qt.nokia.com
+ \o hostname becomes http://hostname
+ \o /home/user/test.html becomes file:///home/user/test.html
+ \endlist
+
+ \section2 Tips to avoid erroneous character conversion when dealing with
+ URLs and strings:
+
+ \list
+ \o When creating an URL QString from a QByteArray or a char*, always use
+ QString::fromUtf8().
+ \o Favor the use of QUrl::fromEncoded() and QUrl::toEncoded() instead of
+ QUrl(string) and QUrl::toString() when converting QUrl to/from string.
+ \endlist
+*/
+QUrl QUrl::fromUserInput(const QString &userInput)
+{
+ QString trimmedString = userInput.trimmed();
+
+ // Check first for files, since on Windows drive letters can be interpretted as schemes
+ if (QDir::isAbsolutePath(trimmedString))
+ return QUrl::fromLocalFile(trimmedString);
+
+ QUrl url = QUrl::fromEncoded(trimmedString.toUtf8(), QUrl::TolerantMode);
+ QUrl urlPrepended = QUrl::fromEncoded((QLatin1String("http://") + trimmedString).toUtf8(), QUrl::TolerantMode);
+
+ // Check the most common case of a valid url with scheme and host
+ // We check if the port would be valid by adding the scheme to handle the case host:port
+ // where the host would be interpretted as the scheme
+ if (url.isValid()
+ && !url.scheme().isEmpty()
+ && (!url.host().isEmpty() || !url.path().isEmpty())
+ && urlPrepended.port() == -1)
+ return url;
+
+ // Else, try the prepended one and adjust the scheme from the host name
+ if (urlPrepended.isValid() && (!urlPrepended.host().isEmpty() || !urlPrepended.path().isEmpty()))
+ {
+ int dotIndex = trimmedString.indexOf(QLatin1Char('.'));
+ const QString hostscheme = trimmedString.left(dotIndex).toLower();
+ if (hostscheme == QLatin1String("ftp"))
+ urlPrepended.setScheme(QLatin1String("ftp"));
+ return urlPrepended;
+ }
+
+ return QUrl();
+}
+// end of BSD code
+
QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qabstractitemmodel.cpp b/src/corelib/kernel/qabstractitemmodel.cpp
index 8e2273d102..10a61cacbf 100644
--- a/src/corelib/kernel/qabstractitemmodel.cpp
+++ b/src/corelib/kernel/qabstractitemmodel.cpp
@@ -2475,10 +2475,8 @@ void QAbstractItemModel::endRemoveRows()
bool QAbstractItemModelPrivate::allowMove(const QModelIndex &srcParent, int start, int end, const QModelIndex &destinationParent, int destinationStart, Qt::Orientation orientation)
{
// Don't move the range within itself.
- if ( ( destinationParent == srcParent )
- && ( destinationStart >= start )
- && ( destinationStart <= end + 1) )
- return false;
+ if (destinationParent == srcParent)
+ return !(destinationStart >= start && destinationStart <= end + 1);
QModelIndex destinationAncestor = destinationParent;
int pos = (Qt::Vertical == orientation) ? destinationAncestor.row() : destinationAncestor.column();
diff --git a/src/corelib/kernel/qcoreevent.cpp b/src/corelib/kernel/qcoreevent.cpp
index 588304298a..9098515625 100644
--- a/src/corelib/kernel/qcoreevent.cpp
+++ b/src/corelib/kernel/qcoreevent.cpp
@@ -228,6 +228,7 @@ QT_BEGIN_NAMESPACE
\value TouchBegin Beginning of a sequence of touch-screen and/or track-pad events (QTouchEvent)
\value TouchUpdate Touch-screen event (QTouchEvent)
\value TouchEnd End of touch-event sequence (QTouchEvent)
+ \value WinIdChange The window system identifer for this native widget has changed
\value Gesture A gesture was triggered (QGestureEvent)
\value GestureOverride A gesture override was triggered (QGestureEvent)
diff --git a/src/corelib/kernel/qcoreevent.h b/src/corelib/kernel/qcoreevent.h
index ee1e1b9c7e..6427d1771a 100644
--- a/src/corelib/kernel/qcoreevent.h
+++ b/src/corelib/kernel/qcoreevent.h
@@ -283,6 +283,7 @@ public:
UpdateSoftKeys = 201, // Internal for compressing soft key updates
+ WinIdChange = 203,
Gesture = 198,
GestureOverride = 202,
diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp
index 02f77a10ab..b32696da16 100644
--- a/src/corelib/kernel/qeventdispatcher_symbian.cpp
+++ b/src/corelib/kernel/qeventdispatcher_symbian.cpp
@@ -668,6 +668,7 @@ void QEventDispatcherSymbian::closingDown()
bool QEventDispatcherSymbian::processEvents ( QEventLoop::ProcessEventsFlags flags )
{
bool handledAnyEvent = false;
+ bool oldNoSocketEventsValue = m_noSocketEvents;
QT_TRY {
Q_D(QAbstractEventDispatcher);
@@ -686,7 +687,6 @@ bool QEventDispatcherSymbian::processEvents ( QEventLoop::ProcessEventsFlags fla
block = false;
}
- bool oldNoSocketEventsValue = m_noSocketEvents;
if (flags & QEventLoop::ExcludeSocketNotifiers) {
m_noSocketEvents = true;
} else {
@@ -762,14 +762,14 @@ bool QEventDispatcherSymbian::processEvents ( QEventLoop::ProcessEventsFlags fla
};
emit awake();
-
- m_noSocketEvents = oldNoSocketEventsValue;
} QT_CATCH (const std::exception& ex) {
#ifndef QT_NO_EXCEPTIONS
CActiveScheduler::Current()->Error(qt_symbian_exception2Error(ex));
#endif
}
+ m_noSocketEvents = oldNoSocketEventsValue;
+
return handledAnyEvent;
}
diff --git a/src/corelib/kernel/qeventdispatcher_win.cpp b/src/corelib/kernel/qeventdispatcher_win.cpp
index 1e6402f652..b3497b99b3 100644
--- a/src/corelib/kernel/qeventdispatcher_win.cpp
+++ b/src/corelib/kernel/qeventdispatcher_win.cpp
@@ -64,6 +64,16 @@ extern uint qGlobalPostedEventsCount();
# define TIME_KILL_SYNCHRONOUS 0x0100
#endif
+#ifndef QS_RAWINPUT
+# define QS_RAWINPUT 0x0400
+#endif
+
+enum {
+ WM_QT_SOCKETNOTIFIER = WM_USER,
+ WM_QT_SENDPOSTEDEVENTS = WM_USER + 1,
+ SendPostedEventsTimerId = ~1u
+};
+
#if defined(Q_OS_WINCE)
QT_BEGIN_INCLUDE_NAMESPACE
#include <winsock.h>
@@ -327,6 +337,11 @@ public:
// internal window handle used for socketnotifiers/timers/etc
HWND internalHwnd;
+ // for controlling when to send posted events
+ QAtomicInt serialNumber;
+ int lastSerialNumber;
+ QAtomicInt wakeUps;
+
// timers
WinTimerVec timerVec;
WinTimerDict timerDict;
@@ -340,9 +355,6 @@ public:
QSNDict sn_except;
void doWsaAsyncSelect(int socket);
- // event notifier
- QWinEventNotifier wakeUpNotifier;
-
QList<QWinEventNotifier *> winEventNotifierList;
void activateEventNotifier(QWinEventNotifier * wen);
@@ -351,19 +363,13 @@ public:
};
QEventDispatcherWin32Private::QEventDispatcherWin32Private()
- : threadId(GetCurrentThreadId()), interrupt(false), internalHwnd(0)
+ : threadId(GetCurrentThreadId()), interrupt(false), internalHwnd(0), serialNumber(0), lastSerialNumber(0), wakeUps(0)
{
resolveTimerAPI();
-
- wakeUpNotifier.setHandle(CreateEvent(0, FALSE, FALSE, 0));
- if (!wakeUpNotifier.handle())
- qWarning("QEventDispatcher: Creating QEventDispatcherWin32Private wakeup event failed");
}
QEventDispatcherWin32Private::~QEventDispatcherWin32Private()
{
- wakeUpNotifier.setEnabled(false);
- CloseHandle(wakeUpNotifier.handle());
if (internalHwnd)
DestroyWindow(internalHwnd);
QString className = QLatin1String("QEventDispatcherWin32_Internal_Widget") + QString::number(quintptr(qt_internal_proc));
@@ -408,22 +414,35 @@ void WINAPI CALLBACK qt_fast_timer_proc(uint timerId, uint /*reserved*/, DWORD_P
LRESULT CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp)
{
- if (message == WM_NCCREATE) {
- return true;
- } else if (message == WM_USER) {
+ if (message == WM_NCCREATE)
+ return true;
- // socket notifier message
- MSG msg;
- msg.hwnd = hwnd;
- msg.message = message;
- msg.wParam = wp;
- msg.lParam = lp;
+ MSG msg;
+ msg.hwnd = hwnd;
+ msg.message = message;
+ msg.wParam = wp;
+ msg.lParam = lp;
+ QCoreApplication *app = QCoreApplication::instance();
+ long result;
+ if (!app) {
+ if (message == WM_TIMER)
+ KillTimer(hwnd, wp);
+ return 0;
+ } else if (app->filterEvent(&msg, &result)) {
+ return result;
+ }
- QCoreApplication *app = QCoreApplication::instance();
- long result;
- if (app && app->filterEvent(&msg, &result))
- return result;
+#ifdef GWLP_USERDATA
+ QEventDispatcherWin32 *q = (QEventDispatcherWin32 *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
+#else
+ QEventDispatcherWin32 *q = (QEventDispatcherWin32 *) GetWindowLong(hwnd, GWL_USERDATA);
+#endif
+ QEventDispatcherWin32Private *d = 0;
+ if (q != 0)
+ d = q->d_func();
+ if (message == WM_QT_SOCKETNOTIFIER) {
+ // socket notifier message
int type = -1;
switch (WSAGETSELECTEVENT(lp)) {
case FD_READ:
@@ -440,56 +459,57 @@ LRESULT CALLBACK qt_internal_proc(HWND hwnd, UINT message, WPARAM wp, LPARAM lp)
break;
}
if (type >= 0) {
-
- #ifdef GWLP_USERDATA
- QEventDispatcherWin32 *eventDispatcher =
- (QEventDispatcherWin32 *) GetWindowLongPtr(hwnd, GWLP_USERDATA);
- #else
- QEventDispatcherWin32 *eventDispatcher =
- (QEventDispatcherWin32 *) GetWindowLong(hwnd, GWL_USERDATA);
- #endif
- if (eventDispatcher) {
- QEventDispatcherWin32Private *d = eventDispatcher->d_func();
- QSNDict *sn_vec[3] = { &d->sn_read, &d->sn_write, &d->sn_except };
- QSNDict *dict = sn_vec[type];
-
- QSockNot *sn = dict ? dict->value(wp) : 0;
- if (sn) {
- QEvent event(QEvent::SockAct);
- QCoreApplication::sendEvent(sn->obj, &event);
- }
+ Q_ASSERT(d != 0);
+ QSNDict *sn_vec[3] = { &d->sn_read, &d->sn_write, &d->sn_except };
+ QSNDict *dict = sn_vec[type];
+
+ QSockNot *sn = dict ? dict->value(wp) : 0;
+ if (sn) {
+ QEvent event(QEvent::SockAct);
+ QCoreApplication::sendEvent(sn->obj, &event);
}
}
return 0;
-
- } else if (message == WM_TIMER) {
-
- MSG msg;
- msg.hwnd = hwnd;
- msg.message = message;
- msg.wParam = wp;
- msg.lParam = lp;
-
- QCoreApplication *app = QCoreApplication::instance();
- Q_ASSERT_X(app, "qt_interal_proc", "Timer fired, but no QCoreApplication");
- if (!app) {
- KillTimer(hwnd, wp);
- return 0;
+ } else if (message == WM_TIMER) {
+ if (wp == SendPostedEventsTimerId) {
+ KillTimer(d->internalHwnd, wp);
+ int localSerialNumber = d->serialNumber;
+ (void) d->wakeUps.fetchAndStoreRelease(0);
+ if (localSerialNumber != d->lastSerialNumber) {
+ PostMessage(d->internalHwnd, WM_QT_SENDPOSTEDEVENTS, 0, 0);
+ }
+ } else {
+ Q_ASSERT(d != 0);
+ d->sendTimerEvent(wp);
+ }
+ return 0;
+ } else if (message == WM_QT_SENDPOSTEDEVENTS) {
+ int localSerialNumber = d->serialNumber;
+
+ if (GetQueueStatus(QS_INPUT | QS_RAWINPUT | QS_TIMER) != 0) {
+ // delay the next pass of sendPostedEvents() until we get the special
+ // WM_TIMER, which allows all pending Windows messages to be processed
+ if (SetTimer(d->internalHwnd, SendPostedEventsTimerId, 0, 0) == 0) {
+ // failed to start the timer, oops, clear wakeUps in an attempt to keep things running
+ qErrnoWarning("Qt: INTERNAL ERROR: failed to start sendPostedEvents() timer");
+ d->wakeUps.fetchAndStoreRelease(0);
+ } else {
+ // SetTimer() succeeded, nothing to do now
+ ;
+ }
+ } else {
+ // nothing pending in the queue, let sendPostedEvents go through
+ d->wakeUps.fetchAndStoreRelease(0);
}
- long result;
- if (app->filterEvent(&msg, &result))
- return result;
-
- QEventDispatcherWin32 *eventDispatcher =
- qobject_cast<QEventDispatcherWin32 *>(QAbstractEventDispatcher::instance());
- Q_ASSERT(eventDispatcher != 0);
- QEventDispatcherWin32Private *d = eventDispatcher->d_func();
- d->sendTimerEvent(wp);
+ if (localSerialNumber != d->lastSerialNumber) {
+ d->lastSerialNumber = localSerialNumber;
+ QCoreApplicationPrivate::sendPostedEvents(0, 0, d->threadData);
+ }
return 0;
}
- return DefWindowProc(hwnd, message, wp, lp);
+ return DefWindowProc(hwnd, message, wp, lp);
}
static HWND qt_create_internal_window(const QEventDispatcherWin32 *eventDispatcher)
@@ -519,15 +539,16 @@ static HWND qt_create_internal_window(const QEventDispatcherWin32 *eventDispatch
qWinAppInst(), // application
0); // windows creation data.
+ if (!wnd) {
+ qWarning("QEventDispatcher: Failed to create QEventDispatcherWin32 internal window: %d\n", (int)GetLastError());
+ }
+
#ifdef GWLP_USERDATA
SetWindowLongPtr(wnd, GWLP_USERDATA, (LONG_PTR)eventDispatcher);
#else
SetWindowLong(wnd, GWL_USERDATA, (LONG)eventDispatcher);
#endif
- if (!wnd) {
- qWarning("QEventDispatcher: Failed to create QEventDispatcherWin32 internal window: %d\n", (int)GetLastError());
- }
return wnd;
}
@@ -538,12 +559,7 @@ void QEventDispatcherWin32Private::registerTimer(WinTimerInfo *t)
Q_Q(QEventDispatcherWin32);
int ok = 0;
-
- //in the animation api, we delay the start of the animation
- //for the dock widgets, we need to use a system timer because dragging a native window
- //makes Windows start its own event loop.
- //So if this threshold changes, please change STARTSTOP_TIMER_DELAY in qabstractanimation.cpp accordingly.
- if (t->interval > 15 || !t->interval || !qtimeSetEvent) {
+ if (t->interval > 20 || !t->interval || !qtimeSetEvent) {
ok = 1;
if (!t->interval) // optimization for single-shot-zero-timer
QCoreApplication::postEvent(q, new QZeroTimerEvent(t->timerId));
@@ -608,7 +624,7 @@ void QEventDispatcherWin32Private::doWsaAsyncSelect(int socket)
sn_event |= FD_OOB;
// BoundsChecker may emit a warning for WSAAsyncSelect when sn_event == 0
// This is a BoundsChecker bug and not a Qt bug
- WSAAsyncSelect(socket, internalHwnd, sn_event ? WM_USER : 0, sn_event);
+ WSAAsyncSelect(socket, internalHwnd, sn_event ? WM_QT_SOCKETNOTIFIER : 0, sn_event);
}
void QEventDispatcherWin32::createInternalHwnd()
@@ -630,6 +646,9 @@ void QEventDispatcherWin32::createInternalHwnd()
// start all normal timers
for (int i = 0; i < d->timerVec.count(); ++i)
d->registerTimer(d->timerVec.at(i));
+
+ // trigger a call to sendPostedEvents()
+ wakeUp();
}
QEventDispatcherWin32::QEventDispatcherWin32(QObject *parent)
@@ -653,9 +672,9 @@ bool QEventDispatcherWin32::processEvents(QEventLoop::ProcessEventsFlags flags)
bool canWait;
bool retVal = false;
+ bool seenWM_QT_SENDPOSTEDEVENTS = false;
+ bool needWM_QT_SENDPOSTEDEVENTS = false;
do {
- QCoreApplicationPrivate::sendPostedEvents(0, 0, d->threadData);
-
DWORD waitRet = 0;
HANDLE pHandles[MAXIMUM_WAIT_OBJECTS - 1];
QVarLengthArray<MSG> processedTimers;
@@ -689,7 +708,7 @@ bool QEventDispatcherWin32::processEvents(QEventLoop::ProcessEventsFlags flags)
d->queuedUserInputEvents.append(msg);
}
if (haveMessage && (flags & QEventLoop::ExcludeSocketNotifiers)
- && (msg.message == WM_USER && msg.hwnd == d->internalHwnd)) {
+ && (msg.message == WM_QT_SOCKETNOTIFIER && msg.hwnd == d->internalHwnd)) {
// queue socket events for later processing
haveMessage = false;
d->queuedSocketEvents.append(msg);
@@ -706,7 +725,13 @@ bool QEventDispatcherWin32::processEvents(QEventLoop::ProcessEventsFlags flags)
}
}
if (haveMessage) {
- if (msg.message == WM_TIMER) {
+ if (msg.message == WM_QT_SENDPOSTEDEVENTS) {
+ if (seenWM_QT_SENDPOSTEDEVENTS) {
+ needWM_QT_SENDPOSTEDEVENTS = true;
+ continue;
+ }
+ seenWM_QT_SENDPOSTEDEVENTS = true;
+ } else if (msg.message == WM_TIMER) {
// avoid live-lock by keeping track of the timers we've already sent
bool found = false;
for (int i = 0; !found && i < processedTimers.count(); ++i) {
@@ -736,9 +761,7 @@ bool QEventDispatcherWin32::processEvents(QEventLoop::ProcessEventsFlags flags)
}
// still nothing - wait for message or signalled objects
- QThreadData *data = d->threadData;
canWait = (!retVal
- && data->canWait
&& !d->interrupt
&& (flags & QEventLoop::WaitForMoreEvents));
if (canWait) {
@@ -757,6 +780,14 @@ bool QEventDispatcherWin32::processEvents(QEventLoop::ProcessEventsFlags flags)
}
} while (canWait);
+ if (!seenWM_QT_SENDPOSTEDEVENTS && (flags & QEventLoop::EventLoopExec) == 0) {
+ // when called "manually", always send posted events
+ QCoreApplicationPrivate::sendPostedEvents(0, 0, d->threadData);
+ }
+
+ if (needWM_QT_SENDPOSTEDEVENTS)
+ PostMessage(d->internalHwnd, WM_QT_SENDPOSTEDEVENTS, 0, 0);
+
return retVal;
}
@@ -990,7 +1021,11 @@ void QEventDispatcherWin32::activateEventNotifiers()
void QEventDispatcherWin32::wakeUp()
{
Q_D(QEventDispatcherWin32);
- SetEvent(d->wakeUpNotifier.handle());
+ d->serialNumber.ref();
+ if (d->internalHwnd && d->wakeUps.testAndSetAcquire(0, 1)) {
+ // post a WM_QT_SENDPOSTEDEVENTS to this thread if there isn't one already pending
+ PostMessage(d->internalHwnd, WM_QT_SENDPOSTEDEVENTS, 0, 0);
+ }
}
void QEventDispatcherWin32::interrupt()
@@ -1003,13 +1038,8 @@ void QEventDispatcherWin32::interrupt()
void QEventDispatcherWin32::flush()
{ }
-
void QEventDispatcherWin32::startingUp()
-{
- Q_D(QEventDispatcherWin32);
-
- if (d->wakeUpNotifier.handle()) d->wakeUpNotifier.setEnabled(true);
-}
+{ }
void QEventDispatcherWin32::closingDown()
{
diff --git a/src/corelib/kernel/qfunctions_wince.h b/src/corelib/kernel/qfunctions_wince.h
index f7ca195dac..ad9d3a158a 100644
--- a/src/corelib/kernel/qfunctions_wince.h
+++ b/src/corelib/kernel/qfunctions_wince.h
@@ -192,7 +192,11 @@ int qt_wince__rmdir(const char *dirname);
int qt_wince__access( const char *path, int pmode );
int qt_wince__rename( const char *oldname, const char *newname );
int qt_wince__remove( const char *name );
+#ifdef __cplusplus
+int qt_wince_open( const char *filename, int oflag, int pmode = 0 );
+#else
int qt_wince_open( const char *filename, int oflag, int pmode );
+#endif
int qt_wince_stat( const char *path, struct stat *buffer );
int qt_wince__fstat( int handle, struct stat *buffer);
diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp
index f98c4490d4..6e6da191d6 100644
--- a/src/corelib/kernel/qmetaobject.cpp
+++ b/src/corelib/kernel/qmetaobject.cpp
@@ -574,8 +574,8 @@ int QMetaObjectPrivate::indexOfSignalRelative(const QMetaObject **baseObject, co
if (i >= 0 && m && m->d.superdata) {
int conflict = m->d.superdata->indexOfMethod(signal);
if (conflict >= 0)
- qWarning("QMetaObject::indexOfSignal:%s: Conflict with %s::%s",
- m->d.stringdata, m->d.superdata->d.stringdata, signal);
+ qWarning("QMetaObject::indexOfSignal: signal %s from %s redefined in %s",
+ signal, m->d.superdata->d.stringdata, m->d.stringdata);
}
#endif
return i;
@@ -2237,7 +2237,10 @@ bool QMetaProperty::write(QObject *object, const QVariant &value) const
// -1 (unchanged): normal qt_metacall, result stored in argv[0]
// changed: result stored directly in value, return the value of status
int status = -1;
- void *argv[] = { 0, &v, &status };
+ // the flags variable is used by the declarative module to implement
+ // interception of property writes.
+ int flags = 0;
+ void *argv[] = { 0, &v, &status, &flags };
if (t == QVariant::LastType)
argv[0] = &v;
else
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index a8120cf008..1260d47530 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -582,7 +582,7 @@ int QMetaCallEvent::placeMetaCall(QObject *object)
QObjects organize themselves in object trees. When you create a
QObject with another object as parent, the object will
automatically add itself to the parent's children() list. The
- parent takes ownership of the object i.e. it will automatically
+ parent takes ownership of the object; i.e., it will automatically
delete its children in its destructor. You can look for an object
by name and optionally type using findChild() or findChildren().
@@ -646,7 +646,7 @@ int QMetaCallEvent::placeMetaCall(QObject *object)
to be stored in one of the container classes. You must store
pointers.
- \section2 Auto-Connection
+ \section1 Auto-Connection
Qt's meta-object system provides a mechanism to automatically connect
signals and slots between QObject subclasses and their children. As long
@@ -660,7 +660,7 @@ int QMetaCallEvent::placeMetaCall(QObject *object)
given in the \l{Using a Designer UI File in Your Application} section of
the \QD manual.
- \section2 Dynamic Properties
+ \section1 Dynamic Properties
From Qt 4.2, dynamic properties can be added to and removed from QObject
instances at run-time. Dynamic properties do not need to be declared at
@@ -673,6 +673,15 @@ int QMetaCallEvent::placeMetaCall(QObject *object)
and both standard Qt widgets and user-created forms can be given dynamic
properties.
+ \section1 Internationalization (i18n)
+
+ All QObject subclasses support Qt's translation features, making it possible
+ to translate an application's user interface into different languages.
+
+ To make user-visible text translatable, it must be wrapped in calls to
+ the tr() function. This is explained in detail in the
+ \l{Writing Source Code for Translation} document.
+
\sa QMetaObject, QPointer, QObjectCleanupHandler, Q_DISABLE_COPY()
{Object Trees and Object Ownership}
*/
@@ -835,14 +844,7 @@ QObject::QObject(QObjectPrivate &dd, QObject *parent)
QObject::~QObject()
{
Q_D(QObject);
- if (d->wasDeleted) {
-#if defined(QT_DEBUG)
- qWarning("QObject: Double deletion detected");
-#endif
- return;
- }
d->wasDeleted = true;
-
d->blockSig = 0; // unblock signals so we always emit destroyed()
if (!d->isWidget) {
@@ -2157,65 +2159,10 @@ void QObject::deleteLater()
otherwise returns \a sourceText itself if no appropriate translated string
is available.
- See the sections below on Disambiguation and Handling Plurals for more
- information about the optional \a disambiguation and \a n parameters.
-
- QObject and its subclasses obtain translated strings from any translator
- objects that have been installed on the application object; see the
- QTranslator documentation for details about this mechanism.
-
- A translatable string is referenced by its translation context;
- this is the name of the QObject subclass whose tr() function is invoked,
- as in the following example:
-
+ Example:
\snippet mainwindows/sdi/mainwindow.cpp implicit tr context
\dots
- Here, the context is \c MainWindow because it is the \c MainWindow::tr()
- function that is invoked. Translation contexts can be given explicitly
- by fully qualifying the call to tr(); for example:
-
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp explicit tr context
-
- This call obtains the translated text for "Page up" from the \c QScrollBar
- context.
-
- \section1 Defining Translation Contexts
-
- The translation context for QObject and each QObject subclass is the
- class name itself. Developers subclassing QObject must use the
- Q_OBJECT macro in their class definition to override the translation
- context. This macro sets the context to the name of the subclass.
-
- If Q_OBJECT is not used in a class definition, the context will be
- inherited from the base class. For example, since all QObject-based
- classes in Qt provide a context, a new QWidget subclass defined without
- a Q_OBJECT macro will use the "QWidget" context if its tr() function
- is invoked.
-
- \section1 Translator Comments
-
- Developers can include information about each translatable string to
- help translators with the translation process. These are extracted
- when \l lupdate is used to process the source files. The recommended
- way to add comments is to annotate the tr() calls in your code with
- comments of the form:
-
- \tt{//: ...}
-
- or
-
- \tt{\begincomment: ... \endcomment}
-
- Examples:
-
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 40
-
- In these examples, the comments will be associated with the strings
- passed to tr() in the context of each call.
-
- \section1 Disambiguation
-
If the same \a sourceText is used in different roles within the
same context, an additional identifying string may be passed in
\a disambiguation (0 by default). In Qt 4.4 and earlier, this was
@@ -2224,76 +2171,12 @@ void QObject::deleteLater()
Example:
\snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 17
+ \dots
- \section1 Meta Data
-
- Additional data can be attached to each translatable message.
- The syntax:
-
- \tt{//= <id>}
-
- can be used to give the message a unique identifier to support tools
- which need it.
- The syntax:
-
- \tt{//~ <field name> <field contents>}
-
- can be used to attach meta data to the message. The field name should consist
- of a domain prefix (possibly the conventional file extension of the file format
- the field is inspired by), a hyphen and the actual field name in
- underscore-delimited notation. For storage in TS files, the field name together
- with the prefix "extra-" will form an XML element name. The field contents will
- be XML-escaped, but otherwise appear verbatim as the element's contents.
- Any number of unique fields can be added to each message.
-
- Example:
-
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp meta data
-
- Meta data appearing right in front of a magic TRANSLATOR comment applies to the
- whole TS file.
-
- \section1 Character Encodings
-
- You can set the encoding for \a sourceText by calling QTextCodec::setCodecForTr().
- By default \a sourceText is assumed to be in Latin-1 encoding.
-
- \section1 Handling Plurals
-
- If \a n >= 0, all occurrences of \c %n in the resulting string
- are replaced with a decimal representation of \a n. In addition,
- depending on \a n's value, the translation text may vary.
-
- Example:
-
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 18
-
- The table below shows what string is returned depending on the
- active translation:
-
- \table
- \header \o \o{3,1} Active Translation
- \header \o \a n \o No Translation \o French \o English
- \row \o 0 \o "0 message(s) saved" \o "0 message sauvegard\unicode{0xE9}" \o "0 message\bold{s} saved"
- \row \o 1 \o "1 message(s) saved" \o "1 message sauvegard\unicode{0xE9}" \o "1 message saved"
- \row \o 2 \o "2 message(s) saved" \o "2 message\bold{s} sauvegard\unicode{0xE9}\bold{s}" \o "2 message\bold{s} saved"
- \row \o 37 \o "37 message(s) saved" \o "37 message\bold{s} sauvegard\unicode{0xE9}\bold{s}" \o "37 message\bold{s} saved"
- \endtable
-
- This idiom is more flexible than the traditional approach; e.g.,
-
- \snippet doc/src/snippets/code/src_corelib_kernel_qobject.cpp 19
-
- because it also works with target languages that have several
- plural forms (e.g., Irish has a special "dual" form that should
- be used when \c n is 2), and it handles the \e n == 0 case
- correctly for languages such as French that require the singular.
- See the \l{Qt Linguist Manual} for details.
-
- Instead of \c %n, you can use \c %Ln to produce a localized
- representation of \a n. The conversion uses the default locale,
- set using QLocale::setDefault(). (If no default locale was
- specified, the "C" locale is used.)
+ See \l{Writing Source Code for Translation} for a detailed description of
+ Qt's translation mechanisms in general, and the
+ \l{Writing Source Code for Translation#Disambiguation}{Disambiguation}
+ section for information on disambiguation.
\warning This method is reentrant only if all translators are
installed \e before calling this method. Installing or removing
@@ -3332,6 +3215,7 @@ void QMetaObject::activate(QObject *sender, const QMetaObject *m, int local_sign
QObjectConnectionListVector *connectionLists = sender->d_func()->connectionLists;
if (!connectionLists) {
+ locker.unlock();
if (qt_signal_spy_callback_set.signal_end_callback != 0)
qt_signal_spy_callback_set.signal_end_callback(sender, signal_absolute_index);
return;
@@ -3401,11 +3285,11 @@ void QMetaObject::activate(QObject *sender, const QMetaObject *m, int local_sign
}
#endif
- locker.relock();
-
if (qt_signal_spy_callback_set.slot_end_callback != 0)
qt_signal_spy_callback_set.slot_end_callback(receiver, method);
+ locker.relock();
+
QObjectPrivate::resetCurrentSender(receiver, &currentSender, previousSender);
if (connectionLists->orphaned)
diff --git a/src/corelib/kernel/qsharedmemory_unix.cpp b/src/corelib/kernel/qsharedmemory_unix.cpp
index 1165fb1c62..a850df084e 100644
--- a/src/corelib/kernel/qsharedmemory_unix.cpp
+++ b/src/corelib/kernel/qsharedmemory_unix.cpp
@@ -50,7 +50,6 @@
#include <errno.h>
#ifndef QT_NO_SHAREDMEMORY
-
#include <sys/types.h>
#include <sys/ipc.h>
#include <sys/shm.h>
@@ -58,9 +57,11 @@
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
+#endif //QT_NO_SHAREDMEMORY
#include "private/qcore_unix_p.h"
+#ifndef QT_NO_SHAREDMEMORY
QT_BEGIN_NAMESPACE
QSharedMemoryPrivate::QSharedMemoryPrivate()
diff --git a/src/corelib/kernel/qtcore_eval.cpp b/src/corelib/kernel/qtcore_eval.cpp
new file mode 100644
index 0000000000..fe47a30403
--- /dev/null
+++ b/src/corelib/kernel/qtcore_eval.cpp
@@ -0,0 +1,569 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <qcoreevent.h>
+#include <qdatetime.h>
+#include <qlibraryinfo.h>
+#include <qobject.h>
+#include <qcoreapplication.h>
+
+#include "stdio.h"
+#include "stdlib.h"
+
+QT_BEGIN_NAMESPACE
+
+#include "qconfig_eval.cpp"
+
+static const char boilerplate_unsuported[] =
+ "\nQt %1 Evaluation License\n"
+ "Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).\n"
+ "All rights reserved.\n\n"
+ "This trial version may only be used for evaluation purposes\n"
+ "and will shut down after 120 minutes.\n"
+ "Registered to:\n"
+ " Licensee: %2\n\n"
+ "The evaluation expires in %4 days\n\n"
+ "Contact http://qt.nokia.com/about/contact-us for pricing and purchasing information.\n";
+
+static const char boilerplate_supported[] =
+ "\nQt %1 Evaluation License\n"
+ "Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).\n"
+ "All rights reserved.\n\n"
+ "This trial version may only be used for evaluation purposes\n"
+ "Registered to:\n"
+ " Licensee: %2\n\n"
+ "The evaluation expires in %4 days\n\n"
+ "Contact http://qt.nokia.com/about/contact-us for pricing and purchasing information.\n";
+
+static const char boilerplate_expired[] =
+ "This software is using the trial version of the Qt GUI toolkit.\n"
+ "The trial period has expired. If you need more time to\n"
+ "evaluate Qt, or if you have any questions about Qt, contact us\n"
+ "at: http://qt.nokia.com/about/contact-us.\n\n";
+
+static const char will_shutdown_1min[] =
+ "\nThe evaluation of Qt will SHUT DOWN in 1 minute.\n"
+ "Contact http://qt.nokia.com/about/contact-us for pricing and purchasing information.\n";
+
+static const char will_shutdown_now[] =
+ "\nThe evaluation of Qt has now reached its automatic\n"
+ "timeout and will shut down.\n"
+ "Contact http://qt.nokia.com/about/contact-us for pricing and purchasing information.\n";
+
+static int qt_eval_days_left()
+{
+ const char *const license_key = qt_eval_key_data + 12;
+
+ // fast fail
+ if (!qt_eval_key_data[0] || !*license_key)
+ return -2;
+
+ QDate today = QDate::currentDate();
+ QDate build = QLibraryInfo::buildDate();
+ return qMax(-1, today.daysTo(build) + 30);
+}
+
+static int qt_eval_is_supported()
+{
+ const char *const license_key = qt_eval_key_data + 12;
+ if (!qt_eval_key_data[0] || !*license_key)
+ return -1;
+
+ // is this an unsupported evaluation?
+ const char* typecode = license_key;
+ int field = 2;
+ for ( ; field && *typecode; ++typecode)
+ if (*typecode == '-')
+ --field;
+
+ if (!field && typecode[1] == '4' && typecode[2] == 'M') {
+ if (typecode[0] == 'Q')
+ return 0;
+ else if (typecode[0] == 'R' || typecode[0] == 'Z')
+ return 1;
+ }
+ return -1;
+}
+
+static QString qt_eval_string()
+{
+ const char *msg;
+ switch (qt_eval_is_supported()) {
+ case 0:
+ msg = boilerplate_unsuported;
+ break;
+ case 1:
+ msg = boilerplate_supported;
+ break;
+ default:
+ return QString();
+ msg = 0;
+ }
+
+ return QString::fromLatin1(msg)
+ .arg(QLatin1String(QT_VERSION_STR))
+ .arg(QLibraryInfo::licensee())
+ .arg(qt_eval_days_left());
+}
+
+#define WARN_TIMEOUT 60 * 1000 * 119
+#define KILL_DELAY 60 * 1000 * 1
+
+class QCoreFuriCuri : public QObject
+{
+public:
+
+ int warn;
+ int kill;
+
+ QCoreFuriCuri() : QObject(), warn(-1), kill(-1)
+ {
+ if (!qt_eval_is_supported()) {
+ warn = startTimer(WARN_TIMEOUT);
+ kill = 0;
+ }
+ }
+
+ void timerEvent(QTimerEvent *e) {
+ if (e->timerId() == warn) {
+ killTimer(warn);
+ fprintf(stderr, "%s\n", will_shutdown_1min);
+ kill = startTimer(KILL_DELAY);
+ } else if (e->timerId() == kill) {
+ fprintf(stderr, "%s\n", will_shutdown_now);
+ QCoreApplication::instance()->quit();
+ }
+ }
+};
+
+#if defined(QT_BUILD_CORE_LIB) || defined (QT_BOOTSTRAPPED)
+
+void qt_core_eval_init(uint type)
+{
+ switch (qt_eval_days_left()) {
+ case -2:
+ return;
+
+ case -1:
+ fprintf(stderr, "%s\n", boilerplate_expired);
+ if (type == 0) {
+ // if we're a console app only.
+ exit(0);
+ }
+
+ default:
+ fprintf(stderr, "%s\n", qPrintable(qt_eval_string()));
+ if (type == 0) {
+ Q_UNUSED(new QCoreFuriCuri());
+ }
+ }
+}
+#endif
+
+#ifdef QT_BUILD_GUI_LIB
+
+QT_BEGIN_INCLUDE_NAMESPACE
+#include <qdialog.h>
+#include <qlabel.h>
+#include <qlayout.h>
+#include <qmessagebox.h>
+#include <qpushbutton.h>
+#include <qtimer.h>
+#include <qapplication.h>
+QT_END_INCLUDE_NAMESPACE
+
+
+static const char * const qtlogo_eval_xpm[] = {
+/* columns rows colors chars-per-pixel */
+"46 55 174 2",
+" c #002E02",
+". c #00370D",
+"X c #003A0E",
+"o c #003710",
+"O c #013C13",
+"+ c #043E1A",
+"@ c #084F0A",
+"# c #0B520C",
+"$ c #054413",
+"% c #0C4C17",
+"& c #07421D",
+"* c #09451D",
+"= c #0D491E",
+"- c #125515",
+"; c #13541A",
+": c #17591B",
+"> c #1B5C1D",
+", c #1F611F",
+"< c #20621E",
+"1 c #337B1E",
+"2 c #0B4521",
+"3 c #0F4923",
+"4 c #114B24",
+"5 c #154D2A",
+"6 c #175323",
+"7 c #1C5924",
+"8 c #1C532F",
+"9 c #1E5432",
+"0 c #245936",
+"q c #265938",
+"w c #295C3B",
+"e c #246324",
+"r c #266823",
+"t c #2A6C24",
+"y c #276628",
+"u c #2D7026",
+"i c #327427",
+"p c #367927",
+"a c #37782A",
+"s c #397C2A",
+"d c #2E613E",
+"f c #336C37",
+"g c #2F6040",
+"h c #356545",
+"j c #3C6B4E",
+"k c #3F6C51",
+"l c #406E4F",
+"z c #406D52",
+"x c #477457",
+"c c #497557",
+"v c #4B7857",
+"b c #517B5E",
+"n c #3C8423",
+"m c #3E812C",
+"M c #53A61D",
+"N c #41862C",
+"B c #458A2D",
+"V c #498F2D",
+"C c #479324",
+"Z c #489226",
+"A c #4D952C",
+"S c #478B30",
+"D c #488C30",
+"F c #4D9232",
+"G c #509632",
+"H c #549A33",
+"J c #589F35",
+"K c #56A526",
+"L c #57A821",
+"P c #5BAA27",
+"I c #57A32A",
+"U c #5CA72E",
+"Y c #5DAB2A",
+"T c #5CA336",
+"R c #60AD2E",
+"E c #63B12D",
+"W c #65AF35",
+"Q c #62A53F",
+"! c #65AE39",
+"~ c #66B036",
+"^ c #6AB437",
+"/ c #67B138",
+"( c #6AB339",
+") c #6DB838",
+"_ c #70BA3C",
+"` c #4D8545",
+"' c #4E8942",
+"] c #548851",
+"[ c #6FAF4A",
+"{ c #6DB243",
+"} c #71B546",
+"| c #70B840",
+" . c #73B648",
+".. c #79BA4E",
+"X. c #7CBB53",
+"o. c #598266",
+"O. c #62886D",
+"+. c #6A8F75",
+"@. c #6B9173",
+"#. c #70937A",
+"$. c #799F79",
+"%. c #7BAF66",
+"&. c #81BD5B",
+"*. c #85BF60",
+"=. c #85AC7F",
+"-. c #8DBA7B",
+";. c #87C061",
+":. c #8AC364",
+">. c #8DC46A",
+",. c #90C56E",
+"<. c #93C771",
+"1. c #96CA73",
+"2. c #9ACB7C",
+"3. c #9FD07D",
+"4. c #779981",
+"5. c #7F9F89",
+"6. c #809F88",
+"7. c #82A18B",
+"8. c #86A192",
+"9. c #8DA994",
+"0. c #8FA998",
+"q. c #94AF9B",
+"w. c #97B991",
+"e. c #97B19E",
+"r. c #9DB6A3",
+"t. c #A3BCA7",
+"y. c #A6BCAB",
+"u. c #A9BEB1",
+"i. c #9ECD81",
+"p. c #A2CF85",
+"a. c #A5D284",
+"s. c #A6D189",
+"d. c #A9D28E",
+"f. c #ABD491",
+"g. c #B1D797",
+"h. c #B1D699",
+"j. c #B5D89E",
+"k. c #ADC5AC",
+"l. c #B1CAAE",
+"z. c #B9DAA3",
+"x. c #BDDDA8",
+"c. c #ADC1B4",
+"v. c #B2C6B6",
+"b. c #B5C6BC",
+"n. c #B6C9BA",
+"m. c #BCD1BA",
+"M. c #C6E1B4",
+"N. c #CDE5BD",
+"B. c #C2D2C6",
+"V. c #CADEC2",
+"C. c #C6D3CC",
+"Z. c #C8D7CB",
+"A. c #CEDAD2",
+"S. c #D2DDD4",
+"D. c #D3E9C6",
+"F. c #D7EBC9",
+"G. c #D9EBCD",
+"H. c #DEEED4",
+"J. c #D6E0D9",
+"K. c #DAE4DC",
+"L. c #E0EFD7",
+"P. c #E5F2DD",
+"I. c #DFE8E0",
+"U. c #E4EBE5",
+"Y. c #E9EFEA",
+"T. c #EDF4EB",
+"R. c #F0FAE6",
+"E. c #F1F8EC",
+"W. c #EDF0F0",
+"Q. c #F4F7F3",
+"!. c #F6F9F4",
+"~. c #F8FAF7",
+"^. c #FEFEFE",
+"/. c None",
+/* pixels */
+"/././././.c h ' Q / W _ &.p././././././././././././././././././././././././././././././././.",
+"/././.4 O % Z ~ ~ W ~ W R U R R ( X.>.p././././././././././././././././././././././././././.",
+"/./.. * = J _ ~ ~ ~ ~ ~ / / / / W W U P P U W .;.2././././././././././././././././././././.",
+"/.= = & a ) W ~ ~ ~ ~ ~ / W / ~ ~ ~ ^ ( ( ^ ~ R R U P Y ~ .;.2././././././././././././././.",
+"O.O = = T ^ W ~ ~ ~ ~ ~ ~ W W / W ~ ~ ~ ~ ~ ~ ~ ( ( ( ( ~ W Y Y Y Y W { &.1././././././././.",
+"0 = * 7 ~ ~ ~ ~ ~ ~ ~ ~ ~ / / W ~ ~ ~ ~ ~ ~ ~ ~ W W W ~ ~ ~ ~ ( ( ( W W R U P U W { X.1.f./.",
+"= = & e ^ W ~ ~ ~ ~ ~ ~ ~ ~ / / ~ ~ ~ ~ ~ ~ ~ ~ W ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ^ ( ( / ~ W R U U Y ",
+"= = & e ^ W ~ ~ ~ ~ ~ ~ ~ ~ W W ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ W ( W ~ ~ ~ ^ ^ ( ",
+"= = * e ^ W ~ ~ ~ ~ ~ ~ / W / W ! ( / ~ W ^ ( ( ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ W ~ W W ~ ~ ~ ~ ~ ~ ",
+"= = & e ^ ! ~ ~ ~ ~ ~ ~ W W ^ _ ~ K Y W W R P Y W ( ~ ~ ~ ~ ~ ~ ~ W / ~ ~ ~ ^ W ~ ~ ~ ~ ~ ~ ",
+"= = & e ^ W ~ ~ ~ ~ ~ ~ W ) W 1 ` w.V.L.H.D.z.,.~ Y ^ ~ ~ ~ ~ ~ W ~ ~ ~ ( ~ W W ~ ~ ~ ~ ~ ~ ",
+"= = & e ^ W ~ ~ ~ ~ ~ W ) V = 8.~.^.^.^.^.^.^.^.U.<.Y ~ ~ ~ ~ ~ W W ! ~ Y W ^ W ~ ~ ~ ~ ~ ~ ",
+"= = & e ^ W ~ ~ ~ ~ W ^ B O u.^.~.^.^.^.^.~.~.^.^.^.h.Y ^ ~ ~ ^ F $ k.R.G.1.Y / ~ ~ ~ ~ ~ ~ ",
+"= = & e ^ ~ ~ ~ / W ( J X 7.^.~.^.^.^.^.^.^.^.^.^.^.^.s.Y / W ) a 2 U.^.^.d.U ( ~ ~ ~ ~ ~ ~ ",
+"= = & e ^ W / ~ ~ ~ ^ > w ~.^.^.^.^.^.F.%.v c.^.^.^.^.~.X.W ~ ^ > h ^.^.^.d.P ( ~ ~ ~ ~ ~ ~ ",
+"= = & e ^ W ~ ~ W ^ H o e.^.^.^.^.^.G.Y E n . y.^.^.^.^.M.Y ( ! $ @.^.~.^.f.U ( / ~ ~ W ~ ~ ",
+"= = & e ^ W ~ W ! ) t 4 U.^.^.^.^.^.>.U ( _ , 9 ~.^.^.^.~...^ A y.^.~.^.s.M W Y ~ ~ ~ ~ ~ ",
+"= 3 & e ^ W ~ ( ^ ( $ c ^.^.^.^.^.E.) ~ ~ ^ S o n.^.^.^.^.=.- l.v.Y.^.^.^.M.:.:.X.~ ~ ~ ~ ~ ",
+"= = & e ^ ! W W ( J X 7.^.^.^.^.^.F.Y ( W ^ T X 6.^.^.~.^.c.. J.^.^.^.^.^.^.^.^.P.~ ~ ~ ~ ~ ",
+"= = & r ^ W / W ) B o v.^.~.^.^.^.M.U / ~ ~ ! $ o.^.^.^.^.K.* S.^.^.^.^.^.^.^.^.P.~ ~ ~ ~ ~ ",
+"= = & e ^ ! ~ W ) a + S.^.^.^.^.^.z.P ( W ~ ( % z ^.^.^.^.~.f t.U.^.^.^.^.~.^.^.P.~ ~ ~ ~ ~ ",
+"* = & e ^ W ~ W ) t 3 Y.^.^.^.^.^.f.P ( ~ ~ ^ ; h ^.^.^.^.^.:.@ j ^.^.^.^.h.{ X.&.~ ~ ~ ~ ~ ",
+"3 = & e ^ W ~ ~ ^ e 8 Q.^.^.^.^.^.s.P ~ ~ W ^ > 0 ~.^.^.^.^.1.# z ^.^.^.^.d.L W R ~ ~ ~ ~ ~ ",
+"= = & e ^ W ~ ~ ^ > q ~.^.^.^.^.^.p.U ^ ~ W ) e 9 ~.^.^.^.^.3.# k ^.^.^.^.f.Y ( / ~ ~ ~ ~ ~ ",
+"= = & e ^ W / W ^ > w ~.^.^.^.^.^.i.Y / ~ W ^ e 8 Q.^.^.^.^.a.# z ^.^.^.^.f.Y / ~ ~ ~ ~ ~ ~ ",
+"= = & e ^ W / W ^ > w ^.^.^.^.^.^.2.Y / ~ ~ ) e 8 Q.^.^.^.^.s.# z ^.^.^.^.d.P ( ~ ~ ~ ~ ~ ~ ",
+"= = & e ^ W W W ^ > q ^.^.^.^.^.^.p.Y / ~ ~ ^ e 9 Q.^.^.^.^.a.@ z ^.^.^.^.f.U / ~ ~ ~ ~ ~ ~ ",
+"= = & e ^ W / W ) 7 9 Q.^.^.^.^.^.a.P / ~ W ) , 9 Q.^.^.^.^.3.# z ^.^.~.^.f.P ^ ~ ~ ~ ~ ~ ~ ",
+"= = & e ^ W / W ) r 5 T.^.^.^.^.^.d.Y / ~ W ) > q ~.^.^.^.^.1.# k ^.^.^.^.f.Y ( ~ ~ ~ ~ ~ ~ ",
+"= = & e ^ / / W ) i 2 I.^.^.^.^.^.h.P ( ~ W ( > g ^.^.^.^.^.:.# z ^.^.^.^.f.P / ~ ~ ~ ~ ~ ~ ",
+"= = & e ( W / W ) m O Z.^.^.^.^.^.x.P / ~ ~ ( ; j ^.^.^.^.~.&.- k ^.^.~.^.f.P / ~ ~ ~ ~ ~ ~ ",
+"= = & e ( W / W ) F o y.^.~.^.^.^.N.U ( ~ ~ W $ b ^.^.^.^.R._ - k ^.^.^.^.f.Y ( ~ ~ ~ ~ ~ ~ ",
+"= = & e ^ W ~ ~ ^ J X 4.^.^.^.^.^.L.~ ~ W ^ T X #.^.^.^.^.F.~ ; j ^.^.^.^.f.U ( ~ ~ ~ ~ ~ ~ ",
+"= = & e ^ ~ ~ ~ / ^ % l ^.^.^.^.^.!. .R ^ ^ G . r.^.~.^.^.j.E : j ^.^.^.^.f.P ) ( ~ ~ ~ ~ ~ ",
+"= = & e ^ W ~ ~ W ) u = U.^.^.^.^.^.1.Y ! ) a & K.^.^.^.^.;.~ : j ^.^.~.^.z.M I I / ~ ~ W ~ ",
+"= = & e ( W ~ ~ W ( G . q.^.^.^.^.^.D.U ^ ! X o.^.^.^.^.P.~ ^ > g ^.^.^.^.E.-.$.m.X.W ~ ~ ~ ",
+"= = & e ^ / ~ ~ ^ ! ( > w ~.^.^.^.^.^.h.T > j T.^.^.~.^.a.Y _ i 3 U.^.^.^.^.^.^.^.X.R ~ ~ ~ ",
+"= = & e ^ / ~ ~ W W ^ H . 9.^.~.^.^.^.^.K.C.~.^.^.^.^.H.W W ^ T . q.^.~.^.^.^.^.^.X.R ~ ~ ~ ",
+"= = + e ^ W / ~ W W W ) m + B.^.~.^.^.^.^.^.^.^.^.^.E.X.Y ( W ^ B 6 y.^.^.^.E.D.2.( ~ ~ ~ ~ ",
+"= = * e ^ ! / ! W ^ W W ) a 4 b.^.^.^.^.^.^.^.^.^.P...Y ( ! W ! ^ W Z [ *.X.{ Y U ~ ~ ~ ~ ~ ",
+"= = & e ( W ~ ~ W / W / W ) A < +.A.~.^.^.^.^.!.p.W R ~ ~ ~ ~ ~ W / ) E U W W / ^ ~ ~ ~ ~ ~ ",
+"= = & e ^ W ~ ~ / W / / / W ( _ Z X 6.^.^.^.^.E.W ~ ^ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ / ~ ~ ~ ~ ~ ~ ~ ~ ",
+"= = & e ^ ~ ~ ~ W W / W ~ ~ ~ ~ ) ; h ^.^.^.^.^.d.M U ~ / ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ W ",
+"= = & e ^ W ~ ~ ^ W W / ~ ~ ~ W ) p + S.^.^.^.^.~.M.f. .W ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ .",
+"= = & e ^ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ W ( T O +.^.~.^.^.^.^.^.&.Y ( ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ W ( Y 2.",
+"= = & e ( W ~ ~ ~ ~ ~ ~ ~ ~ ~ / W ) N + b.^.^.^.^.^.^.&.R ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ W /.",
+"= = & e ^ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ W ^ N 7 r.W.^.^.^.!.X.W ~ ~ W ~ W ~ ~ ~ ~ ~ ~ / ( ( K p./.",
+"= = & e ( W ~ ~ W ~ ~ ~ ~ ~ ~ ~ ~ ~ W ( W C Q &.:.X.| ~ ~ ~ ~ W ~ / ~ ( / ( ~ W E U P 1././.",
+"= = + e ^ / / / ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ W / ) ^ R Y W W ~ ~ ( / ( / W R Y Y U R ( X.,././././.",
+"= = * e ( / ~ / ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ ~ W W W ! ( ( ( W W E U P Y W ( X.,.d./././././././././.",
+"= = * e ( W ~ ~ ~ ~ W ! ~ W ~ W ~ ( ( / ^ W W U Y P W ( X.,.d./././././././././././././././.",
+"8 $ * e ( W ~ ~ ~ ! ( ( ( / ( W R Y Y Y R ( X.>.d./././././././././././././././././././././.",
+"/.d . y ^ / / / ( W Y Y P P W ( X.>.d./././././././././././././././././././././././././././.",
+"/./.h : ^ R R R W ( X.<.f./././././././././././././././././././././././././././././././././.",
+"/././.] _ *.3./././././././././././././././././././././././././././././././././././././././."
+};
+
+class EvalMessageBox : public QDialog
+{
+public:
+ EvalMessageBox(bool expired)
+ {
+ setWindowTitle(QLatin1String(" "));
+
+ QString str = qt_eval_string();
+ if (expired) {
+ str = QLatin1String(boilerplate_expired);
+ } else {
+ str = qt_eval_string();
+ }
+ str = str.trimmed();
+
+ QFrame *border = new QFrame(this);
+
+ QLabel *pixmap_label = new QLabel(border);
+ pixmap_label->setPixmap(qtlogo_eval_xpm);
+ pixmap_label->setAlignment(Qt::AlignTop);
+
+ QLabel *text_label = new QLabel(str, border);
+
+ QHBoxLayout *pm_and_text_layout = new QHBoxLayout();
+ pm_and_text_layout->addWidget(pixmap_label);
+ pm_and_text_layout->addWidget(text_label);
+
+ QVBoxLayout *master_layout = new QVBoxLayout(border);
+ master_layout->addLayout(pm_and_text_layout);
+
+ QVBoxLayout *border_layout = new QVBoxLayout(this);
+ border_layout->setMargin(0);
+ border_layout->addWidget(border);
+
+ if (expired) {
+ QPushButton *cmd = new QPushButton(QLatin1String("OK"), border);
+ cmd->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);
+ cmd->setDefault(true);
+
+ QHBoxLayout *button_layout = new QHBoxLayout();
+ master_layout->addLayout(button_layout);
+ button_layout->addWidget(cmd);
+
+ connect(cmd, SIGNAL(clicked()), this, SLOT(close()));
+ } else {
+ border->setFrameShape(QFrame::WinPanel);
+ border->setFrameShadow(QFrame::Raised);
+ setParent(parentWidget(), Qt::FramelessWindowHint | Qt::WindowStaysOnTopHint);
+ QTimer::singleShot(7000, this, SLOT(close()));
+ setAttribute(Qt::WA_DeleteOnClose);
+ }
+
+ setFixedSize(sizeHint());
+ }
+};
+
+class QGuiFuriCuri : public QCoreFuriCuri
+{
+public:
+ void timerEvent(QTimerEvent *e) {
+ if (e->timerId() == warn) {
+ killTimer(warn);
+ QMessageBox::information(0, QLatin1String("Automatic Timeout"), QLatin1String(will_shutdown_1min));
+ kill = startTimer(KILL_DELAY);
+ } else if (e->timerId() == kill) {
+ killTimer(kill);
+ QMessageBox::information(0, QLatin1String("Automatic Timeout"), QLatin1String(will_shutdown_now));
+ qApp->quit();
+ }
+ }
+};
+
+
+void qt_gui_eval_init(uint)
+{
+ switch (qt_eval_days_left()) {
+ case -2:
+ return;
+
+ case -1: {
+ EvalMessageBox box(true);
+ box.exec();
+ ::exit(0);
+ }
+
+ default: {
+ EvalMessageBox *box = new EvalMessageBox(false);
+ box->show();
+ Q_UNUSED(new QGuiFuriCuri());
+ }
+ }
+}
+
+static QString qt_eval_title_prefix()
+{
+ return QLatin1String("[Qt Evaluation] ");
+}
+
+QString qt_eval_adapt_window_title(const QString &title)
+{
+ if (qt_eval_days_left() == -2)
+ return title;
+ return qt_eval_title_prefix() + title;
+}
+
+void qt_eval_init_widget(QWidget *w)
+{
+ if (qt_eval_days_left() == -2)
+ return;
+ if (w->isTopLevel()) {
+ QString windowTitle = w->windowTitle();
+ if (windowTitle.isEmpty()) {
+ w->setWindowTitle(QLatin1String(" "));
+ } else if (!windowTitle.startsWith(qt_eval_title_prefix())) {
+ qt_eval_adapt_window_title(windowTitle);
+ }
+ }
+}
+#endif
+
+QT_END_NAMESPACE
diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h
index eb4fb564eb..3c107882ca 100644
--- a/src/corelib/kernel/qvariant.h
+++ b/src/corelib/kernel/qvariant.h
@@ -456,10 +456,11 @@ template <typename T>
inline void qVariantSetValue(QVariant &v, const T &t)
{
//if possible we reuse the current QVariant private
- const int type = qMetaTypeId<T>(reinterpret_cast<T *>(0));
+ const uint type = qMetaTypeId<T>(reinterpret_cast<T *>(0));
QVariant::Private &d = v.data_ptr();
- if (v.isDetached() && (type <= int(QVariant::Char) || type == d.type)) {
+ if (v.isDetached() && (type <= uint(QVariant::Char) || type == d.type)) {
d.type = type;
+ d.is_null = false;
T *old = reinterpret_cast<T*>(d.is_shared ? d.data.shared->ptr : &d.data.ptr);
if (QTypeInfo<T>::isComplex)
old->~T();
@@ -469,6 +470,13 @@ inline void qVariantSetValue(QVariant &v, const T &t)
}
}
+template <>
+inline void qVariantSetValue<QVariant>(QVariant &v, const QVariant &t)
+{
+ v = t;
+}
+
+
inline QVariant::QVariant() {}
inline bool QVariant::isValid() const { return d.type != Invalid; }
@@ -558,9 +566,7 @@ inline bool operator!=(const QVariant &v1, const QVariantComparisonHelper &v2)
#endif
#ifndef QT_MOC
-#if !defined qdoc && defined Q_CC_MSVC && _MSC_VER < 1300
-
-template<typename T> T qvariant_cast(const QVariant &v, T * = 0)
+template<typename T> inline T qvariant_cast(const QVariant &v)
{
const int vid = qMetaTypeId<T>(static_cast<T *>(0));
if (vid == v.userType())
@@ -573,28 +579,12 @@ template<typename T> T qvariant_cast(const QVariant &v, T * = 0)
return T();
}
-template<typename T>
-inline T qVariantValue(const QVariant &variant, T *t = 0)
-{ return qvariant_cast<T>(variant, t); }
-
-template<typename T>
-inline bool qVariantCanConvert(const QVariant &variant, T *t = 0)
-{
- return variant.canConvert(static_cast<QVariant::Type>(qMetaTypeId<T>(t)));
-}
-#else
-
-template<typename T> T qvariant_cast(const QVariant &v)
+template<> inline QVariant qvariant_cast<QVariant>(const QVariant &v)
{
- const int vid = qMetaTypeId<T>(static_cast<T *>(0));
+ static const int vid = qRegisterMetaType<QVariant>("QVariant");
if (vid == v.userType())
- return *reinterpret_cast<const T *>(v.constData());
- if (vid < int(QMetaType::User)) {
- T t;
- if (qvariant_cast_helper(v, QVariant::Type(vid), &t))
- return t;
- }
- return T();
+ return *reinterpret_cast<const QVariant *>(v.constData());
+ return v;
}
template<typename T>
@@ -608,7 +598,6 @@ inline bool qVariantCanConvert(const QVariant &variant)
qMetaTypeId<T>(static_cast<T *>(0))));
}
#endif
-#endif
Q_DECLARE_SHARED(QVariant)
Q_DECLARE_TYPEINFO(QVariant, Q_MOVABLE_TYPE);
diff --git a/src/corelib/plugin/qlibrary.cpp b/src/corelib/plugin/qlibrary.cpp
index 2b463a1e57..649687639e 100644
--- a/src/corelib/plugin/qlibrary.cpp
+++ b/src/corelib/plugin/qlibrary.cpp
@@ -659,7 +659,10 @@ bool QLibraryPrivate::isPlugin(QSettings *settings)
#endif
if (!pHnd) {
#ifdef Q_OS_WIN
+ //avoid 'Bad Image' message box
+ UINT oldmode = SetErrorMode(SEM_FAILCRITICALERRORS|SEM_NOOPENFILEERRORBOX);
hTempModule = ::LoadLibraryEx((wchar_t*)QDir::toNativeSeparators(fileName).utf16(), 0, DONT_RESOLVE_DLL_REFERENCES);
+ SetErrorMode(oldmode);
#else
# if defined(Q_OS_SYMBIAN)
//Guard against accidentally trying to load non-plugin libraries by making sure the stub exists
diff --git a/src/corelib/statemachine/qabstractstate.cpp b/src/corelib/statemachine/qabstractstate.cpp
index 72d640bce9..ec5332f1ee 100644
--- a/src/corelib/statemachine/qabstractstate.cpp
+++ b/src/corelib/statemachine/qabstractstate.cpp
@@ -78,7 +78,8 @@ QT_BEGIN_NAMESPACE
function to perform custom processing when the state is exited.
*/
-QAbstractStatePrivate::QAbstractStatePrivate()
+QAbstractStatePrivate::QAbstractStatePrivate(StateType type)
+ : stateType(type), isMachine(false), parentState(0)
{
}
@@ -87,6 +88,11 @@ QAbstractStatePrivate *QAbstractStatePrivate::get(QAbstractState *q)
return q->d_func();
}
+const QAbstractStatePrivate *QAbstractStatePrivate::get(const QAbstractState *q)
+{
+ return q->d_func();
+}
+
QStateMachine *QAbstractStatePrivate::machine() const
{
QObject *par = parent;
@@ -126,7 +132,7 @@ void QAbstractStatePrivate::emitExited()
Constructs a new state with the given \a parent state.
*/
QAbstractState::QAbstractState(QState *parent)
- : QObject(*new QAbstractStatePrivate, parent)
+ : QObject(*new QAbstractStatePrivate(QAbstractStatePrivate::AbstractState), parent)
{
}
@@ -150,7 +156,10 @@ QAbstractState::~QAbstractState()
*/
QState *QAbstractState::parentState() const
{
- return qobject_cast<QState*>(parent());
+ Q_D(const QAbstractState);
+ if (d->parentState != parent())
+ d->parentState = qobject_cast<QState*>(parent());
+ return d->parentState;
}
/*!
diff --git a/src/corelib/statemachine/qabstractstate_p.h b/src/corelib/statemachine/qabstractstate_p.h
index 4b1306d712..faea6b6295 100644
--- a/src/corelib/statemachine/qabstractstate_p.h
+++ b/src/corelib/statemachine/qabstractstate_p.h
@@ -65,9 +65,17 @@ class QAbstractStatePrivate : public QObjectPrivate
Q_DECLARE_PUBLIC(QAbstractState)
public:
- QAbstractStatePrivate();
+ enum StateType {
+ AbstractState,
+ StandardState,
+ FinalState,
+ HistoryState
+ };
+
+ QAbstractStatePrivate(StateType type);
static QAbstractStatePrivate *get(QAbstractState *q);
+ static const QAbstractStatePrivate *get(const QAbstractState *q);
QStateMachine *machine() const;
@@ -76,6 +84,10 @@ public:
void emitEntered();
void emitExited();
+
+ uint stateType:31;
+ uint isMachine:1;
+ mutable QState *parentState;
};
QT_END_NAMESPACE
diff --git a/src/corelib/statemachine/qfinalstate.cpp b/src/corelib/statemachine/qfinalstate.cpp
index 761eee4dd9..d900ddd82e 100644
--- a/src/corelib/statemachine/qfinalstate.cpp
+++ b/src/corelib/statemachine/qfinalstate.cpp
@@ -92,6 +92,7 @@ public:
};
QFinalStatePrivate::QFinalStatePrivate()
+ : QAbstractStatePrivate(FinalState)
{
}
diff --git a/src/corelib/statemachine/qhistorystate.cpp b/src/corelib/statemachine/qhistorystate.cpp
index 0c2b85865a..18436d3121 100644
--- a/src/corelib/statemachine/qhistorystate.cpp
+++ b/src/corelib/statemachine/qhistorystate.cpp
@@ -120,7 +120,8 @@ QT_BEGIN_NAMESPACE
*/
QHistoryStatePrivate::QHistoryStatePrivate()
- : defaultState(0), historyType(QHistoryState::ShallowHistory)
+ : QAbstractStatePrivate(HistoryState),
+ defaultState(0), historyType(QHistoryState::ShallowHistory)
{
}
diff --git a/src/corelib/statemachine/qstate.cpp b/src/corelib/statemachine/qstate.cpp
index a6e4a57469..cf718a55d2 100644
--- a/src/corelib/statemachine/qstate.cpp
+++ b/src/corelib/statemachine/qstate.cpp
@@ -124,7 +124,9 @@ QT_BEGIN_NAMESPACE
*/
QStatePrivate::QStatePrivate()
- : errorState(0), initialState(0), childMode(QState::ExclusiveStates)
+ : QAbstractStatePrivate(StandardState),
+ errorState(0), initialState(0), childMode(QState::ExclusiveStates),
+ childStatesListNeedsRefresh(true), transitionsListNeedsRefresh(true)
{
}
@@ -138,10 +140,10 @@ void QStatePrivate::emitFinished()
emit q->finished();
}
-void QStatePrivate::emitPolished()
+void QStatePrivate::emitPropertiesAssigned()
{
Q_Q(QState);
- emit q->polished();
+ emit q->propertiesAssigned();
}
/*!
@@ -180,15 +182,18 @@ QState::~QState()
QList<QAbstractState*> QStatePrivate::childStates() const
{
- QList<QAbstractState*> result;
- QList<QObject*>::const_iterator it;
- for (it = children.constBegin(); it != children.constEnd(); ++it) {
- QAbstractState *s = qobject_cast<QAbstractState*>(*it);
- if (!s || qobject_cast<QHistoryState*>(s))
- continue;
- result.append(s);
+ if (childStatesListNeedsRefresh) {
+ childStatesList.clear();
+ QList<QObject*>::const_iterator it;
+ for (it = children.constBegin(); it != children.constEnd(); ++it) {
+ QAbstractState *s = qobject_cast<QAbstractState*>(*it);
+ if (!s || qobject_cast<QHistoryState*>(s))
+ continue;
+ childStatesList.append(s);
+ }
+ childStatesListNeedsRefresh = false;
}
- return result;
+ return childStatesList;
}
QList<QHistoryState*> QStatePrivate::historyStates() const
@@ -205,14 +210,17 @@ QList<QHistoryState*> QStatePrivate::historyStates() const
QList<QAbstractTransition*> QStatePrivate::transitions() const
{
- QList<QAbstractTransition*> result;
- QList<QObject*>::const_iterator it;
- for (it = children.constBegin(); it != children.constEnd(); ++it) {
- QAbstractTransition *t = qobject_cast<QAbstractTransition*>(*it);
- if (t)
- result.append(t);
+ if (transitionsListNeedsRefresh) {
+ transitionsList.clear();
+ QList<QObject*>::const_iterator it;
+ for (it = children.constBegin(); it != children.constEnd(); ++it) {
+ QAbstractTransition *t = qobject_cast<QAbstractTransition*>(*it);
+ if (t)
+ transitionsList.append(t);
+ }
+ transitionsListNeedsRefresh = false;
}
- return result;
+ return transitionsList;
}
#ifndef QT_NO_PROPERTIES
@@ -221,7 +229,7 @@ QList<QAbstractTransition*> QStatePrivate::transitions() const
Instructs this state to set the property with the given \a name of the given
\a object to the given \a value when the state is entered.
- \sa polished()
+ \sa propertiesAssigned()
*/
void QState::assignProperty(QObject *object, const char *name,
const QVariant &value)
@@ -279,15 +287,14 @@ void QState::setErrorState(QAbstractState *state)
/*!
Adds the given \a transition. The transition has this state as the source.
- This state takes ownership of the transition. If the transition is successfully
- added, the function will return the \a transition pointer. Otherwise it will return null.
+ This state takes ownership of the transition.
*/
-QAbstractTransition *QState::addTransition(QAbstractTransition *transition)
+void QState::addTransition(QAbstractTransition *transition)
{
Q_D(QState);
if (!transition) {
qWarning("QState::addTransition: cannot add null transition");
- return 0;
+ return ;
}
transition->setParent(this);
@@ -296,18 +303,17 @@ QAbstractTransition *QState::addTransition(QAbstractTransition *transition)
QAbstractState *t = targets.at(i).data();
if (!t) {
qWarning("QState::addTransition: cannot add transition to null state");
- return 0;
+ return ;
}
if ((QAbstractStatePrivate::get(t)->machine() != d->machine())
&& QAbstractStatePrivate::get(t)->machine() && d->machine()) {
qWarning("QState::addTransition: cannot add transition "
"to a state in a different state machine");
- return 0;
+ return ;
}
}
if (machine() != 0 && machine()->configuration().contains(this))
QStateMachinePrivate::get(machine())->registerTransitions(this);
- return transition;
}
/*!
@@ -372,7 +378,8 @@ QAbstractTransition *QState::addTransition(QAbstractState *target)
return 0;
}
UnconditionalTransition *trans = new UnconditionalTransition(target);
- return addTransition(trans);
+ addTransition(trans);
+ return trans;
}
/*!
@@ -468,6 +475,11 @@ void QState::setChildMode(ChildMode mode)
*/
bool QState::event(QEvent *e)
{
+ Q_D(QState);
+ if ((e->type() == QEvent::ChildAdded) || (e->type() == QEvent::ChildRemoved)) {
+ d->childStatesListNeedsRefresh = true;
+ d->transitionsListNeedsRefresh = true;
+ }
return QAbstractState::event(e);
}
@@ -480,9 +492,15 @@ bool QState::event(QEvent *e)
*/
/*!
- \fn QState::polished()
+ \fn QState::propertiesAssigned()
+
+ This signal is emitted when all properties have been assigned their final value. If the state
+ assigns a value to one or more properties for which an animation exists (either set on the
+ transition or as a default animation on the state machine), then the signal will not be emitted
+ until all such animations have finished playing.
- This signal is emitted when all properties have been assigned their final value.
+ If there are no relevant animations, or no property assignments defined for the state, then
+ the signal will be emitted immediately before the state is entered.
\sa QState::assignProperty(), QAbstractTransition::addAnimation()
*/
diff --git a/src/corelib/statemachine/qstate.h b/src/corelib/statemachine/qstate.h
index 7a47447de6..423f940452 100644
--- a/src/corelib/statemachine/qstate.h
+++ b/src/corelib/statemachine/qstate.h
@@ -76,7 +76,7 @@ public:
QAbstractState *errorState() const;
void setErrorState(QAbstractState *state);
- QAbstractTransition *addTransition(QAbstractTransition *transition);
+ void addTransition(QAbstractTransition *transition);
QSignalTransition *addTransition(QObject *sender, const char *signal, QAbstractState *target);
QAbstractTransition *addTransition(QAbstractState *target);
void removeTransition(QAbstractTransition *transition);
@@ -94,7 +94,7 @@ public:
Q_SIGNALS:
void finished();
- void polished();
+ void propertiesAssigned();
protected:
void onEntry(QEvent *event);
diff --git a/src/corelib/statemachine/qstate_p.h b/src/corelib/statemachine/qstate_p.h
index 20cda29cab..7fe6279e77 100644
--- a/src/corelib/statemachine/qstate_p.h
+++ b/src/corelib/statemachine/qstate_p.h
@@ -94,11 +94,15 @@ public:
QList<QAbstractTransition*> transitions() const;
void emitFinished();
- void emitPolished();
+ void emitPropertiesAssigned();
QAbstractState *errorState;
QAbstractState *initialState;
QState::ChildMode childMode;
+ mutable bool childStatesListNeedsRefresh;
+ mutable QList<QAbstractState*> childStatesList;
+ mutable bool transitionsListNeedsRefresh;
+ mutable QList<QAbstractTransition*> transitionsList;
QList<QPropertyAssignment> propertyAssignments;
};
diff --git a/src/corelib/statemachine/qstatemachine.cpp b/src/corelib/statemachine/qstatemachine.cpp
index e182c885e3..ecf3f9c1e8 100644
--- a/src/corelib/statemachine/qstatemachine.cpp
+++ b/src/corelib/statemachine/qstatemachine.cpp
@@ -159,12 +159,12 @@ QT_BEGIN_NAMESPACE
\brief the restore policy for states of this state machine.
The default value of this property is
- QStateMachine::DoNotRestoreProperties.
+ QStateMachine::DontRestoreProperties.
*/
#ifndef QT_NO_ANIMATION
/*!
- \property QStateMachine::animationsEnabled
+ \property QStateMachine::animated
\brief whether animations are enabled
@@ -178,6 +178,8 @@ QT_BEGIN_NAMESPACE
QStateMachinePrivate::QStateMachinePrivate()
{
+ QAbstractStatePrivate::isMachine = true;
+
state = NotRunning;
_startState = 0;
processing = false;
@@ -185,10 +187,10 @@ QStateMachinePrivate::QStateMachinePrivate()
stop = false;
stopProcessingReason = EventQueueEmpty;
error = QStateMachine::NoError;
- globalRestorePolicy = QStateMachine::DoNotRestoreProperties;
+ globalRestorePolicy = QStateMachine::DontRestoreProperties;
signalEventGenerator = 0;
#ifndef QT_NO_ANIMATION
- animationsEnabled = true;
+ animated = true;
#endif
}
@@ -336,7 +338,7 @@ QSet<QAbstractTransition*> QStateMachinePrivate::selectTransitions(QEvent *event
if (isPreempted(state, enabledTransitions))
continue;
QList<QState*> lst = properAncestors(state, rootState()->parentState());
- if (QState *grp = qobject_cast<QState*>(state))
+ if (QState *grp = toStandardState(state))
lst.prepend(grp);
bool found = false;
for (int j = 0; (j < lst.size()) && !found; ++j) {
@@ -414,7 +416,7 @@ QList<QAbstractState*> QStateMachinePrivate::exitStates(QEvent *event, const QLi
qSort(statesToExit_sorted.begin(), statesToExit_sorted.end(), stateExitLessThan);
for (int i = 0; i < statesToExit_sorted.size(); ++i) {
QAbstractState *s = statesToExit_sorted.at(i);
- if (QState *grp = qobject_cast<QState*>(s)) {
+ if (QState *grp = toStandardState(s)) {
QList<QHistoryState*> hlst = QStatePrivate::get(grp)->historyStates();
for (int j = 0; j < hlst.size(); ++j) {
QHistoryState *h = hlst.at(j);
@@ -563,7 +565,7 @@ void QStateMachinePrivate::addStatesToEnter(QAbstractState *s, QState *root,
QSet<QAbstractState*> &statesToEnter,
QSet<QAbstractState*> &statesForDefaultEntry)
{
- if (QHistoryState *h = qobject_cast<QHistoryState*>(s)) {
+ if (QHistoryState *h = toHistoryState(s)) {
QList<QAbstractState*> hconf = QHistoryStatePrivate::get(h)->configuration;
if (!hconf.isEmpty()) {
for (int k = 0; k < hconf.size(); ++k) {
@@ -600,7 +602,7 @@ void QStateMachinePrivate::addStatesToEnter(QAbstractState *s, QState *root,
}
statesToEnter.insert(s);
if (isParallel(s)) {
- QState *grp = qobject_cast<QState*>(s);
+ QState *grp = toStandardState(s);
QList<QAbstractState*> lst = QStatePrivate::get(grp)->childStates();
for (int i = 0; i < lst.size(); ++i) {
QAbstractState *child = lst.at(i);
@@ -608,7 +610,7 @@ void QStateMachinePrivate::addStatesToEnter(QAbstractState *s, QState *root,
}
} else if (isCompound(s)) {
statesForDefaultEntry.insert(s);
- QState *grp = qobject_cast<QState*>(s);
+ QState *grp = toStandardState(s);
QAbstractState *initial = grp->initialState();
if (initial != 0) {
Q_ASSERT(initial->machine() == q_func());
@@ -660,7 +662,7 @@ void QStateMachinePrivate::applyProperties(const QList<QAbstractTransition*> &tr
QHash<QAbstractState*, QList<QPropertyAssignment> > propertyAssignmentsForState;
QHash<RestorableId, QVariant> pendingRestorables = registeredRestorables;
for (int i = 0; i < enteredStates.size(); ++i) {
- QState *s = qobject_cast<QState*>(enteredStates.at(i));
+ QState *s = toStandardState(enteredStates.at(i));
if (!s)
continue;
@@ -742,7 +744,7 @@ void QStateMachinePrivate::applyProperties(const QList<QAbstractTransition*> &tr
// Find the animations to use for the state change.
QList<QAbstractAnimation*> selectedAnimations;
- if (animationsEnabled) {
+ if (animated) {
for (int i = 0; i < transitionList.size(); ++i) {
QAbstractTransition *transition = transitionList.at(i);
@@ -807,7 +809,7 @@ void QStateMachinePrivate::applyProperties(const QList<QAbstractTransition*> &tr
if (anim->state() == QAbstractAnimation::Running) {
// The animation is still running. This can happen if the
// animation is a group, and one of its children just finished,
- // and that caused a state to emit its polished() signal, and
+ // and that caused a state to emit its propertiesAssigned() signal, and
// that triggered a transition in the machine.
// Just stop the animation so it is correctly restarted again.
anim->stop();
@@ -829,15 +831,15 @@ void QStateMachinePrivate::applyProperties(const QList<QAbstractTransition*> &tr
}
}
- // Emit polished signal for entered states that have no animated properties.
+ // Emit propertiesAssigned signal for entered states that have no animated properties.
for (int i = 0; i < enteredStates.size(); ++i) {
- QState *s = qobject_cast<QState*>(enteredStates.at(i));
+ QState *s = toStandardState(enteredStates.at(i));
if (s
#ifndef QT_NO_ANIMATION
&& !animationsForState.contains(s)
#endif
)
- QStatePrivate::get(s)->emitPolished();
+ QStatePrivate::get(s)->emitPropertiesAssigned();
}
}
@@ -845,21 +847,21 @@ void QStateMachinePrivate::applyProperties(const QList<QAbstractTransition*> &tr
bool QStateMachinePrivate::isFinal(const QAbstractState *s)
{
- return qobject_cast<const QFinalState*>(s) != 0;
+ return s && (QAbstractStatePrivate::get(s)->stateType == QAbstractStatePrivate::FinalState);
}
bool QStateMachinePrivate::isParallel(const QAbstractState *s)
{
- const QState *ss = qobject_cast<const QState*>(s);
+ const QState *ss = toStandardState(s);
return ss && (QStatePrivate::get(ss)->childMode == QState::ParallelStates);
}
bool QStateMachinePrivate::isCompound(const QAbstractState *s) const
{
- const QState *group = qobject_cast<const QState*>(s);
+ const QState *group = toStandardState(s);
if (!group)
return false;
- bool isMachine = (qobject_cast<const QStateMachine*>(group) != 0);
+ bool isMachine = QStatePrivate::get(group)->isMachine;
// Don't treat the machine as compound if it's a sub-state of this machine
if (isMachine && (group != rootState()))
return false;
@@ -869,11 +871,11 @@ bool QStateMachinePrivate::isCompound(const QAbstractState *s) const
bool QStateMachinePrivate::isAtomic(const QAbstractState *s) const
{
- const QState *ss = qobject_cast<const QState*>(s);
+ const QState *ss = toStandardState(s);
return (ss && QStatePrivate::get(ss)->childStates().isEmpty())
|| isFinal(s)
// Treat the machine as atomic if it's a sub-state of this machine
- || (ss && (qobject_cast<const QStateMachine*>(ss) != 0) && (ss != rootState()));
+ || (ss && QStatePrivate::get(ss)->isMachine && (ss != rootState()));
}
@@ -897,10 +899,38 @@ QList<QState*> QStateMachinePrivate::properAncestors(const QAbstractState *state
return result;
}
+QState *QStateMachinePrivate::toStandardState(QAbstractState *state)
+{
+ if (state && (QAbstractStatePrivate::get(state)->stateType == QAbstractStatePrivate::StandardState))
+ return static_cast<QState*>(state);
+ return 0;
+}
+
+const QState *QStateMachinePrivate::toStandardState(const QAbstractState *state)
+{
+ if (state && (QAbstractStatePrivate::get(state)->stateType == QAbstractStatePrivate::StandardState))
+ return static_cast<const QState*>(state);
+ return 0;
+}
+
+QFinalState *QStateMachinePrivate::toFinalState(QAbstractState *state)
+{
+ if (state && (QAbstractStatePrivate::get(state)->stateType == QAbstractStatePrivate::FinalState))
+ return static_cast<QFinalState*>(state);
+ return 0;
+}
+
+QHistoryState *QStateMachinePrivate::toHistoryState(QAbstractState *state)
+{
+ if (state && (QAbstractStatePrivate::get(state)->stateType == QAbstractStatePrivate::HistoryState))
+ return static_cast<QHistoryState*>(state);
+ return 0;
+}
+
bool QStateMachinePrivate::isInFinalState(QAbstractState* s) const
{
if (isCompound(s)) {
- QState *grp = qobject_cast<QState*>(s);
+ QState *grp = toStandardState(s);
QList<QAbstractState*> lst = QStatePrivate::get(grp)->childStates();
for (int i = 0; i < lst.size(); ++i) {
QAbstractState *cs = lst.at(i);
@@ -909,7 +939,7 @@ bool QStateMachinePrivate::isInFinalState(QAbstractState* s) const
}
return false;
} else if (isParallel(s)) {
- QState *grp = qobject_cast<QState*>(s);
+ QState *grp = toStandardState(s);
QList<QAbstractState*> lst = QStatePrivate::get(grp)->childStates();
for (int i = 0; i < lst.size(); ++i) {
QAbstractState *cs = lst.at(i);
@@ -975,7 +1005,7 @@ QAbstractState *QStateMachinePrivate::findErrorState(QAbstractState *context)
// Find error state recursively in parent hierarchy if not set explicitly for context state
QAbstractState *errorState = 0;
if (context != 0) {
- QState *s = qobject_cast<QState*>(context);
+ QState *s = toStandardState(context);
if (s != 0)
errorState = s->errorState();
@@ -1100,7 +1130,7 @@ void QStateMachinePrivate::_q_animationFinished()
animations.removeOne(anim);
if (animations.isEmpty()) {
animationsForState.erase(it);
- QStatePrivate::get(qobject_cast<QState*>(state))->emitPolished();
+ QStatePrivate::get(toStandardState(state))->emitPropertiesAssigned();
}
}
@@ -1216,8 +1246,7 @@ void QStateMachinePrivate::_q_process()
delete e;
e = 0;
}
- if (enabledTransitions.isEmpty() && !internalEventQueue.isEmpty()) {
- e = internalEventQueue.takeFirst();
+ if (enabledTransitions.isEmpty() && ((e = dequeueInternalEvent()) != 0)) {
#ifdef QSTATEMACHINE_DEBUG
qDebug() << q << ": dequeued internal event" << e << "of type" << e->type();
#endif
@@ -1228,13 +1257,7 @@ void QStateMachinePrivate::_q_process()
}
}
if (enabledTransitions.isEmpty()) {
- if (externalEventQueue.isEmpty()) {
- if (internalEventQueue.isEmpty()) {
- processing = false;
- stopProcessingReason = EventQueueEmpty;
- }
- } else {
- e = externalEventQueue.takeFirst();
+ if ((e = dequeueExternalEvent()) != 0) {
#ifdef QSTATEMACHINE_DEBUG
qDebug() << q << ": dequeued external event" << e << "of type" << e->type();
#endif
@@ -1243,6 +1266,11 @@ void QStateMachinePrivate::_q_process()
delete e;
e = 0;
}
+ } else {
+ if (isInternalEventQueueEmpty()) {
+ processing = false;
+ stopProcessingReason = EventQueueEmpty;
+ }
}
}
if (!enabledTransitions.isEmpty()) {
@@ -1278,17 +1306,60 @@ void QStateMachinePrivate::_q_process()
}
}
+void QStateMachinePrivate::postInternalEvent(QEvent *e)
+{
+ QMutexLocker locker(&internalEventMutex);
+ internalEventQueue.append(e);
+}
+
+void QStateMachinePrivate::postExternalEvent(QEvent *e)
+{
+ QMutexLocker locker(&externalEventMutex);
+ externalEventQueue.append(e);
+}
+
+QEvent *QStateMachinePrivate::dequeueInternalEvent()
+{
+ QMutexLocker locker(&internalEventMutex);
+ if (internalEventQueue.isEmpty())
+ return 0;
+ return internalEventQueue.takeFirst();
+}
+
+QEvent *QStateMachinePrivate::dequeueExternalEvent()
+{
+ QMutexLocker locker(&externalEventMutex);
+ if (externalEventQueue.isEmpty())
+ return 0;
+ return externalEventQueue.takeFirst();
+}
+
+bool QStateMachinePrivate::isInternalEventQueueEmpty()
+{
+ QMutexLocker locker(&internalEventMutex);
+ return internalEventQueue.isEmpty();
+}
+
+bool QStateMachinePrivate::isExternalEventQueueEmpty()
+{
+ QMutexLocker locker(&externalEventMutex);
+ return externalEventQueue.isEmpty();
+}
+
void QStateMachinePrivate::processEvents(EventProcessingMode processingMode)
{
+ Q_Q(QStateMachine);
if ((state != Running) || processing || processingScheduled)
return;
switch (processingMode) {
case DirectProcessing:
- _q_process();
- break;
+ if (QThread::currentThread() == q->thread()) {
+ _q_process();
+ break;
+ } // fallthrough -- processing must be done in the machine thread
case QueuedProcessing:
processingScheduled = true;
- QMetaObject::invokeMethod(q_func(), "_q_process", Qt::QueuedConnection);
+ QMetaObject::invokeMethod(q, "_q_process", Qt::QueuedConnection);
break;
}
}
@@ -1296,6 +1367,7 @@ void QStateMachinePrivate::processEvents(EventProcessingMode processingMode)
void QStateMachinePrivate::cancelAllDelayedEvents()
{
Q_Q(QStateMachine);
+ QMutexLocker locker(&delayedEventsMutex);
QHash<int, QEvent*>::const_iterator it;
for (it = delayedEvents.constBegin(); it != delayedEvents.constEnd(); ++it) {
int id = it.key();
@@ -1346,7 +1418,7 @@ void QStateMachinePrivate::goToState(QAbstractState *targetState)
if (state == Running) {
QSet<QAbstractState*>::const_iterator it;
for (it = configuration.constBegin(); it != configuration.constEnd(); ++it) {
- sourceState = qobject_cast<QState*>(*it);
+ sourceState = toStandardState(*it);
if (sourceState != 0)
break;
}
@@ -1370,7 +1442,7 @@ void QStateMachinePrivate::goToState(QAbstractState *targetState)
void QStateMachinePrivate::registerTransitions(QAbstractState *state)
{
- QState *group = qobject_cast<QState*>(state);
+ QState *group = toStandardState(state);
if (!group)
return;
QList<QAbstractTransition*> transitions = QStatePrivate::get(group)->transitions();
@@ -1544,10 +1616,9 @@ void QStateMachinePrivate::unregisterEventTransition(QEventTransition *transitio
}
void QStateMachinePrivate::handleFilteredEvent(QObject *watched, QEvent *event)
-{
- Q_ASSERT(qobjectEvents.contains(watched));
- if (qobjectEvents[watched].contains(event->type())) {
- internalEventQueue.append(new QStateMachine::WrappedEvent(watched, handler->cloneEvent(event)));
+{
+ if (qobjectEvents.value(watched).contains(event->type())) {
+ postInternalEvent(new QStateMachine::WrappedEvent(watched, handler->cloneEvent(event)));
processEvents(DirectProcessing);
}
}
@@ -1571,7 +1642,7 @@ void QStateMachinePrivate::handleTransitionSignal(QObject *sender, int signalInd
qDebug() << q_func() << ": sending signal event ( sender =" << sender
<< ", signal =" << sender->metaObject()->method(signalIndex).signature() << ')';
#endif
- internalEventQueue.append(new QStateMachine::SignalEvent(sender, signalIndex, vargs));
+ postInternalEvent(new QStateMachine::SignalEvent(sender, signalIndex, vargs));
processEvents(DirectProcessing);
}
@@ -1654,7 +1725,7 @@ QStateMachine::~QStateMachine()
already been saved by the state machine, it will not be overwritten until the property has been
successfully restored.
- \value DoNotRestoreProperties The state machine should not save the initial values of properties
+ \value DontRestoreProperties The state machine should not save the initial values of properties
and restore them later.
\value RestoreProperties The state machine should save the initial values of properties
and restore them later.
@@ -1704,7 +1775,7 @@ QStateMachine::RestorePolicy QStateMachine::globalRestorePolicy() const
/*!
Sets the restore policy of the state machine to \a restorePolicy. The default
- restore policy is QAbstractState::DoNotRestoreProperties.
+ restore policy is QAbstractState::DontRestoreProperties.
\sa globalRestorePolicy()
*/
@@ -1825,6 +1896,8 @@ void QStateMachine::stop()
}
/*!
+ \threadsafe
+
Posts the given \a event of the given \a priority for processing by this
state machine.
@@ -1852,16 +1925,18 @@ void QStateMachine::postEvent(QEvent *event, EventPriority priority)
#endif
switch (priority) {
case NormalPriority:
- d->externalEventQueue.append(event);
+ d->postExternalEvent(event);
break;
case HighPriority:
- d->internalEventQueue.append(event);
+ d->postInternalEvent(event);
break;
}
d->processEvents(QStateMachinePrivate::QueuedProcessing);
}
/*!
+ \threadsafe
+
Posts the given \a event for processing by this state machine, with the
given \a delay in milliseconds. Returns an identifier associated with the
delayed event, or -1 if the event could not be posted.
@@ -1893,12 +1968,15 @@ int QStateMachine::postDelayedEvent(QEvent *event, int delay)
#ifdef QSTATEMACHINE_DEBUG
qDebug() << this << ": posting event" << event << "with delay" << delay;
#endif
+ QMutexLocker locker(&d->delayedEventsMutex);
int tid = startTimer(delay);
d->delayedEvents[tid] = event;
return tid;
}
/*!
+ \threadsafe
+
Cancels the delayed event identified by the given \a id. The id should be a
value returned by a call to postDelayedEvent(). Returns true if the event
was successfully cancelled, otherwise returns false.
@@ -1912,6 +1990,7 @@ bool QStateMachine::cancelDelayedEvent(int id)
qWarning("QStateMachine::cancelDelayedEvent: the machine is not running");
return false;
}
+ QMutexLocker locker(&d->delayedEventsMutex);
QEvent *e = d->delayedEvents.take(id);
if (!e)
return false;
@@ -1921,8 +2000,6 @@ bool QStateMachine::cancelDelayedEvent(int id)
}
/*!
- \internal
-
Returns the maximal consistent set of states (including parallel and final
states) that this state machine is currently in. If a state \c s is in the
configuration, it is always the case that the parent of \c s is also in
@@ -1963,18 +2040,23 @@ bool QStateMachine::event(QEvent *e)
int tid = te->timerId();
if (d->state != QStateMachinePrivate::Running) {
// This event has been cancelled already
+ QMutexLocker locker(&d->delayedEventsMutex);
Q_ASSERT(!d->delayedEvents.contains(tid));
return true;
}
+ d->delayedEventsMutex.lock();
QEvent *ee = d->delayedEvents.take(tid);
if (ee != 0) {
killTimer(tid);
- d->externalEventQueue.append(ee);
+ d->delayedEventsMutex.unlock();
+ d->postExternalEvent(ee);
d->processEvents(QStateMachinePrivate::DirectProcessing);
return true;
+ } else {
+ d->delayedEventsMutex.unlock();
}
}
- return QObject::event(e);
+ return QState::event(e);
}
#ifndef QT_NO_STATEMACHINE_EVENTFILTER
@@ -2063,19 +2145,19 @@ void QStateMachine::onExit(QEvent *event)
/*!
Returns whether animations are enabled for this state machine.
*/
-bool QStateMachine::animationsEnabled() const
+bool QStateMachine::isAnimated() const
{
Q_D(const QStateMachine);
- return d->animationsEnabled;
+ return d->animated;
}
/*!
Sets whether animations are \a enabled for this state machine.
*/
-void QStateMachine::setAnimationsEnabled(bool enabled)
+void QStateMachine::setAnimated(bool enabled)
{
Q_D(QStateMachine);
- d->animationsEnabled = enabled;
+ d->animated = enabled;
}
/*!
diff --git a/src/corelib/statemachine/qstatemachine.h b/src/corelib/statemachine/qstatemachine.h
index 13b6fe2b40..ff2b66706a 100644
--- a/src/corelib/statemachine/qstatemachine.h
+++ b/src/corelib/statemachine/qstatemachine.h
@@ -67,7 +67,7 @@ class Q_CORE_EXPORT QStateMachine : public QState
Q_PROPERTY(RestorePolicy globalRestorePolicy READ globalRestorePolicy WRITE setGlobalRestorePolicy)
Q_ENUMS(RestorePolicy)
#ifndef QT_NO_ANIMATION
- Q_PROPERTY(bool animationsEnabled READ animationsEnabled WRITE setAnimationsEnabled)
+ Q_PROPERTY(bool animated READ isAnimated WRITE setAnimated)
#endif
public:
class SignalEvent : public QEvent
@@ -109,7 +109,7 @@ public:
};
enum RestorePolicy {
- DoNotRestoreProperties,
+ DontRestoreProperties,
RestoreProperties
};
@@ -133,8 +133,8 @@ public:
bool isRunning() const;
#ifndef QT_NO_ANIMATION
- bool animationsEnabled() const;
- void setAnimationsEnabled(bool enabled);
+ bool isAnimated() const;
+ void setAnimated(bool enabled);
void addDefaultAnimation(QAbstractAnimation *animation);
QList<QAbstractAnimation *> defaultAnimations() const;
diff --git a/src/corelib/statemachine/qstatemachine_p.h b/src/corelib/statemachine/qstatemachine_p.h
index cf7a073369..aad5c67418 100644
--- a/src/corelib/statemachine/qstatemachine_p.h
+++ b/src/corelib/statemachine/qstatemachine_p.h
@@ -58,6 +58,7 @@
#include <QtCore/qcoreevent.h>
#include <QtCore/qhash.h>
#include <QtCore/qlist.h>
+#include <QtCore/qmutex.h>
#include <QtCore/qpair.h>
#include <QtCore/qset.h>
#include <QtCore/qvector.h>
@@ -72,6 +73,8 @@ class QSignalEventGenerator;
class QSignalTransition;
class QAbstractState;
class QAbstractTransition;
+class QFinalState;
+class QHistoryState;
class QState;
#ifndef QT_NO_ANIMATION
@@ -137,6 +140,11 @@ public:
const QList<QAbstractState*> &exitedStates,
const QList<QAbstractState*> &enteredStates);
+ static QState *toStandardState(QAbstractState *state);
+ static const QState *toStandardState(const QAbstractState *state);
+ static QFinalState *toFinalState(QAbstractState *state);
+ static QHistoryState *toHistoryState(QAbstractState *state);
+
bool isInFinalState(QAbstractState *s) const;
static bool isFinal(const QAbstractState *s);
static bool isParallel(const QAbstractState *s);
@@ -159,6 +167,13 @@ public:
void unregisterAllTransitions();
void handleTransitionSignal(QObject *sender, int signalIndex,
void **args);
+
+ void postInternalEvent(QEvent *e);
+ void postExternalEvent(QEvent *e);
+ QEvent *dequeueInternalEvent();
+ QEvent *dequeueExternalEvent();
+ bool isInternalEventQueueEmpty();
+ bool isExternalEventQueueEmpty();
void processEvents(EventProcessingMode processingMode);
void cancelAllDelayedEvents();
@@ -181,6 +196,8 @@ public:
QSet<QAbstractState*> configuration;
QList<QEvent*> internalEventQueue;
QList<QEvent*> externalEventQueue;
+ QMutex internalEventMutex;
+ QMutex externalEventMutex;
QStateMachine::Error error;
QStateMachine::RestorePolicy globalRestorePolicy;
@@ -190,7 +207,7 @@ public:
QSet<QAbstractState *> pendingErrorStatesForDefaultEntry;
#ifndef QT_NO_ANIMATION
- bool animationsEnabled;
+ bool animated;
QPair<QList<QAbstractAnimation*>, QList<QAbstractAnimation*> >
initializeAnimation(QAbstractAnimation *abstractAnimation,
@@ -214,6 +231,7 @@ public:
QHash<QObject*, QHash<QEvent::Type, int> > qobjectEvents;
#endif
QHash<int, QEvent*> delayedEvents;
+ QMutex delayedEventsMutex;
typedef QEvent* (*f_cloneEvent)(QEvent*);
struct Handler {
diff --git a/src/corelib/tools/qalgorithms.h b/src/corelib/tools/qalgorithms.h
index a68ce279b7..f70821a484 100644
--- a/src/corelib/tools/qalgorithms.h
+++ b/src/corelib/tools/qalgorithms.h
@@ -295,23 +295,12 @@ template <typename RandomAccessIterator, typename T>
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qBinaryFind(RandomAccessIterator begin, RandomAccessIterator end, const T &value)
{
// Implementation is duplicated from QAlgorithmsPrivate.
- qint64 l = 0;
- qint64 r = end - begin - 1;
- if (r < 0)
- return end;
- qint64 i = (l + r + 1) / 2;
-
- while (r != l) {
- if (value < begin[i])
- r = i - 1;
- else
- l = i;
- i = (l + r + 1) / 2;
- }
- if (begin[i] < value || value < begin[i])
+ RandomAccessIterator it = qLowerBound(begin, end, value);
+
+ if (it == end || value < *it)
return end;
- else
- return begin + i;
+
+ return it;
}
template <typename RandomAccessIterator, typename T, typename LessThan>
@@ -520,23 +509,12 @@ Q_OUTOFLINE_TEMPLATE RandomAccessIterator qUpperBoundHelper(RandomAccessIterator
template <typename RandomAccessIterator, typename T, typename LessThan>
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qBinaryFindHelper(RandomAccessIterator begin, RandomAccessIterator end, const T &value, LessThan lessThan)
{
- qint64 l = 0;
- qint64 r = end - begin - 1;
- if (r < 0)
- return end;
- qint64 i = (l + r + 1) / 2;
-
- while (r != l) {
- if (lessThan(value, begin[i]))
- r = i - 1;
- else
- l = i;
- i = (l + r + 1) / 2;
- }
- if (lessThan(begin[i], value) || lessThan(value, begin[i]))
+ RandomAccessIterator it = qLowerBoundHelper(begin, end, value, lessThan);
+
+ if (it == end || lessThan(value, *it))
return end;
- else
- return begin + i;
+
+ return it;
}
} //namespace QAlgorithmsPrivate
diff --git a/src/corelib/tools/qbytearray.cpp b/src/corelib/tools/qbytearray.cpp
index d8557e58a8..bf9b6bdbc0 100644
--- a/src/corelib/tools/qbytearray.cpp
+++ b/src/corelib/tools/qbytearray.cpp
@@ -48,9 +48,7 @@
#include "qlocale_p.h"
#include "qunicodetables_p.h"
#include "qscopedpointer.h"
-#ifndef QT_NO_DATASTREAM
#include <qdatastream.h>
-#endif
#ifndef QT_NO_COMPRESS
#include <zlib.h>
@@ -2640,7 +2638,7 @@ void QByteArray::clear()
d->ref.ref();
}
-#ifndef QT_NO_DATASTREAM
+#if !defined(QT_NO_DATASTREAM) || (defined(QT_BOOTSTRAPPED) && !defined(QT_BUILD_QMAKE))
/*! \relates QByteArray
diff --git a/src/corelib/tools/qbytearray.h b/src/corelib/tools/qbytearray.h
index e2584812a2..7dd6f4f2a8 100644
--- a/src/corelib/tools/qbytearray.h
+++ b/src/corelib/tools/qbytearray.h
@@ -572,7 +572,7 @@ inline QByteArray &QByteArray::setNum(float n, char f, int prec)
{ return setNum(double(n),f,prec); }
-#ifndef QT_NO_DATASTREAM
+#if !defined(QT_NO_DATASTREAM) || (defined(QT_BOOTSTRAPPED) && !defined(QT_BUILD_QMAKE))
Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QByteArray &);
Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QByteArray &);
#endif
diff --git a/src/corelib/tools/qbytearraymatcher.h b/src/corelib/tools/qbytearraymatcher.h
index ef46d34695..3d951cf1f4 100644
--- a/src/corelib/tools/qbytearraymatcher.h
+++ b/src/corelib/tools/qbytearraymatcher.h
@@ -79,17 +79,21 @@ private:
QByteArray q_pattern;
#ifdef Q_CC_RVCT
// explicitely allow anonymous unions for RVCT to prevent compiler warnings
-#pragma anon_unions
+# pragma push
+# pragma anon_unions
#endif
struct Data {
uchar q_skiptable[256];
const uchar *p;
int l;
- };
+ };
union {
uint dummy[256];
Data p;
};
+#ifdef Q_CC_RVCT
+# pragma pop
+#endif
};
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qcontiguouscache.cpp b/src/corelib/tools/qcontiguouscache.cpp
index b0ed701e6d..dab7327f38 100644
--- a/src/corelib/tools/qcontiguouscache.cpp
+++ b/src/corelib/tools/qcontiguouscache.cpp
@@ -56,6 +56,16 @@ void QContiguousCacheData::dump() const
}
#endif
+QContiguousCacheData *QContiguousCacheData::allocate(int size, int alignment)
+{
+ return static_cast<QContiguousCacheData *>(qMallocAligned(size, alignment));
+}
+
+void QContiguousCacheData::free(QContiguousCacheData *data)
+{
+ qFreeAligned(data);
+}
+
/*! \class QContiguousCache
\brief The QContiguousCache class is a template class that provides a contiguous cache.
\ingroup tools
@@ -140,20 +150,45 @@ MyRecord record(int row) const
*/
/*! \fn void QContiguousCache::detach()
-
\internal
*/
/*! \fn bool QContiguousCache::isDetached() const
-
\internal
*/
/*! \fn void QContiguousCache::setSharable(bool sharable)
-
\internal
*/
+/*! \typedef QContiguousCache::value_type
+ \internal
+ */
+
+/*! \typedef QContiguousCache::pointer
+ \internal
+ */
+
+/*! \typedef QContiguousCache::const_pointer
+ \internal
+ */
+
+/*! \typedef QContiguousCache::reference
+ \internal
+ */
+
+/*! \typedef QContiguousCache::const_reference
+ \internal
+ */
+
+/*! \typedef QContiguousCache::difference_type
+ \internal
+ */
+
+/*! \typedef QContiguousCache::size_type
+ \internal
+ */
+
/*! \fn QContiguousCache<T> &QContiguousCache::operator=(const QContiguousCache<T> &other)
Assigns \a other to this cache and returns a reference to this cache.
diff --git a/src/corelib/tools/qcontiguouscache.h b/src/corelib/tools/qcontiguouscache.h
index ad78d1f54b..37859385a7 100644
--- a/src/corelib/tools/qcontiguouscache.h
+++ b/src/corelib/tools/qcontiguouscache.h
@@ -62,6 +62,15 @@ struct Q_CORE_EXPORT QContiguousCacheData
int start;
int offset;
uint sharable : 1;
+ uint reserved : 31;
+
+ // total is 24 bytes (HP-UX aCC: 40 bytes)
+ // the next entry is already aligned to 8 bytes
+ // there will be an 8 byte gap here if T requires 16-byte alignment
+ // (such as long double on 64-bit platforms, __int128, __float128)
+
+ static QContiguousCacheData *allocate(int size, int alignment);
+ static void free(QContiguousCacheData *data);
#ifdef QT_QCONTIGUOUSCACHE_DEBUG
void dump() const;
@@ -69,33 +78,32 @@ struct Q_CORE_EXPORT QContiguousCacheData
};
template <typename T>
-struct QContiguousCacheTypedData
+struct QContiguousCacheTypedData: private QContiguousCacheData
{
- QBasicAtomicInt ref;
- int alloc;
- int count;
- int start;
- int offset;
- uint sharable : 1;
- // uint unused : 31;
-
- // total is 24 bytes (HP-UX aCC: 40 bytes)
- // the next entry is already aligned to 8 bytes
- // there will be an 8 byte gap here if T requires 16-byte alignment
- // (such as long double on 64-bit platforms, __int128, __float128)
-
+ // private inheritance to avoid aliasing warningss
T array[1];
+
+ static inline void free(QContiguousCacheTypedData *data) { QContiguousCacheData::free(data); }
};
template<typename T>
class QContiguousCache {
typedef QContiguousCacheTypedData<T> Data;
- union { QContiguousCacheData *p; QContiguousCacheTypedData<T> *d; };
+ union { QContiguousCacheData *d; QContiguousCacheTypedData<T> *p; };
public:
+ // STL compatibility
+ typedef T value_type;
+ typedef value_type* pointer;
+ typedef const value_type* const_pointer;
+ typedef value_type& reference;
+ typedef const value_type& const_reference;
+ typedef ptrdiff_t difference_type;
+ typedef int size_type;
+
explicit QContiguousCache(int capacity = 0);
QContiguousCache(const QContiguousCache<T> &v) : d(v.d) { d->ref.ref(); if (!d->sharable) detach_helper(); }
- inline ~QContiguousCache() { if (!d) return; if (!d->ref.deref()) free(d); }
+ inline ~QContiguousCache() { if (!d) return; if (!d->ref.deref()) free(p); }
inline void detach() { if (d->ref != 1) detach_helper(); }
inline bool isDetached() const { return d->ref == 1; }
@@ -128,10 +136,10 @@ public:
inline int firstIndex() const { return d->offset; }
inline int lastIndex() const { return d->offset + d->count - 1; }
- inline const T &first() const { Q_ASSERT(!isEmpty()); return d->array[d->start]; }
- inline const T &last() const { Q_ASSERT(!isEmpty()); return d->array[(d->start + d->count -1) % d->alloc]; }
- inline T &first() { Q_ASSERT(!isEmpty()); detach(); return d->array[d->start]; }
- inline T &last() { Q_ASSERT(!isEmpty()); detach(); return d->array[(d->start + d->count -1) % d->alloc]; }
+ inline const T &first() const { Q_ASSERT(!isEmpty()); return p->array[d->start]; }
+ inline const T &last() const { Q_ASSERT(!isEmpty()); return p->array[(d->start + d->count -1) % d->alloc]; }
+ inline T &first() { Q_ASSERT(!isEmpty()); detach(); return p->array[d->start]; }
+ inline T &last() { Q_ASSERT(!isEmpty()); detach(); return p->array[(d->start + d->count -1) % d->alloc]; }
void removeFirst();
T takeFirst();
@@ -156,23 +164,32 @@ private:
// count the padding at the end
return reinterpret_cast<const char *>(&(reinterpret_cast<const Data *>(this))->array[1]) - reinterpret_cast<const char *>(this);
}
+ int alignOfTypedData() const
+ {
+#ifdef Q_ALIGNOF
+ return qMax<int>(sizeof(void*), Q_ALIGNOF(Data));
+#else
+ return 0;
+#endif
+ }
};
template <typename T>
void QContiguousCache<T>::detach_helper()
{
- union { QContiguousCacheData *p; QContiguousCacheTypedData<T> *d; } x;
+ union { QContiguousCacheData *d; QContiguousCacheTypedData<T> *p; } x;
- x.p = malloc(d->alloc);
+ x.d = malloc(d->alloc);
x.d->ref = 1;
x.d->count = d->count;
x.d->start = d->start;
x.d->offset = d->offset;
x.d->alloc = d->alloc;
x.d->sharable = true;
+ x.d->reserved = 0;
- T *dest = x.d->array + x.d->start;
- T *src = d->array + d->start;
+ T *dest = x.p->array + x.d->start;
+ T *src = p->array + d->start;
int oldcount = x.d->count;
while (oldcount--) {
if (QTypeInfo<T>::isComplex) {
@@ -181,15 +198,15 @@ void QContiguousCache<T>::detach_helper()
*dest = *src;
}
dest++;
- if (dest == x.d->array + x.d->alloc)
- dest = x.d->array;
+ if (dest == x.p->array + x.d->alloc)
+ dest = x.p->array;
src++;
- if (src == d->array + d->alloc)
- src = d->array;
+ if (src == p->array + d->alloc)
+ src = p->array;
}
if (!d->ref.deref())
- free(d);
+ free(p);
d = x.d;
}
@@ -199,14 +216,14 @@ void QContiguousCache<T>::setCapacity(int asize)
if (asize == d->alloc)
return;
detach();
- union { QContiguousCacheData *p; QContiguousCacheTypedData<T> *d; } x;
- x.p = malloc(asize);
+ union { QContiguousCacheData *d; QContiguousCacheTypedData<T> *p; } x;
+ x.d = malloc(asize);
x.d->alloc = asize;
x.d->count = qMin(d->count, asize);
x.d->offset = d->offset + d->count - x.d->count;
x.d->start = x.d->offset % x.d->alloc;
- T *dest = x.d->array + (x.d->start + x.d->count-1) % x.d->alloc;
- T *src = d->array + (d->start + d->count-1) % d->alloc;
+ T *dest = x.p->array + (x.d->start + x.d->count-1) % x.d->alloc;
+ T *src = p->array + (d->start + d->count-1) % d->alloc;
int oldcount = x.d->count;
while (oldcount--) {
if (QTypeInfo<T>::isComplex) {
@@ -214,15 +231,15 @@ void QContiguousCache<T>::setCapacity(int asize)
} else {
*dest = *src;
}
- if (dest == x.d->array)
- dest = x.d->array + x.d->alloc;
+ if (dest == x.p->array)
+ dest = x.p->array + x.d->alloc;
dest--;
- if (src == d->array)
- src = d->array + d->alloc;
+ if (src == p->array)
+ src = p->array + d->alloc;
src--;
}
/* free old */
- free(d);
+ free(p);
d = x.d;
}
@@ -232,24 +249,24 @@ void QContiguousCache<T>::clear()
if (d->ref == 1) {
if (QTypeInfo<T>::isComplex) {
int oldcount = d->count;
- T * i = d->array + d->start;
- T * e = d->array + d->alloc;
+ T * i = p->array + d->start;
+ T * e = p->array + d->alloc;
while (oldcount--) {
i->~T();
i++;
if (i == e)
- i = d->array;
+ i = p->array;
}
}
d->count = d->start = d->offset = 0;
} else {
- union { QContiguousCacheData *p; QContiguousCacheTypedData<T> *d; } x;
- x.p = malloc(d->alloc);
+ union { QContiguousCacheData *d; QContiguousCacheTypedData<T> *p; } x;
+ x.d = malloc(d->alloc);
x.d->ref = 1;
x.d->alloc = d->alloc;
x.d->count = x.d->start = x.d->offset = 0;
x.d->sharable = true;
- if (!d->ref.deref()) free(d);
+ if (!d->ref.deref()) free(p);
d = x.d;
}
}
@@ -257,13 +274,13 @@ void QContiguousCache<T>::clear()
template <typename T>
inline QContiguousCacheData *QContiguousCache<T>::malloc(int aalloc)
{
- return static_cast<QContiguousCacheData *>(qMalloc(sizeOfTypedData() + (aalloc - 1) * sizeof(T)));
+ return QContiguousCacheData::allocate(sizeOfTypedData() + (aalloc - 1) * sizeof(T), alignOfTypedData());
}
template <typename T>
QContiguousCache<T>::QContiguousCache(int cap)
{
- p = malloc(cap);
+ d = malloc(cap);
d->ref = 1;
d->alloc = cap;
d->count = d->start = d->offset = 0;
@@ -303,16 +320,16 @@ void QContiguousCache<T>::free(Data *x)
{
if (QTypeInfo<T>::isComplex) {
int oldcount = d->count;
- T * i = d->array + d->start;
- T * e = d->array + d->alloc;
+ T * i = p->array + d->start;
+ T * e = p->array + d->alloc;
while (oldcount--) {
i->~T();
i++;
if (i == e)
- i = d->array;
+ i = p->array;
}
}
- qFree(x);
+ x->free(x);
}
template <typename T>
void QContiguousCache<T>::append(const T &value)
@@ -320,10 +337,10 @@ void QContiguousCache<T>::append(const T &value)
detach();
if (QTypeInfo<T>::isComplex) {
if (d->count == d->alloc)
- (d->array + (d->start+d->count) % d->alloc)->~T();
- new (d->array + (d->start+d->count) % d->alloc) T(value);
+ (p->array + (d->start+d->count) % d->alloc)->~T();
+ new (p->array + (d->start+d->count) % d->alloc) T(value);
} else {
- d->array[(d->start+d->count) % d->alloc] = value;
+ p->array[(d->start+d->count) % d->alloc] = value;
}
if (d->count == d->alloc) {
@@ -349,12 +366,12 @@ void QContiguousCache<T>::prepend(const T &value)
d->count++;
else
if (d->count == d->alloc)
- (d->array + d->start)->~T();
+ (p->array + d->start)->~T();
if (QTypeInfo<T>::isComplex)
- new (d->array + d->start) T(value);
+ new (p->array + d->start) T(value);
else
- d->array[d->start] = value;
+ p->array[d->start] = value;
}
template<typename T>
@@ -364,9 +381,9 @@ void QContiguousCache<T>::insert(int pos, const T &value)
detach();
if (containsIndex(pos)) {
if(QTypeInfo<T>::isComplex)
- new (d->array + pos % d->alloc) T(value);
+ new (p->array + pos % d->alloc) T(value);
else
- d->array[pos % d->alloc] = value;
+ p->array[pos % d->alloc] = value;
} else if (pos == d->offset-1)
prepend(value);
else if (pos == d->offset+d->count)
@@ -378,18 +395,18 @@ void QContiguousCache<T>::insert(int pos, const T &value)
d->start = pos % d->alloc;
d->count = 1;
if (QTypeInfo<T>::isComplex)
- new (d->array + d->start) T(value);
+ new (p->array + d->start) T(value);
else
- d->array[d->start] = value;
+ p->array[d->start] = value;
}
}
template <typename T>
inline const T &QContiguousCache<T>::at(int pos) const
-{ Q_ASSERT_X(pos >= d->offset && pos - d->offset < d->count, "QContiguousCache<T>::at", "index out of range"); return d->array[pos % d->alloc]; }
+{ Q_ASSERT_X(pos >= d->offset && pos - d->offset < d->count, "QContiguousCache<T>::at", "index out of range"); return p->array[pos % d->alloc]; }
template <typename T>
inline const T &QContiguousCache<T>::operator[](int pos) const
-{ Q_ASSERT_X(pos >= d->offset && pos - d->offset < d->count, "QContiguousCache<T>::at", "index out of range"); return d->array[pos % d->alloc]; }
+{ Q_ASSERT_X(pos >= d->offset && pos - d->offset < d->count, "QContiguousCache<T>::at", "index out of range"); return p->array[pos % d->alloc]; }
template <typename T>
inline T &QContiguousCache<T>::operator[](int pos)
@@ -397,7 +414,7 @@ inline T &QContiguousCache<T>::operator[](int pos)
detach();
if (!containsIndex(pos))
insert(pos, T());
- return d->array[pos % d->alloc];
+ return p->array[pos % d->alloc];
}
template <typename T>
@@ -407,7 +424,7 @@ inline void QContiguousCache<T>::removeFirst()
detach();
d->count--;
if (QTypeInfo<T>::isComplex)
- (d->array + d->start)->~T();
+ (p->array + d->start)->~T();
d->start = (d->start + 1) % d->alloc;
d->offset++;
}
@@ -419,7 +436,7 @@ inline void QContiguousCache<T>::removeLast()
detach();
d->count--;
if (QTypeInfo<T>::isComplex)
- (d->array + (d->start + d->count) % d->alloc)->~T();
+ (p->array + (d->start + d->count) % d->alloc)->~T();
}
template <typename T>
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp
index 1b559cfaf3..db6435ec1d 100644
--- a/src/corelib/tools/qdatetime.cpp
+++ b/src/corelib/tools/qdatetime.cpp
@@ -73,6 +73,10 @@
#include <private/qcore_mac_p.h>
#endif
+#if defined(Q_OS_SYMBIAN)
+#include <e32std.h>
+#endif
+
QT_BEGIN_NAMESPACE
enum {
@@ -1128,6 +1132,12 @@ QDate QDate::currentDate()
memset(&st, 0, sizeof(SYSTEMTIME));
GetLocalTime(&st);
d.jd = julianDayFromDate(st.wYear, st.wMonth, st.wDay);
+#elif defined(Q_OS_SYMBIAN)
+ TTime localTime;
+ localTime.HomeTime();
+ TDateTime localDateTime = localTime.DateTime();
+ // months and days are zero indexed
+ d.jd = julianDayFromDate(localDateTime.Year(), localDateTime.Month() + 1, localDateTime.Day() + 1 );
#else
// posix compliant system
time_t ltime;
@@ -1823,6 +1833,12 @@ QTime QTime::currentTime()
#if defined(Q_OS_WINCE)
ct.startTick = GetTickCount() % MSECS_PER_DAY;
#endif
+#elif defined(Q_OS_SYMBIAN)
+ TTime localTime;
+ localTime.HomeTime();
+ TDateTime localDateTime = localTime.DateTime();
+ ct.mds = MSECS_PER_HOUR * localDateTime.Hour() + MSECS_PER_MIN * localDateTime.Minute()
+ + 1000 * localDateTime.Second() + (localDateTime.MicroSecond() / 1000);
#elif defined(Q_OS_UNIX)
// posix compliant system
struct timeval tv;
@@ -1839,7 +1855,7 @@ QTime QTime::currentTime()
t = localtime(&ltime);
#endif
Q_CHECK_PTR(t);
-
+
ct.mds = MSECS_PER_HOUR * t->tm_hour + MSECS_PER_MIN * t->tm_min + 1000 * t->tm_sec
+ tv.tv_usec / 1000;
#else
@@ -2874,6 +2890,8 @@ QDateTime QDateTime::currentDateTime()
t.mds = MSECS_PER_HOUR * st.wHour + MSECS_PER_MIN * st.wMinute + 1000 * st.wSecond
+ st.wMilliseconds;
return QDateTime(d, t);
+#elif defined(Q_OS_SYMBIAN)
+ return QDateTime(QDate::currentDate(), QTime::currentTime());
#else
#if defined(Q_OS_UNIX)
// posix compliant system
@@ -3700,6 +3718,27 @@ static QDateTimePrivate::Spec utcToLocal(QDate &date, QTime &time)
res.tm_mon = sysTime.wMonth - 1;
res.tm_year = sysTime.wYear - 1900;
brokenDown = &res;
+#elif defined(Q_OS_SYMBIAN)
+ // months and days are zero index based
+ _LIT(KUnixEpoch, "19700000:000000.000000");
+ TTimeIntervalSeconds utcOffset = User::UTCOffset();
+ TTimeIntervalSeconds tTimeIntervalSecsSince1Jan1970UTC(secsSince1Jan1970UTC);
+ TTime epochTTime;
+ TInt err = epochTTime.Set(KUnixEpoch);
+ tm res;
+ if(err == KErrNone) {
+ TTime utcTTime = epochTTime + tTimeIntervalSecsSince1Jan1970UTC;
+ utcTTime = utcTTime + utcOffset;
+ TDateTime utcDateTime = utcTTime.DateTime();
+ res.tm_sec = utcDateTime.Second();
+ res.tm_min = utcDateTime.Minute();
+ res.tm_hour = utcDateTime.Hour();
+ res.tm_mday = utcDateTime.Day() + 1; // non-zero based index for tm struct
+ res.tm_mon = utcDateTime.Month();
+ res.tm_year = utcDateTime.Year() - 1900;
+ res.tm_isdst = 0;
+ brokenDown = &res;
+ }
#elif !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS)
// use the reentrant version of localtime() where available
tzset();
@@ -3745,7 +3784,7 @@ static void localToUtc(QDate &date, QTime &time, int isdst)
localTM.tm_mon = fakeDate.month() - 1;
localTM.tm_year = fakeDate.year() - 1900;
localTM.tm_isdst = (int)isdst;
-#if defined(Q_OS_WINCE)
+#if defined(Q_OS_WINCE) || defined(Q_OS_SYMBIAN)
time_t secsSince1Jan1970UTC = toTime_tHelper(fakeDate, time);
#else
#if defined(Q_OS_WIN)
@@ -3770,6 +3809,27 @@ static void localToUtc(QDate &date, QTime &time, int isdst)
res.tm_year = sysTime.wYear - 1900;
res.tm_isdst = (int)isdst;
brokenDown = &res;
+#elif defined(Q_OS_SYMBIAN)
+ // months and days are zero index based
+ _LIT(KUnixEpoch, "19700000:000000.000000");
+ TTimeIntervalSeconds utcOffset = TTimeIntervalSeconds(0 - User::UTCOffset().Int());
+ TTimeIntervalSeconds tTimeIntervalSecsSince1Jan1970UTC(secsSince1Jan1970UTC);
+ TTime epochTTime;
+ TInt err = epochTTime.Set(KUnixEpoch);
+ tm res;
+ if(err == KErrNone) {
+ TTime utcTTime = epochTTime + tTimeIntervalSecsSince1Jan1970UTC;
+ utcTTime = utcTTime + utcOffset;
+ TDateTime utcDateTime = utcTTime.DateTime();
+ res.tm_sec = utcDateTime.Second();
+ res.tm_min = utcDateTime.Minute();
+ res.tm_hour = utcDateTime.Hour();
+ res.tm_mday = utcDateTime.Day() + 1; // non-zero based index for tm struct
+ res.tm_mon = utcDateTime.Month();
+ res.tm_year = utcDateTime.Year() - 1900;
+ res.tm_isdst = (int)isdst;
+ brokenDown = &res;
+ }
#elif !defined(QT_NO_THREAD) && defined(_POSIX_THREAD_SAFE_FUNCTIONS)
// use the reentrant version of gmtime() where available
tm res;
diff --git a/src/corelib/tools/qhash.cpp b/src/corelib/tools/qhash.cpp
index f33aba9fe3..c82c3897c0 100644
--- a/src/corelib/tools/qhash.cpp
+++ b/src/corelib/tools/qhash.cpp
@@ -166,29 +166,38 @@ static int countBits(int hint)
const int MinNumBits = 4;
QHashData QHashData::shared_null = {
- 0, 0, Q_BASIC_ATOMIC_INITIALIZER(1), 0, 0, MinNumBits, 0, 0, true
+ 0, 0, Q_BASIC_ATOMIC_INITIALIZER(1), 0, 0, MinNumBits, 0, 0, true, false, 0
};
void *QHashData::allocateNode()
{
- void *ptr = qMalloc(nodeSize);
+ return allocateNode(0);
+}
+
+void *QHashData::allocateNode(int nodeAlign)
+{
+ void *ptr = strictAlignment ? qMallocAligned(nodeSize, nodeAlign) : qMalloc(nodeSize);
Q_CHECK_PTR(ptr);
return ptr;
}
void QHashData::freeNode(void *node)
{
- qFree(node);
+ if (strictAlignment)
+ qFreeAligned(node);
+ else
+ qFree(node);
}
QHashData *QHashData::detach_helper(void (*node_duplicate)(Node *, void *), int nodeSize)
{
- return detach_helper( node_duplicate, 0, nodeSize );
+ return detach_helper2( node_duplicate, 0, nodeSize, 0 );
}
-QHashData *QHashData::detach_helper(void (*node_duplicate)(Node *, void *),
- void (*node_delete)(Node *),
- int nodeSize)
+QHashData *QHashData::detach_helper2(void (*node_duplicate)(Node *, void *),
+ void (*node_delete)(Node *),
+ int nodeSize,
+ int nodeAlign)
{
union {
QHashData *d;
@@ -204,6 +213,8 @@ QHashData *QHashData::detach_helper(void (*node_duplicate)(Node *, void *),
d->numBits = numBits;
d->numBuckets = numBuckets;
d->sharable = true;
+ d->strictAlignment = nodeAlign > 8;
+ d->reserved = 0;
if (numBuckets) {
QT_TRY {
@@ -222,7 +233,7 @@ QHashData *QHashData::detach_helper(void (*node_duplicate)(Node *, void *),
Node *oldNode = buckets[i];
while (oldNode != this_e) {
QT_TRY {
- Node *dup = static_cast<Node *>(allocateNode());
+ Node *dup = static_cast<Node *>(allocateNode(nodeAlign));
QT_TRY {
node_duplicate(oldNode, dup);
@@ -262,6 +273,7 @@ void QHashData::free_helper(void (*node_delete)(Node *))
while (cur != this_e) {
Node *next = cur->next;
node_delete(cur);
+ freeNode(cur);
cur = next;
}
}
diff --git a/src/corelib/tools/qhash.h b/src/corelib/tools/qhash.h
index b65f1d3f74..1918229533 100644
--- a/src/corelib/tools/qhash.h
+++ b/src/corelib/tools/qhash.h
@@ -125,12 +125,15 @@ struct Q_CORE_EXPORT QHashData
short numBits;
int numBuckets;
uint sharable : 1;
+ uint strictAlignment : 1;
+ uint reserved : 30;
- void *allocateNode();
+ void *allocateNode(); // ### Qt5 remove me
+ void *allocateNode(int nodeAlign);
void freeNode(void *node);
QHashData *detach_helper(void (*node_duplicate)(Node *, void *), int nodeSize); // ### Qt5 remove me
- QHashData *detach_helper(void (*node_duplicate)(Node *, void *), void (*node_delete)(Node *),
- int nodeSize);
+ QHashData *detach_helper2(void (*node_duplicate)(Node *, void *), void (*node_delete)(Node *),
+ int nodeSize, int nodeAlign);
void mightGrow();
bool willGrow();
void hasShrunk();
@@ -267,6 +270,14 @@ class QHash
return reinterpret_cast<Node *>(node);
}
+#ifdef Q_ALIGNOF
+ static inline int alignOfNode() { return qMax<int>(sizeof(void*), Q_ALIGNOF(Node)); }
+ static inline int alignOfDummyNode() { return qMax<int>(sizeof(void*), Q_ALIGNOF(DummyNode)); }
+#else
+ static inline int alignOfNode() { return 0; }
+ static inline int alignOfDummyNode() { return 0; }
+#endif
+
public:
inline QHash() : d(&QHashData::shared_null) { d->ref.ref(); }
inline QHash(const QHash<Key, T> &other) : d(other.d) { d->ref.ref(); if (!d->sharable) detach(); }
@@ -483,7 +494,7 @@ private:
Node **findNode(const Key &key, uint *hp = 0) const;
Node *createNode(uint h, const Key &key, const T &value, Node **nextNode);
void deleteNode(Node *node);
- static void deleteNode(QHashData::Node *node);
+ static void deleteNode2(QHashData::Node *node);
static void duplicateNode(QHashData::Node *originalNode, void *newNode);
};
@@ -492,12 +503,12 @@ private:
template <class Key, class T>
Q_INLINE_TEMPLATE void QHash<Key, T>::deleteNode(Node *node)
{
- deleteNode(reinterpret_cast<QHashData::Node*>(node));
+ deleteNode2(reinterpret_cast<QHashData::Node*>(node));
+ d->freeNode(node);
}
-
template <class Key, class T>
-Q_INLINE_TEMPLATE void QHash<Key, T>::deleteNode(QHashData::Node *node)
+Q_INLINE_TEMPLATE void QHash<Key, T>::deleteNode2(QHashData::Node *node)
{
#ifdef Q_CC_BOR
concrete(node)->~QHashNode<Key, T>();
@@ -506,7 +517,6 @@ Q_INLINE_TEMPLATE void QHash<Key, T>::deleteNode(QHashData::Node *node)
#else
concrete(node)->~Node();
#endif
- qFree(node);
}
template <class Key, class T>
@@ -527,9 +537,9 @@ QHash<Key, T>::createNode(uint ah, const Key &akey, const T &avalue, Node **anex
Node *node;
if (QTypeInfo<T>::isDummy) {
- node = reinterpret_cast<Node *>(new (d->allocateNode()) DummyNode(akey));
+ node = reinterpret_cast<Node *>(new (d->allocateNode(alignOfDummyNode())) DummyNode(akey));
} else {
- node = new (d->allocateNode()) Node(akey, avalue);
+ node = new (d->allocateNode(alignOfNode())) Node(akey, avalue);
}
node->h = ah;
@@ -554,7 +564,7 @@ Q_INLINE_TEMPLATE QHash<Key, T> &QHash<Key, T>::unite(const QHash<Key, T> &other
template <class Key, class T>
Q_OUTOFLINE_TEMPLATE void QHash<Key, T>::freeData(QHashData *x)
{
- x->free_helper(deleteNode);
+ x->free_helper(deleteNode2);
}
template <class Key, class T>
@@ -566,8 +576,9 @@ Q_INLINE_TEMPLATE void QHash<Key, T>::clear()
template <class Key, class T>
Q_OUTOFLINE_TEMPLATE void QHash<Key, T>::detach_helper()
{
- QHashData *x = d->detach_helper(duplicateNode, deleteNode,
- QTypeInfo<T>::isDummy ? sizeof(DummyNode) : sizeof(Node));
+ QHashData *x = d->detach_helper2(duplicateNode, deleteNode2,
+ QTypeInfo<T>::isDummy ? sizeof(DummyNode) : sizeof(Node),
+ QTypeInfo<T>::isDummy ? alignOfDummyNode() : alignOfNode());
if (!d->ref.deref())
freeData(d);
d = x;
diff --git a/src/corelib/tools/qlocale_symbian.cpp b/src/corelib/tools/qlocale_symbian.cpp
index 1660e95bb8..1273d06358 100644
--- a/src/corelib/tools/qlocale_symbian.cpp
+++ b/src/corelib/tools/qlocale_symbian.cpp
@@ -873,9 +873,11 @@ QVariant QSystemLocale::query(QueryType type, QVariant in = QVariant()) const
}
case NegativeSign:
case PositiveSign:
+ break;
case AMText:
+ return qt_TDes2QString(TAmPmName(TAmPm(EAm)));
case PMText:
- break;
+ return qt_TDes2QString(TAmPmName(TAmPm(EPm)));
default:
break;
}
diff --git a/src/corelib/tools/qmap.cpp b/src/corelib/tools/qmap.cpp
index 13858107e3..3b48c3f24f 100644
--- a/src/corelib/tools/qmap.cpp
+++ b/src/corelib/tools/qmap.cpp
@@ -53,11 +53,16 @@ QT_BEGIN_NAMESPACE
QMapData QMapData::shared_null = {
&shared_null,
{ &shared_null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 },
- Q_BASIC_ATOMIC_INITIALIZER(1), 0, 0, 0, false, true
+ Q_BASIC_ATOMIC_INITIALIZER(1), 0, 0, 0, false, true, false, 0
};
QMapData *QMapData::createData()
{
+ return createData(0);
+}
+
+QMapData *QMapData::createData(int alignment)
+{
QMapData *d = new QMapData;
Q_CHECK_PTR(d);
Node *e = reinterpret_cast<Node *>(d);
@@ -69,6 +74,8 @@ QMapData *QMapData::createData()
d->randomBits = 0;
d->insertInOrder = false;
d->sharable = true;
+ d->strictAlignment = alignment > 8;
+ d->reserved = 0;
return d;
}
@@ -80,11 +87,19 @@ void QMapData::continueFreeData(int offset)
while (cur != e) {
prev = cur;
cur = cur->forward[0];
- qFree(reinterpret_cast<char *>(prev) - offset);
+ if (strictAlignment)
+ qFreeAligned(reinterpret_cast<char *>(prev) - offset);
+ else
+ qFree(reinterpret_cast<char *>(prev) - offset);
}
delete this;
}
+QMapData::Node *QMapData::node_create(Node *update[], int offset)
+{
+ return node_create(update, offset, 0);
+}
+
/*!
Creates a new node inside the data structure.
@@ -94,10 +109,12 @@ void QMapData::continueFreeData(int offset)
\a offset is an amount of bytes that needs to reserved just before the
QMapData::Node structure.
+ \a alignment dictates the alignment for the data.
+
\internal
\since 4.6
*/
-QMapData::Node *QMapData::node_create(Node *update[], int offset)
+QMapData::Node *QMapData::node_create(Node *update[], int offset, int alignment)
{
int level = 0;
uint mask = (1 << Sparseness) - 1;
@@ -118,7 +135,9 @@ QMapData::Node *QMapData::node_create(Node *update[], int offset)
if (level == 3 && !insertInOrder)
randomBits = qrand();
- void *concreteNode = qMalloc(offset + sizeof(Node) + level * sizeof(Node *));
+ void *concreteNode = strictAlignment ?
+ qMallocAligned(offset + sizeof(Node) + level * sizeof(Node *), alignment) :
+ qMalloc(offset + sizeof(Node) + level * sizeof(Node *));
Q_CHECK_PTR(concreteNode);
Node *abstractNode = reinterpret_cast<Node *>(reinterpret_cast<char *>(concreteNode) + offset);
@@ -145,7 +164,10 @@ void QMapData::node_delete(Node *update[], int offset, Node *node)
update[i]->forward[i] = node->forward[i];
}
--size;
- qFree(reinterpret_cast<char *>(node) - offset);
+ if (strictAlignment)
+ qFreeAligned(reinterpret_cast<char *>(node) - offset);
+ else
+ qFree(reinterpret_cast<char *>(node) - offset);
}
#ifdef QT_QMAP_DEBUG
diff --git a/src/corelib/tools/qmap.h b/src/corelib/tools/qmap.h
index 688aca62f5..0441107771 100644
--- a/src/corelib/tools/qmap.h
+++ b/src/corelib/tools/qmap.h
@@ -74,10 +74,14 @@ struct Q_CORE_EXPORT QMapData
uint randomBits;
uint insertInOrder : 1;
uint sharable : 1;
+ uint strictAlignment : 1;
+ uint reserved : 29;
- static QMapData *createData();
+ static QMapData *createData(); // ### Qt5 remove me
+ static QMapData *createData(int alignment);
void continueFreeData(int offset);
- Node *node_create(Node *update[], int offset);
+ Node *node_create(Node *update[], int offset); // ### Qt5 remove me
+ Node *node_create(Node *update[], int offset, int alignment);
void node_delete(Node *update[], int offset, Node *node);
#ifdef QT_QMAP_DEBUG
uint adjust_ptr(Node *node);
@@ -145,6 +149,13 @@ class QMap
};
static inline int payload() { return sizeof(PayloadNode) - sizeof(QMapData::Node *); }
+ static inline int alignment() {
+#ifdef Q_ALIGNOF
+ return int(qMax(sizeof(void*), Q_ALIGNOF(Node)));
+#else
+ return 0;
+#endif
+ }
static inline Node *concrete(QMapData::Node *node) {
return reinterpret_cast<Node *>(reinterpret_cast<char *>(node) - payload());
}
@@ -414,7 +425,7 @@ template <class Key, class T>
Q_INLINE_TEMPLATE typename QMapData::Node *
QMap<Key, T>::node_create(QMapData *adt, QMapData::Node *aupdate[], const Key &akey, const T &avalue)
{
- QMapData::Node *abstractNode = adt->node_create(aupdate, payload());
+ QMapData::Node *abstractNode = adt->node_create(aupdate, payload(), alignment());
QT_TRY {
Node *concreteNode = concrete(abstractNode);
new (&concreteNode->key) Key(akey);
@@ -715,7 +726,7 @@ template <class Key, class T>
Q_OUTOFLINE_TEMPLATE void QMap<Key, T>::detach_helper()
{
union { QMapData *d; QMapData::Node *e; } x;
- x.d = QMapData::createData();
+ x.d = QMapData::createData(alignment());
if (d->size) {
x.d->insertInOrder = true;
QMapData::Node *update[QMapData::LastLevel + 1];
@@ -905,7 +916,7 @@ Q_OUTOFLINE_TEMPLATE bool QMap<Key, T>::operator==(const QMap<Key, T> &other) co
template <class Key, class T>
Q_OUTOFLINE_TEMPLATE QMap<Key, T>::QMap(const std::map<Key, T> &other)
{
- d = QMapData::createData();
+ d = QMapData::createData(alignment());
d->insertInOrder = true;
typename std::map<Key,T>::const_iterator it = other.end();
while (it != other.begin()) {
diff --git a/src/corelib/tools/qregexp.cpp b/src/corelib/tools/qregexp.cpp
index 1f23211744..3ca8ab9709 100644
--- a/src/corelib/tools/qregexp.cpp
+++ b/src/corelib/tools/qregexp.cpp
@@ -1083,7 +1083,7 @@ public:
bool isValid() const { return valid; }
const QString &errorString() const { return yyError; }
- int numCaptures() const { return officialncap; }
+ int captureCount() const { return officialncap; }
int createState(QChar ch);
int createState(const QRegExpCharClass &cc);
@@ -1378,7 +1378,7 @@ void QRegExpMatchState::prepareForMatch(QRegExpEngine *eng)
#else
int newSlideTabSize = 0;
#endif
- int numCaptures = eng->numCaptures();
+ int numCaptures = eng->captureCount();
int newCapturedSize = 2 + 2 * numCaptures;
bigArray = q_check_ptr((int *)realloc(bigArray, ((3 + 4 * ncap) * ns + 4 * ncap + newSlideTabSize + newCapturedSize)*sizeof(int)));
@@ -4168,12 +4168,24 @@ int QRegExp::matchedLength() const
#ifndef QT_NO_REGEXP_CAPTURE
/*!
+ \obsolete
Returns the number of captures contained in the regular expression.
+
+ \sa captureCount()
*/
int QRegExp::numCaptures() const
{
+ return captureCount();
+}
+
+/*!
+ \since 4.6
+ Returns the number of captures contained in the regular expression.
+ */
+int QRegExp::captureCount() const
+{
prepareEngine(priv);
- return priv->eng->numCaptures();
+ return priv->eng->captureCount();
}
/*!
diff --git a/src/corelib/tools/qregexp.h b/src/corelib/tools/qregexp.h
index 1a7cf53711..2bad40e0a9 100644
--- a/src/corelib/tools/qregexp.h
+++ b/src/corelib/tools/qregexp.h
@@ -119,7 +119,8 @@ public:
#endif
int matchedLength() const;
#ifndef QT_NO_REGEXP_CAPTURE
- int numCaptures() const;
+ QT_DEPRECATED int numCaptures() const;
+ int captureCount() const;
QStringList capturedTexts() const;
QStringList capturedTexts();
QString cap(int nth = 0) const;
diff --git a/src/corelib/tools/qringbuffer_p.h b/src/corelib/tools/qringbuffer_p.h
index c44346cc94..7c766cb7f2 100644
--- a/src/corelib/tools/qringbuffer_p.h
+++ b/src/corelib/tools/qringbuffer_p.h
@@ -287,6 +287,33 @@ public:
return -1;
}
+ inline int indexOf(char c, int maxLength) const {
+ int index = 0;
+ int remain = qMin(size(), maxLength);
+ for (int i = 0; remain && i < buffers.size(); ++i) {
+ int start = 0;
+ int end = buffers.at(i).size();
+
+ if (i == 0)
+ start = head;
+ if (i == tailBuffer)
+ end = tail;
+ if (remain < end - start) {
+ end = start + remain;
+ remain = 0;
+ } else {
+ remain -= end - start;
+ }
+ const char *ptr = buffers.at(i).data() + start;
+ for (int j = start; j < end; ++j) {
+ if (*ptr++ == c)
+ return index;
+ ++index;
+ }
+ }
+ return -1;
+ }
+
inline int read(char *data, int maxLength) {
int bytesToRead = qMin(size(), maxLength);
int readSoFar = 0;
diff --git a/src/corelib/tools/qscopedpointer.cpp b/src/corelib/tools/qscopedpointer.cpp
index a3ca2c3d84..22e9bdf4f3 100644
--- a/src/corelib/tools/qscopedpointer.cpp
+++ b/src/corelib/tools/qscopedpointer.cpp
@@ -174,18 +174,20 @@ QT_BEGIN_NAMESPACE
*/
/*!
- \fn bool QScopedPointer::operator==(const QScopedPointer<T, Cleanup> &other) const
+ \fn bool operator==(const QScopedPointer<T, Cleanup> &lhs, const QScopedPointer<T, Cleanup> &rhs)
- Equality operator. Returns true if the scoped pointer \a other
- is pointing to the same object as this pointer, otherwise returns false.
+ Equality operator. Returns true if the scoped pointers
+ \a lhs and \a rhs are pointing to the same object.
+ Otherwise returns false.
*/
/*!
- \fn bool QScopedPointer::operator!=(const QScopedPointer<T, Cleanup> &other) const
+ \fn bool operator!=(const QScopedPointer<T, Cleanup> &lhs, const QScopedPointer<T, Cleanup> &rhs)
- Inequality operator. Returns true if the scoped pointer \a other
- is not pointing to the same object as this pointer, otherwise returns false.
+ Inequality operator. Returns true if the scoped pointers
+ \a lhs and \a rhs are \e not pointing to the same object.
+ Otherwise returns false.
*/
/*!
diff --git a/src/corelib/tools/qscopedpointer.h b/src/corelib/tools/qscopedpointer.h
index 7cbdb6c38d..c40b3cfb19 100644
--- a/src/corelib/tools/qscopedpointer.h
+++ b/src/corelib/tools/qscopedpointer.h
@@ -113,16 +113,6 @@ public:
return d;
}
- inline bool operator==(const QScopedPointer<T, Cleanup> &other) const
- {
- return d == other.d;
- }
-
- inline bool operator!=(const QScopedPointer<T, Cleanup> &other) const
- {
- return d != other.d;
- }
-
inline bool operator!() const
{
return !d;
@@ -181,6 +171,18 @@ private:
};
template <class T, class Cleanup>
+inline bool operator==(const QScopedPointer<T, Cleanup> &lhs, const QScopedPointer<T, Cleanup> &rhs)
+{
+ return lhs.data() == rhs.data();
+}
+
+template <class T, class Cleanup>
+inline bool operator!=(const QScopedPointer<T, Cleanup> &lhs, const QScopedPointer<T, Cleanup> &rhs)
+{
+ return lhs.data() != rhs.data();
+}
+
+template <class T, class Cleanup>
Q_INLINE_TEMPLATE void qSwap(QScopedPointer<T, Cleanup> &p1, QScopedPointer<T, Cleanup> &p2)
{ p1.swap(p2); }
@@ -203,104 +205,10 @@ public:
return this->d[i];
}
- inline bool operator==(const QScopedArrayPointer<T, Cleanup> &other) const
- {
- return this->d == other.d;
- }
-
- inline bool operator!=(const QScopedArrayPointer<T, Cleanup> &other) const
- {
- return this->d != other.d;
- }
-
private:
Q_DISABLE_COPY(QScopedArrayPointer)
};
-/* Internal helper class - exposes the data through data_ptr (legacy from QShared).
- Required for some internal Qt classes, do not use otherwise. */
-template <typename T, typename Cleanup = QScopedPointerDeleter<T> >
-class QCustomScopedPointer : public QScopedPointer<T, Cleanup>
-{
-public:
- explicit inline QCustomScopedPointer(T *p = 0)
- : QScopedPointer<T, Cleanup>(p)
- {
- }
-
- inline T *&data_ptr()
- {
- return this->d;
- }
-
- inline bool operator==(const QCustomScopedPointer<T, Cleanup> &other) const
- {
- return this->d == other.d;
- }
-
- inline bool operator!=(const QCustomScopedPointer<T, Cleanup> &other) const
- {
- return this->d != other.d;
- }
-
-private:
- Q_DISABLE_COPY(QCustomScopedPointer)
-};
-
-/* Internal helper class - a handler for QShared* classes, to be used in QCustomScopedPointer */
-template <typename T>
-class QScopedPointerSharedDeleter
-{
-public:
- static inline void cleanup(T *d)
- {
- if (d && !d->ref.deref())
- delete d;
- }
-};
-
-/* Internal.
- This class is basically a scoped pointer pointing to a ref-counted object
- */
-template <typename T>
-class QScopedSharedPointer : public QCustomScopedPointer<T, QScopedPointerSharedDeleter<T> >
-{
-public:
- explicit inline QScopedSharedPointer(T *p = 0)
- : QCustomScopedPointer<T, QScopedPointerSharedDeleter<T> >(p)
- {
- }
-
- inline void detach()
- {
- qAtomicDetach(this->d);
- }
-
- inline void assign(T *other)
- {
- if (this->d == other)
- return;
- if (other)
- other->ref.ref();
- T *oldD = this->d;
- this->d = other;
- QScopedPointerSharedDeleter<T>::cleanup(oldD);
- }
-
- inline bool operator==(const QScopedSharedPointer<T> &other) const
- {
- return this->d == other.d;
- }
-
- inline bool operator!=(const QScopedSharedPointer<T> &other) const
- {
- return this->d != other.d;
- }
-
-private:
- Q_DISABLE_COPY(QScopedSharedPointer)
-};
-
QT_END_NAMESPACE
QT_END_HEADER
diff --git a/src/corelib/tools/qscopedpointer_p.h b/src/corelib/tools/qscopedpointer_p.h
new file mode 100644
index 0000000000..fb627a4e6a
--- /dev/null
+++ b/src/corelib/tools/qscopedpointer_p.h
@@ -0,0 +1,151 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtCore module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU Lesser
+** General Public License version 2.1 as published by the Free Software
+** Foundation and appearing in the file LICENSE.LGPL included in the
+** packaging of this file. Please review the following information to
+** ensure the GNU Lesser General Public License version 2.1 requirements
+** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+//
+// W A R N I N G
+// -------------
+//
+// This file is not part of the Qt API. It exists for the convenience
+// of internal files. This header file may change from version to version
+// without notice, or even be removed.
+//
+// We mean it.
+//
+
+#ifndef QSCOPEDPOINTER_P_H
+#define QSCOPEDPOINTER_P_H
+
+#include "QtCore/qscopedpointer.h"
+
+QT_BEGIN_HEADER
+QT_BEGIN_NAMESPACE
+QT_MODULE(Core)
+
+
+/* Internal helper class - exposes the data through data_ptr (legacy from QShared).
+ Required for some internal Qt classes, do not use otherwise. */
+template <typename T, typename Cleanup = QScopedPointerDeleter<T> >
+class QCustomScopedPointer : public QScopedPointer<T, Cleanup>
+{
+public:
+ explicit inline QCustomScopedPointer(T *p = 0)
+ : QScopedPointer<T, Cleanup>(p)
+ {
+ }
+
+ inline T *&data_ptr()
+ {
+ return this->d;
+ }
+
+ inline bool operator==(const QCustomScopedPointer<T, Cleanup> &other) const
+ {
+ return this->d == other.d;
+ }
+
+ inline bool operator!=(const QCustomScopedPointer<T, Cleanup> &other) const
+ {
+ return this->d != other.d;
+ }
+
+private:
+ Q_DISABLE_COPY(QCustomScopedPointer)
+};
+
+/* Internal helper class - a handler for QShared* classes, to be used in QCustomScopedPointer */
+template <typename T>
+class QScopedPointerSharedDeleter
+{
+public:
+ static inline void cleanup(T *d)
+ {
+ if (d && !d->ref.deref())
+ delete d;
+ }
+};
+
+/* Internal.
+ This class is basically a scoped pointer pointing to a ref-counted object
+ */
+template <typename T>
+class QScopedSharedPointer : public QCustomScopedPointer<T, QScopedPointerSharedDeleter<T> >
+{
+public:
+ explicit inline QScopedSharedPointer(T *p = 0)
+ : QCustomScopedPointer<T, QScopedPointerSharedDeleter<T> >(p)
+ {
+ }
+
+ inline void detach()
+ {
+ qAtomicDetach(this->d);
+ }
+
+ inline void assign(T *other)
+ {
+ if (this->d == other)
+ return;
+ if (other)
+ other->ref.ref();
+ T *oldD = this->d;
+ this->d = other;
+ QScopedPointerSharedDeleter<T>::cleanup(oldD);
+ }
+
+ inline bool operator==(const QScopedSharedPointer<T> &other) const
+ {
+ return this->d == other.d;
+ }
+
+ inline bool operator!=(const QScopedSharedPointer<T> &other) const
+ {
+ return this->d != other.d;
+ }
+
+private:
+ Q_DISABLE_COPY(QScopedSharedPointer)
+};
+
+
+QT_END_NAMESPACE
+QT_END_HEADER
+
+#endif
diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp
index a996f30b73..086a2f3a81 100644
--- a/src/corelib/tools/qstring.cpp
+++ b/src/corelib/tools/qstring.cpp
@@ -1590,12 +1590,12 @@ QString &QString::append(QChar ch)
*/
QString &QString::remove(int pos, int len)
{
- if (pos < 0)
+ if (pos < 0) // count from end of string
pos += d->size;
if (pos < 0 || pos >= d->size) {
// range problems
- } else if (pos + len >= d->size) { // pos ok
- resize(pos);
+ } else if (len >= d->size - pos) {
+ resize(pos); // truncate
} else if (len > 0) {
detach();
memmove(d->data + pos, d->data + pos + len,
@@ -2681,7 +2681,7 @@ QString& QString::replace(const QRegExp &rx, const QString &after)
realloc();
int index = 0;
- int numCaptures = rx2.numCaptures();
+ int numCaptures = rx2.captureCount();
int al = after.length();
QRegExp::CaretMode caretMode = QRegExp::CaretAtZero;
@@ -7204,7 +7204,7 @@ QString QString::fromRawData(const QChar *unicode, int size)
*/
-#ifndef QT_NO_DATASTREAM
+#if !defined(QT_NO_DATASTREAM) || (defined(QT_BOOTSTRAPPED) && !defined(QT_BUILD_QMAKE))
/*!
\fn QDataStream &operator<<(QDataStream &stream, const QString &string)
\relates QString
diff --git a/src/corelib/tools/qstring.h b/src/corelib/tools/qstring.h
index 6c9a3cab35..668be35b81 100644
--- a/src/corelib/tools/qstring.h
+++ b/src/corelib/tools/qstring.h
@@ -631,6 +631,7 @@ private:
friend class QCharRef;
friend class QTextCodec;
friend class QStringRef;
+ friend struct QAbstractConcatenable;
friend inline bool qStringComparisonHelper(const QString &s1, const char *s2);
friend inline bool qStringComparisonHelper(const QStringRef &s1, const char *s2);
public:
@@ -1064,7 +1065,7 @@ inline QChar &QString::ref(uint i)
}
#endif
-#ifndef QT_NO_DATASTREAM
+#if !defined(QT_NO_DATASTREAM) || (defined(QT_BOOTSTRAPPED) && !defined(QT_BUILD_QMAKE))
Q_CORE_EXPORT QDataStream &operator<<(QDataStream &, const QString &);
Q_CORE_EXPORT QDataStream &operator>>(QDataStream &, QString &);
#endif
diff --git a/src/corelib/tools/qstringbuilder.cpp b/src/corelib/tools/qstringbuilder.cpp
index 0a1321892d..4a16488efc 100644
--- a/src/corelib/tools/qstringbuilder.cpp
+++ b/src/corelib/tools/qstringbuilder.cpp
@@ -41,6 +41,8 @@
#include "qstringbuilder.h"
+QT_BEGIN_NAMESPACE
+
/*!
\class QLatin1Literal
\internal
@@ -143,3 +145,25 @@
Converts the \c QLatin1Literal into a \c QString object.
*/
+
+/*! \internal */
+void QAbstractConcatenable::convertFromAscii(const char *a, int len, QChar *&out)
+{
+#ifndef QT_NO_TEXTCODEC
+ if (QString::codecForCStrings) {
+ QString tmp = QString::fromAscii(a);
+ memcpy(out, reinterpret_cast<const char *>(tmp.constData()), sizeof(QChar) * tmp.size());
+ out += tmp.length();
+ return;
+ }
+#endif
+ if (len == -1) {
+ while (*a)
+ *out++ = QLatin1Char(*a++);
+ } else {
+ for (int i = 0; i < len - 1; ++i)
+ *out++ = QLatin1Char(a[i]);
+ }
+}
+
+QT_END_NAMESPACE
diff --git a/src/corelib/tools/qstringbuilder.h b/src/corelib/tools/qstringbuilder.h
index efa39b50b4..798d09702b 100644
--- a/src/corelib/tools/qstringbuilder.h
+++ b/src/corelib/tools/qstringbuilder.h
@@ -66,7 +66,7 @@ public:
const char *data() const { return m_data; }
template <int N>
- QLatin1Literal(const char (&str)[N])
+ QLatin1Literal(const char (&str)[N])
: m_size(N - 1), m_data(str) {}
private:
@@ -74,6 +74,21 @@ private:
const char *m_data;
};
+struct Q_CORE_EXPORT QAbstractConcatenable
+{
+protected:
+ static void convertFromAscii(const char *a, int len, QChar *&out);
+
+ static inline void convertFromAscii(char a, QChar *&out)
+ {
+#ifndef QT_NO_TEXTCODEC
+ if (QString::codecForCStrings)
+ *out++ = QChar::fromAscii(a);
+ else
+#endif
+ *out++ = QLatin1Char(a);
+ }
+};
template <typename T> struct QConcatenable {};
@@ -87,9 +102,12 @@ public:
{
QString s(QConcatenable< QStringBuilder<A, B> >::size(*this),
Qt::Uninitialized);
-
+
QChar *d = s.data();
QConcatenable< QStringBuilder<A, B> >::appendTo(*this, d);
+ // this resize is necessary since we allocate a bit too much
+ // when dealing with variable sized 8-bit encodings
+ s.resize(d - s.data());
return s;
}
QByteArray toLatin1() const { return QString(*this).toLatin1(); }
@@ -99,13 +117,13 @@ public:
};
-template <> struct QConcatenable<char>
+template <> struct QConcatenable<char> : private QAbstractConcatenable
{
typedef char type;
static int size(const char) { return 1; }
static inline void appendTo(const char c, QChar *&out)
{
- *out++ = QLatin1Char(c);
+ QAbstractConcatenable::convertFromAscii(c, out);
}
};
@@ -170,7 +188,7 @@ template <> struct QConcatenable<QString>
{
const int n = a.size();
memcpy(out, reinterpret_cast<const char*>(a.constData()), sizeof(QChar) * n);
- out += n;
+ out += n;
}
};
@@ -182,53 +200,51 @@ template <> struct QConcatenable<QStringRef>
{
const int n = a.size();
memcpy(out, reinterpret_cast<const char*>(a.constData()), sizeof(QChar) * n);
- out += n;
+ out += n;
}
};
#ifndef QT_NO_CAST_FROM_ASCII
-template <int N> struct QConcatenable<char[N]>
+template <int N> struct QConcatenable<char[N]> : private QAbstractConcatenable
{
typedef char type[N];
- static int size(const char[N]) { return N - 1; }
+ static int size(const char[N])
+ {
+ return N - 1;
+ }
static inline void appendTo(const char a[N], QChar *&out)
{
- for (int i = 0; i < N - 1; ++i)
- *out++ = QLatin1Char(a[i]);
+ QAbstractConcatenable::convertFromAscii(a, N, out);
}
};
-template <int N> struct QConcatenable<const char[N]>
+template <int N> struct QConcatenable<const char[N]> : private QAbstractConcatenable
{
typedef const char type[N];
static int size(const char[N]) { return N - 1; }
static inline void appendTo(const char a[N], QChar *&out)
{
- for (int i = 0; i < N - 1; ++i)
- *out++ = QLatin1Char(a[i]);
+ QAbstractConcatenable::convertFromAscii(a, N, out);
}
};
-template <> struct QConcatenable<const char *>
+template <> struct QConcatenable<const char *> : private QAbstractConcatenable
{
typedef char const *type;
static int size(const char *a) { return qstrlen(a); }
static inline void appendTo(const char *a, QChar *&out)
{
- while (*a)
- *out++ = QLatin1Char(*a++);
+ QAbstractConcatenable::convertFromAscii(a, -1, out);
}
};
-template <> struct QConcatenable<QByteArray>
+template <> struct QConcatenable<QByteArray> : private QAbstractConcatenable
{
typedef QByteArray type;
static int size(const QByteArray &ba) { return qstrnlen(ba.constData(), ba.size()); }
static inline void appendTo(const QByteArray &ba, QChar *&out)
{
- const char *data = ba.constData();
- while (*data)
- *out++ = QLatin1Char(*data++);
+ QAbstractConcatenable::convertFromAscii(ba.constData(), -1, out);
}
};
#endif
@@ -237,7 +253,7 @@ template <typename A, typename B>
struct QConcatenable< QStringBuilder<A, B> >
{
typedef QStringBuilder<A, B> type;
- static int size(const type &p)
+ static int size(const type &p)
{
return QConcatenable<A>::size(p.a) + QConcatenable<B>::size(p.b);
}
diff --git a/src/corelib/tools/qstringmatcher.h b/src/corelib/tools/qstringmatcher.h
index 0cb1312940..80760985a4 100644
--- a/src/corelib/tools/qstringmatcher.h
+++ b/src/corelib/tools/qstringmatcher.h
@@ -79,7 +79,8 @@ private:
Qt::CaseSensitivity q_cs;
#ifdef Q_CC_RVCT
// explicitely allow anonymous unions for RVCT to prevent compiler warnings
-#pragma anon_unions
+# pragma push
+# pragma anon_unions
#endif
struct Data {
uchar q_skiptable[256];
@@ -90,6 +91,9 @@ private:
uint q_data[256];
Data p;
};
+#ifdef Q_CC_RVCT
+# pragma pop
+#endif
};
QT_END_NAMESPACE
diff --git a/src/corelib/tools/qunicodetables_p.h b/src/corelib/tools/qunicodetables_p.h
index e4041b4c88..4e9ce4d61a 100644
--- a/src/corelib/tools/qunicodetables_p.h
+++ b/src/corelib/tools/qunicodetables_p.h
@@ -114,6 +114,7 @@ namespace QUnicodeTables {
Ogham,
Runic,
Khmer,
+ Nko,
Inherited,
ScriptCount = Inherited,
Latin = Common,
@@ -152,8 +153,7 @@ namespace QUnicodeTables {
Balinese = Common,
Cuneiform = Common,
Phoenician = Common,
- PhagsPa = Common,
- Nko = Common
+ PhagsPa = Common
};
enum { ScriptSentinel = 32 };
diff --git a/src/corelib/tools/qvector.cpp b/src/corelib/tools/qvector.cpp
index 20f3a80667..8bb1074b3c 100644
--- a/src/corelib/tools/qvector.cpp
+++ b/src/corelib/tools/qvector.cpp
@@ -45,7 +45,14 @@
QT_BEGIN_NAMESPACE
-QVectorData QVectorData::shared_null = { Q_BASIC_ATOMIC_INITIALIZER(1), 0, 0, true, false };
+static inline int alignmentThreshold()
+{
+ // malloc on 32-bit platforms should return pointers that are 8-byte aligned or more
+ // while on 64-bit platforms they should be 16-byte aligned or more
+ return 2 * sizeof(void*);
+}
+
+QVectorData QVectorData::shared_null = { Q_BASIC_ATOMIC_INITIALIZER(1), 0, 0, true, false, 0 };
QVectorData *QVectorData::malloc(int sizeofTypedData, int size, int sizeofT, QVectorData *init)
{
@@ -55,6 +62,26 @@ QVectorData *QVectorData::malloc(int sizeofTypedData, int size, int sizeofT, QVe
return p;
}
+QVectorData *QVectorData::allocate(int size, int alignment)
+{
+ return static_cast<QVectorData *>(alignment > alignmentThreshold() ? qMallocAligned(size, alignment) : qMalloc(size));
+}
+
+QVectorData *QVectorData::reallocate(QVectorData *x, int newsize, int oldsize, int alignment)
+{
+ if (alignment > alignmentThreshold())
+ return static_cast<QVectorData *>(qReallocAligned(x, newsize, oldsize, alignment));
+ return static_cast<QVectorData *>(qRealloc(x, newsize));
+}
+
+void QVectorData::free(QVectorData *x, int alignment)
+{
+ if (alignment > alignmentThreshold())
+ qFreeAligned(x);
+ else
+ qFree(x);
+}
+
int QVectorData::grow(int sizeofTypedData, int size, int sizeofT, bool excessive)
{
if (excessive)
diff --git a/src/corelib/tools/qvector.h b/src/corelib/tools/qvector.h
index b77b53a21d..f0de98dd85 100644
--- a/src/corelib/tools/qvector.h
+++ b/src/corelib/tools/qvector.h
@@ -69,9 +69,11 @@ struct Q_CORE_EXPORT QVectorData
// workaround for bug in gcc 3.4.2
uint sharable;
uint capacity;
+ uint reserved;
#else
uint sharable : 1;
uint capacity : 1;
+ uint reserved : 30;
#endif
static QVectorData shared_null;
@@ -79,6 +81,9 @@ struct Q_CORE_EXPORT QVectorData
// some debugges when the QVector is member of a class within an unnamed namespace.
// ### Qt 5: can be removed completely. (Ralf)
static QVectorData *malloc(int sizeofTypedData, int size, int sizeofT, QVectorData *init);
+ static QVectorData *allocate(int size, int alignment);
+ static QVectorData *reallocate(QVectorData *old, int newsize, int oldsize, int alignment);
+ static void free(QVectorData *data, int alignment);
static int grow(int sizeofTypedData, int size, int sizeofT, bool excessive);
};
@@ -87,6 +92,8 @@ struct QVectorTypedData : private QVectorData
{ // private inheritance as we must not access QVectorData member thought QVectorTypedData
// as this would break strict aliasing rules. (in the case of shared_null)
T array[1];
+
+ static inline void free(QVectorTypedData<T> *x, int alignment) { QVectorData::free(static_cast<QVectorData *>(x), alignment); }
};
class QRegion;
@@ -302,6 +309,14 @@ private:
// count the padding at the end
return reinterpret_cast<const char *>(&(reinterpret_cast<const Data *>(this))->array[1]) - reinterpret_cast<const char *>(this);
}
+ inline int alignOfTypedData() const
+ {
+#ifdef Q_ALIGNOF
+ return qMax<int>(sizeof(void*), Q_ALIGNOF(Data));
+#else
+ return 0;
+#endif
+ }
};
template <typename T>
@@ -373,7 +388,7 @@ QVector<T> &QVector<T>::operator=(const QVector<T> &v)
template <typename T>
inline QVectorData *QVector<T>::malloc(int aalloc)
{
- QVectorData *vectordata = static_cast<QVectorData *>(qMalloc(sizeOfTypedData() + (aalloc - 1) * sizeof(T)));
+ QVectorData *vectordata = QVectorData::allocate(sizeOfTypedData() + (aalloc - 1) * sizeof(T), alignOfTypedData());
Q_CHECK_PTR(vectordata);
return vectordata;
}
@@ -420,7 +435,7 @@ void QVector<T>::free(Data *x)
while (i-- != b)
i->~T();
}
- qFree(x);
+ x->free(x, alignOfTypedData());
}
template <typename T>
@@ -459,7 +474,8 @@ void QVector<T>::realloc(int asize, int aalloc)
}
} else {
QT_TRY {
- QVectorData *mem = static_cast<QVectorData *>(qRealloc(p, sizeOfTypedData() + (aalloc - 1) * sizeof(T)));
+ QVectorData *mem = QVectorData::reallocate(d, sizeOfTypedData() + (aalloc - 1) * sizeof(T),
+ sizeOfTypedData() + (d->alloc - 1) * sizeof(T), alignOfTypedData());
Q_CHECK_PTR(mem);
x.d = d = mem;
x.d->size = d->size;
@@ -472,6 +488,7 @@ void QVector<T>::realloc(int asize, int aalloc)
x.d->alloc = aalloc;
x.d->sharable = true;
x.d->capacity = d->capacity;
+ x.d->reserved = 0;
}
if (QTypeInfo<T>::isComplex) {
diff --git a/src/corelib/tools/tools.pri b/src/corelib/tools/tools.pri
index 007b763e4c..3406e41b3c 100644
--- a/src/corelib/tools/tools.pri
+++ b/src/corelib/tools/tools.pri
@@ -44,7 +44,8 @@ HEADERS += \
tools/qunicodetables_p.h \
tools/qvarlengtharray.h \
tools/qvector.h \
- tools/qscopedpointer.h
+ tools/qscopedpointer.h \
+ tools/qscopedpointer_p.h
SOURCES += \
diff --git a/src/corelib/xml/make-parser.sh b/src/corelib/xml/make-parser.sh
index 9866555ac0..35289d27ee 100755
--- a/src/corelib/xml/make-parser.sh
+++ b/src/corelib/xml/make-parser.sh
@@ -42,7 +42,7 @@
me=$(dirname $0)
mkdir -p $me/out
-(cd $me/out && ../../../../util/qlalr/qlalr --troll --no-debug --no-lines ../qxmlstream.g)
+(cd $me/out && ../../../../util/qlalr/qlalr --qt --no-debug --no-lines ../qxmlstream.g)
for f in $me/out/*.h; do
n=$(basename $f)
diff --git a/src/corelib/xml/qxmlstream.g b/src/corelib/xml/qxmlstream.g
index 3bf0e7d279..22ba33da1e 100644
--- a/src/corelib/xml/qxmlstream.g
+++ b/src/corelib/xml/qxmlstream.g
@@ -158,6 +158,7 @@ public:
if (tos + extraCapacity + 1 > cap) {
cap = qMax(tos + extraCapacity + 1, cap << 1 );
data = reinterpret_cast<T *>(qRealloc(data, cap * sizeof(T)));
+ Q_CHECK_PTR(data);
}
}
@@ -243,7 +244,7 @@ public:
class QXmlStreamEntityResolver;
-
+#ifndef QT_NO_XMLSTREAMREADER
class QXmlStreamReaderPrivate : public QXmlStreamReader_Table, public QXmlStreamPrivateTagStack{
QXmlStreamReader *q_ptr;
Q_DECLARE_PUBLIC(QXmlStreamReader)
@@ -1840,4 +1841,6 @@ nmtoken ::= COLON;
}
return false;
}
+#endif //QT_NO_XMLSTREAMREADER.xml
+
./
diff --git a/src/corelib/xml/qxmlstream_p.h b/src/corelib/xml/qxmlstream_p.h
index ed65409b93..253f8bd5e3 100644
--- a/src/corelib/xml/qxmlstream_p.h
+++ b/src/corelib/xml/qxmlstream_p.h
@@ -1,4 +1,3 @@
-// This file was generated by qlalr - DO NOT EDIT!
/****************************************************************************
**
** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
@@ -51,6 +50,7 @@
// We mean it.
//
+// This file was generated by qlalr - DO NOT EDIT!
#ifndef QXMLSTREAM_P_H
#define QXMLSTREAM_P_H
@@ -132,13 +132,13 @@ public:
};
static const char *const spell [];
- static const qint16 lhs [];
- static const qint16 rhs [];
- static const qint16 goto_default [];
- static const qint16 action_default [];
- static const qint16 action_index [];
- static const qint16 action_info [];
- static const qint16 action_check [];
+ static const short lhs [];
+ static const short rhs [];
+ static const short goto_default [];
+ static const short action_default [];
+ static const short action_index [];
+ static const short action_info [];
+ static const short action_check [];
static inline int nt_action (int state, int nt)
{
@@ -169,7 +169,7 @@ const char *const QXmlStreamReader_Table::spell [] = {
"EMPTY", "ANY", "PCDATA", 0, 0, 0, 0, "CDATA", "ID", "IDREF",
"IDREFS", "ENTITIES", "NMTOKEN", "NMTOKENS", "<?xml", "version", 0};
-const qint16 QXmlStreamReader_Table::lhs [] = {
+const short QXmlStreamReader_Table::lhs [] = {
57, 57, 59, 59, 59, 59, 59, 59, 59, 59,
67, 68, 64, 72, 72, 72, 75, 66, 66, 66,
66, 79, 78, 80, 80, 80, 80, 80, 80, 81,
@@ -198,7 +198,7 @@ const qint16 QXmlStreamReader_Table::lhs [] = {
58, 58, 58, 58, 58, 58, 58, 58, 74, 69,
69, 77, 111, 102, 102, 102, 102, 102, 140};
-const qint16 QXmlStreamReader_Table:: rhs[] = {
+const short QXmlStreamReader_Table::rhs [] = {
2, 1, 4, 2, 2, 2, 2, 2, 2, 0,
1, 1, 9, 2, 4, 0, 4, 4, 6, 6,
4, 1, 3, 1, 1, 1, 2, 2, 2, 1,
@@ -227,7 +227,7 @@ const qint16 QXmlStreamReader_Table:: rhs[] = {
2, 2, 2, 2, 2, 2, 2, 0, 1, 0,
1, 1, 1, 1, 1, 1, 1, 1, 2};
-const qint16 QXmlStreamReader_Table::action_default [] = {
+const short QXmlStreamReader_Table::action_default [] = {
10, 258, 0, 2, 1, 0, 124, 116, 118, 119,
126, 128, 122, 11, 113, 107, 0, 108, 127, 110,
114, 112, 120, 123, 125, 106, 109, 111, 117, 115,
@@ -272,7 +272,7 @@ const qint16 QXmlStreamReader_Table::action_default [] = {
260, 0, 230, 0, 0, 13, 269, 9, 5, 8,
4, 0, 7, 258, 6, 0, 3};
-const qint16 QXmlStreamReader_Table::goto_default [] = {
+const short QXmlStreamReader_Table::goto_default [] = {
2, 4, 3, 49, 388, 43, 37, 52, 47, 41,
249, 53, 127, 84, 393, 81, 85, 126, 42, 46,
169, 130, 131, 146, 145, 149, 138, 136, 140, 147,
@@ -283,7 +283,7 @@ const qint16 QXmlStreamReader_Table::goto_default [] = {
264, 252, 251, 250, 339, 326, 325, 329, 398, 399,
50, 51, 59, 0};
-const qint16 QXmlStreamReader_Table::action_index [] = {
+const short QXmlStreamReader_Table::action_index [] = {
-21, -57, 33, 119, 960, 70, -57, -57, -57, -57,
-57, -57, -57, -57, -57, -57, 105, -57, -57, -57,
-57, -57, -57, -57, -57, -57, -57, -57, -57, -57,
@@ -372,7 +372,7 @@ const qint16 QXmlStreamReader_Table::action_index [] = {
28, 15, 82, -84, -84, -84, -84, -84, -84, -84,
-84, -84, -84, 3, -84, 98, -84};
-const qint16 QXmlStreamReader_Table::action_info [] = {
+const short QXmlStreamReader_Table::action_info [] = {
65, 332, 65, 405, 392, 385, 377, 65, 414, 410,
415, 55, 397, 374, 373, 217, 206, 408, 65, 65,
207, 211, 216, 1, 55, 199, 182, 192, 70, 70,
@@ -506,7 +506,7 @@ const qint16 QXmlStreamReader_Table::action_info [] = {
0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0};
-const qint16 QXmlStreamReader_Table::action_check [] = {
+const short QXmlStreamReader_Table::action_check [] = {
26, 18, 26, 14, 4, 4, 4, 26, 24, 14,
4, 26, 4, 4, 4, 4, 22, 55, 26, 26,
42, 4, 4, 44, 26, 22, 19, 12, 2, 2,
@@ -736,9 +736,9 @@ public:
}
};
-
class QXmlStreamEntityResolver;
+#ifndef QT_NO_XMLSTREAMREADER
class QXmlStreamReaderPrivate : public QXmlStreamReader_Table, public QXmlStreamPrivateTagStack{
QXmlStreamReader *q_ptr;
Q_DECLARE_PUBLIC(QXmlStreamReader)
@@ -1959,5 +1959,6 @@ bool QXmlStreamReaderPrivate::parse()
return false;
}
+#endif //QT_NO_XMLSTREAMREADER
#endif // QXMLSTREAM_P_H