diff options
author | Bradley T. Hughes <bradley.hughes@nokia.com> | 2009-10-28 08:45:04 (GMT) |
---|---|---|
committer | Bradley T. Hughes <bradley.hughes@nokia.com> | 2009-10-28 08:45:04 (GMT) |
commit | 1ec19ed5a69b8b0e11c81037c270072736f48e40 (patch) | |
tree | 869800a523b46e527d04c9973f36e294dd101978 /src/corelib | |
parent | 0444453661df0f56fd034778028c7abdc0b621cc (diff) | |
parent | 1583d643285641bf71e6a107331d788acca9850c (diff) | |
download | Qt-1ec19ed5a69b8b0e11c81037c270072736f48e40.zip Qt-1ec19ed5a69b8b0e11c81037c270072736f48e40.tar.gz Qt-1ec19ed5a69b8b0e11c81037c270072736f48e40.tar.bz2 |
Merge branch '4.6' of scm.dev.nokia.troll.no:qt/qt into 4.6-WM_NULL-driven
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/animation/qabstractanimation.cpp | 39 | ||||
-rw-r--r-- | src/corelib/animation/qpauseanimation.cpp | 3 | ||||
-rw-r--r-- | src/corelib/global/qglobal.cpp | 25 | ||||
-rw-r--r-- | src/corelib/global/qglobal.h | 2 | ||||
-rw-r--r-- | src/corelib/global/qnamespace.h | 5 | ||||
-rw-r--r-- | src/corelib/global/qnamespace.qdoc | 3 | ||||
-rw-r--r-- | src/corelib/tools/qstring.cpp | 6 |
7 files changed, 52 insertions, 31 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 diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc index e8d6df0..5f9d01d 100644 --- a/src/corelib/global/qnamespace.qdoc +++ b/src/corelib/global/qnamespace.qdoc @@ -2841,6 +2841,9 @@ \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 ItemGesture Gestures can only start over the item itself. + \value ItemWithChildrenGesture Gestures can start on the item or over + any of its children. \sa QWidget::grabGesture() */ diff --git a/src/corelib/tools/qstring.cpp b/src/corelib/tools/qstring.cpp index a996f30..55ad28d 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, |