summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-10-29 04:54:35 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-10-29 04:54:35 (GMT)
commitc06be171d9e9efe91a3612bf0a82fab0d2cff2fa (patch)
tree8c3194e5171125f281f4df53328826138e723719 /src/corelib
parentbfbded95056d43a65b2c9ef1fa90bfd40adc6472 (diff)
parent51f1d68addd23516d7e6e252e476feac0a95d0c0 (diff)
downloadQt-c06be171d9e9efe91a3612bf0a82fab0d2cff2fa.zip
Qt-c06be171d9e9efe91a3612bf0a82fab0d2cff2fa.tar.gz
Qt-c06be171d9e9efe91a3612bf0a82fab0d2cff2fa.tar.bz2
Merge branch '4.6' of git@scm.dev.nokia.troll.no:qt/qt-widget-team into kinetic-declarativeui
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/animation/qabstractanimation.cpp19
-rw-r--r--src/corelib/animation/qabstractanimation_p.h2
-rw-r--r--src/corelib/global/qnamespace.qdoc2
-rw-r--r--src/corelib/kernel/qobject.cpp7
-rw-r--r--src/corelib/kernel/qvariant.h40
-rw-r--r--src/corelib/tools/qalgorithms.h42
6 files changed, 33 insertions, 79 deletions
diff --git a/src/corelib/animation/qabstractanimation.cpp b/src/corelib/animation/qabstractanimation.cpp
index bb38a94..fc124d9 100644
--- a/src/corelib/animation/qabstractanimation.cpp
+++ b/src/corelib/animation/qabstractanimation.cpp
@@ -194,15 +194,10 @@ 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()
@@ -381,7 +376,7 @@ void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState)
case QAbstractAnimation::Paused:
if (hasRegisteredTimer)
// currentTime needs to be updated if pauseTimer is active
- QUnifiedTimer::instance()->ensureTimerUpdate(q);
+ QUnifiedTimer::instance()->ensureTimerUpdate();
if (!guard)
return;
//here we're sure that we were in running state before and that the
@@ -395,9 +390,11 @@ void QAbstractAnimationPrivate::setState(QAbstractAnimation::State newState)
// 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);
+ QUnifiedTimer::instance()->ensureTimerUpdate();
+ q->setCurrentTime(totalCurrentTime);
+ }
}
}
break;
@@ -558,7 +555,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);
diff --git a/src/corelib/animation/qabstractanimation_p.h b/src/corelib/animation/qabstractanimation_p.h
index bef0499..f989bce 100644
--- a/src/corelib/animation/qabstractanimation_p.h
+++ b/src/corelib/animation/qabstractanimation_p.h
@@ -142,7 +142,7 @@ public:
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
diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc
index 5f9d01d..7e0b933 100644
--- a/src/corelib/global/qnamespace.qdoc
+++ b/src/corelib/global/qnamespace.qdoc
@@ -2509,7 +2509,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)
diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp
index 7be19b3..5303975 100644
--- a/src/corelib/kernel/qobject.cpp
+++ b/src/corelib/kernel/qobject.cpp
@@ -835,14 +835,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) {
diff --git a/src/corelib/kernel/qvariant.h b/src/corelib/kernel/qvariant.h
index eb4fb56..a1ab4e9 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,9 @@ 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)
+template<> inline QVariant qvariant_cast<QVariant>(const QVariant &v)
{
- return variant.canConvert(static_cast<QVariant::Type>(qMetaTypeId<T>(t)));
-}
-#else
-
-template<typename T> T qvariant_cast(const QVariant &v)
-{
- const int vid = qMetaTypeId<T>(static_cast<T *>(0));
- 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 v;
}
template<typename T>
@@ -608,7 +595,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/tools/qalgorithms.h b/src/corelib/tools/qalgorithms.h
index a68ce27..f70821a 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