summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-10-26 10:41:56 (GMT)
committerDenis Dzyubenko <denis.dzyubenko@nokia.com>2009-10-26 10:41:56 (GMT)
commit968f7c0e65a293a7d7b9a87601e853894d9794ed (patch)
tree3a86b71dd69cf4b759bb20b62c18cfeb02a28ef0 /src/corelib
parent3481db791c3b48e28f1a9531b247adf6562edb71 (diff)
parente2ef97128c006ac2a5c99c67bb54eebaa3b45720 (diff)
downloadQt-968f7c0e65a293a7d7b9a87601e853894d9794ed.zip
Qt-968f7c0e65a293a7d7b9a87601e853894d9794ed.tar.gz
Qt-968f7c0e65a293a7d7b9a87601e853894d9794ed.tar.bz2
Merge branch '4.6' into 4.6-platform
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/animation/qabstractanimation.cpp39
-rw-r--r--src/corelib/animation/qpauseanimation.cpp3
-rw-r--r--src/corelib/global/qglobal.cpp25
-rw-r--r--src/corelib/global/qglobal.h2
-rw-r--r--src/corelib/global/qnamespace.h5
5 files changed, 46 insertions, 28 deletions
diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp
index df8b548..d38ec46 100644
--- a/src/corelib/animation/qabstractanimation.cpp
+++ b/src/corelib/animation/qabstractanimation.cpp
@@ -260,7 +260,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);
}
}
@@ -278,7 +279,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);
@@ -306,6 +307,7 @@ void QUnifiedTimer::unregisterRunningAnimation(QAbstractAnimation *animation)
runningPauseAnimations.removeOne(animation);
else
runningLeafAnimations--;
+ Q_ASSERT(runningLeafAnimations >= 0);
}
int QUnifiedTimer::closestPauseAnimationTimeToFinish()
@@ -316,9 +318,9 @@ int QUnifiedTimer::closestPauseAnimationTimeToFinish()
int timeToFinish;
if (animation->direction() == QAbstractAnimation::Forward)
- timeToFinish = animation->totalDuration() - QAbstractAnimationPrivate::get(animation)->totalCurrentTime;
+ timeToFinish = animation->duration() - animation->currentTime();
else
- timeToFinish = QAbstractAnimationPrivate::get(animation)->totalCurrentTime;
+ timeToFinish = animation->currentTime();
if (timeToFinish < closestTimeToFinish)
closestTimeToFinish = timeToFinish;
@@ -370,25 +372,20 @@ void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState)
QUnifiedTimer::instance()->ensureTimerUpdate(q);
if (!guard)
return;
+ //here we're sure that we were in running state before and that the
+ //animation is currently registered
QUnifiedTimer::instance()->unregisterAnimation(q);
break;
case QAbstractAnimation::Running:
{
bool isTopLevel = !group || group->state() == QAbstractAnimation::Stopped;
+ QUnifiedTimer::instance()->registerAnimation(q, isTopLevel);
// this ensures that the value is updated now that the animation is running
if (oldState == QAbstractAnimation::Stopped) {
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);
}
}
break;
@@ -401,7 +398,8 @@ void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState)
if (deleteWhenStopped)
q->deleteLater();
- QUnifiedTimer::instance()->unregisterAnimation(q);
+ if (oldState == QAbstractAnimation::Running)
+ QUnifiedTimer::instance()->unregisterAnimation(q);
if (dura == -1 || loopCount < 0
|| (oldDirection == QAbstractAnimation::Forward && (oldCurrentTime * (oldCurrentLoop + 1)) == (dura * loopCount))
@@ -448,7 +446,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);
}
}
@@ -636,13 +635,13 @@ 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;
}
/*!
@@ -673,7 +672,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;
diff --git a/src/corelib/animation/qpauseanimation.cpp b/src/corelib/animation/qpauseanimation.cpp
index d90f001..21e5b08 100644
--- a/src/corelib/animation/qpauseanimation.cpp
+++ b/src/corelib/animation/qpauseanimation.cpp
@@ -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/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 5a7b559..7d47944 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -2479,7 +2479,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.
@@ -2535,20 +2535,35 @@ void qsrand(uint seed)
*/
void qsrand()
{
-#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)
SeedStorageType *pseed = randTLS()->localData();
if (pseed) {
// already seeded
return;
}
randTLS()->setLocalData(pseed = new SeedStorageType);
- static QBasicAtomicInt serial = Q_BASIC_ATOMIC_INITIALIZER(0);
+ // 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);
-#else
- // On Windows, we assume that rand() already does the right thing
+#if defined(Q_OS_WIN)
+ // for Windows the srand function must still be called.
+ srand(*pseed);
#endif
+
+#elif defined(Q_OS_WIN)
+ static unsigned int seed = 0;
+
+ if (seed)
+ return;
+
+ seed = GetTickCount();
+ srand(seed);
+#else
+ // Symbian?
+
+#endif // defined(Q_OS_UNIX) || defined(Q_OS_WIN)) && !defined(QT_NO_THREAD) && !defined(Q_OS_SYMBIAN)
}
/*!
diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h
index df17546..5ee1815 100644
--- a/src/corelib/global/qglobal.h
+++ b/src/corelib/global/qglobal.h
@@ -466,7 +466,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)))
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index f28f94e..2b62c6b 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -1631,7 +1631,10 @@ public:
enum GestureContext
{
WidgetGesture = 0,
- WidgetWithChildrenGesture = 3
+ WidgetWithChildrenGesture = 3,
+
+ ItemGesture = WidgetGesture,
+ ItemWithChildrenGesture = WidgetWithChildrenGesture
};
enum NavigationMode