summaryrefslogtreecommitdiffstats
path: root/src/corelib/kernel
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@nokia.com>2010-10-05 14:05:00 (GMT)
committerPaul Olav Tvete <paul.tvete@nokia.com>2010-10-05 14:05:00 (GMT)
commitc743e81790213db0c9a4abcee993fce0368b6367 (patch)
tree4eeaa5fd21f18981f8e31a3288da92d3e2084ead /src/corelib/kernel
parentd9f42e554c1da7aafad59881e1d143ff8672b833 (diff)
parenta7bf1cfb1a75c35e837c01f4a5b0697fc8961148 (diff)
downloadQt-c743e81790213db0c9a4abcee993fce0368b6367.zip
Qt-c743e81790213db0c9a4abcee993fce0368b6367.tar.gz
Qt-c743e81790213db0c9a4abcee993fce0368b6367.tar.bz2
Merge remote branch 'qt/4.7' into lighthouse-4.7
Conflicts: src/gui/painting/qpdf.cpp
Diffstat (limited to 'src/corelib/kernel')
-rw-r--r--src/corelib/kernel/qcoreapplication.cpp3
-rw-r--r--src/corelib/kernel/qeventdispatcher_symbian.cpp38
-rw-r--r--src/corelib/kernel/qeventdispatcher_symbian_p.h8
-rw-r--r--src/corelib/kernel/qeventdispatcher_unix.cpp22
-rw-r--r--src/corelib/kernel/qmath.qdoc155
-rw-r--r--src/corelib/kernel/qmetatype.h26
-rw-r--r--src/corelib/kernel/qobject.h91
-rw-r--r--src/corelib/kernel/qpointer.cpp2
8 files changed, 214 insertions, 131 deletions
diff --git a/src/corelib/kernel/qcoreapplication.cpp b/src/corelib/kernel/qcoreapplication.cpp
index 512e193..d3f399b 100644
--- a/src/corelib/kernel/qcoreapplication.cpp
+++ b/src/corelib/kernel/qcoreapplication.cpp
@@ -2091,7 +2091,8 @@ QStringList QCoreApplication::arguments()
l1arg == "-stylesheet" ||
l1arg == "-widgetcount")
;
- else if (l1arg.startsWith("-style="))
+ else if (l1arg.startsWith("-style=") ||
+ l1arg.startsWith("-qmljsdebugger="))
;
else if (l1arg == "-style" ||
l1arg == "-session" ||
diff --git a/src/corelib/kernel/qeventdispatcher_symbian.cpp b/src/corelib/kernel/qeventdispatcher_symbian.cpp
index 5cc6ae3..d8cc344 100644
--- a/src/corelib/kernel/qeventdispatcher_symbian.cpp
+++ b/src/corelib/kernel/qeventdispatcher_symbian.cpp
@@ -127,9 +127,9 @@ private:
* cannot change active objects that we do not own, but the active objects that Qt owns will use
* this as a base class with convenience functions.
*
- * Here is how it works: On every RunL, the deriving class should call okToRun(). This will allow
- * exactly one run of the active object, and mark it as such. If it is called again, it will return
- * false, and add the object to a queue so it can be run later.
+ * Here is how it works: On every RunL, the deriving class should call maybeQueueForLater().
+ * This will return whether the active object has been queued, or whether it should run immediately.
+ * Queued objects will run again after other events have been processed.
*
* The QCompleteDeferredAOs class is a special object that runs after all others, which will
* reactivate the objects that were previously not run.
@@ -149,7 +149,7 @@ QActiveObject::~QActiveObject()
m_dispatcher->removeDeferredActiveObject(this);
}
-bool QActiveObject::okToRun()
+bool QActiveObject::maybeQueueForLater()
{
Q_ASSERT(!m_hasRunAgain);
@@ -157,12 +157,12 @@ bool QActiveObject::okToRun()
// First occurrence of this event in this iteration.
m_hasAlreadyRun = true;
m_iterationCount = m_dispatcher->iterationCount();
- return true;
+ return false;
} else {
// The event has already occurred.
m_dispatcher->addDeferredActiveObject(this);
m_hasRunAgain = true;
- return false;
+ return true;
}
}
@@ -178,8 +178,7 @@ void QActiveObject::reactivateAndComplete()
}
QWakeUpActiveObject::QWakeUpActiveObject(QEventDispatcherSymbian *dispatcher)
- : CActive(WAKE_UP_PRIORITY),
- m_dispatcher(dispatcher)
+ : QActiveObject(WAKE_UP_PRIORITY, dispatcher)
{
CActiveScheduler::Add(this);
iStatus = KRequestPending;
@@ -201,6 +200,9 @@ void QWakeUpActiveObject::DoCancel()
void QWakeUpActiveObject::RunL()
{
+ if (maybeQueueForLater())
+ return;
+
iStatus = KRequestPending;
SetActive();
QT_TRYCATCH_LEAVING(m_dispatcher->wakeUpWasCalled());
@@ -270,7 +272,7 @@ void QTimerActiveObject::Run()
return;
}
- if (!okToRun())
+ if (maybeQueueForLater())
return;
if (m_timerInfo->interval > 0) {
@@ -630,7 +632,7 @@ void QSocketActiveObject::DoCancel()
void QSocketActiveObject::RunL()
{
- if (!okToRun())
+ if (maybeQueueForLater())
return;
QT_TRYCATCH_LEAVING(m_dispatcher->socketFired(this));
@@ -722,6 +724,7 @@ QEventDispatcherSymbian::QEventDispatcherSymbian(QObject *parent)
m_interrupt(false),
m_wakeUpDone(0),
m_iterationCount(0),
+ m_insideTimerEvent(false),
m_noSocketEvents(false)
{
#ifdef QT_SYMBIAN_PRIORITY_DROP
@@ -772,6 +775,9 @@ bool QEventDispatcherSymbian::processEvents ( QEventLoop::ProcessEventsFlags fla
{
bool handledAnyEvent = false;
bool oldNoSocketEventsValue = m_noSocketEvents;
+ bool oldInsideTimerEventValue = m_insideTimerEvent;
+
+ m_insideTimerEvent = false;
QT_TRY {
Q_D(QAbstractEventDispatcher);
@@ -862,6 +868,7 @@ bool QEventDispatcherSymbian::processEvents ( QEventLoop::ProcessEventsFlags fla
}
m_noSocketEvents = oldNoSocketEventsValue;
+ m_insideTimerEvent = oldInsideTimerEventValue;
return handledAnyEvent;
}
@@ -882,10 +889,13 @@ void QEventDispatcherSymbian::timerFired(int timerId)
}
timerInfo->inTimerEvent = true;
+ bool oldInsideTimerEventValue = m_insideTimerEvent;
+ m_insideTimerEvent = true;
QTimerEvent event(timerInfo->timerId);
QCoreApplication::sendEvent(timerInfo->receiver, &event);
+ m_insideTimerEvent = oldInsideTimerEventValue;
timerInfo->inTimerEvent = false;
return;
@@ -1052,6 +1062,14 @@ void QEventDispatcherSymbian::registerTimer ( int timerId, int interval, QObject
m_timerList.insert(timerId, timer);
timer->timerAO->Start();
+
+ if (m_insideTimerEvent)
+ // If we are inside a timer event, we need to prevent event starvation
+ // by preventing newly created timers from running in the same event processing
+ // iteration. Do this by calling the maybeQueueForLater() function to "fake" that we have
+ // already run once. This will cause the next run to be added to the deferred
+ // queue instead.
+ timer->timerAO->maybeQueueForLater();
}
bool QEventDispatcherSymbian::unregisterTimer ( int timerId )
diff --git a/src/corelib/kernel/qeventdispatcher_symbian_p.h b/src/corelib/kernel/qeventdispatcher_symbian_p.h
index bc42753..1486db5 100644
--- a/src/corelib/kernel/qeventdispatcher_symbian_p.h
+++ b/src/corelib/kernel/qeventdispatcher_symbian_p.h
@@ -82,7 +82,7 @@ public:
QActiveObject(TInt priority, QEventDispatcherSymbian *dispatcher);
~QActiveObject();
- bool okToRun();
+ bool maybeQueueForLater();
void reactivateAndComplete();
@@ -95,7 +95,7 @@ private:
int m_iterationCount;
};
-class QWakeUpActiveObject : public CActive
+class QWakeUpActiveObject : public QActiveObject
{
public:
QWakeUpActiveObject(QEventDispatcherSymbian *dispatcher);
@@ -106,9 +106,6 @@ public:
protected:
void DoCancel();
void RunL();
-
-private:
- QEventDispatcherSymbian *m_dispatcher;
};
struct SymbianTimerInfo : public QSharedData
@@ -277,6 +274,7 @@ private:
QAtomicInt m_wakeUpDone;
unsigned char m_iterationCount;
+ bool m_insideTimerEvent;
bool m_noSocketEvents;
QList<QSocketActiveObject *> m_deferredSocketEvents;
diff --git a/src/corelib/kernel/qeventdispatcher_unix.cpp b/src/corelib/kernel/qeventdispatcher_unix.cpp
index 72f3c0e..b2b9806 100644
--- a/src/corelib/kernel/qeventdispatcher_unix.cpp
+++ b/src/corelib/kernel/qeventdispatcher_unix.cpp
@@ -557,18 +557,22 @@ int QTimerInfoList::activateTimers()
if (qt_disable_lowpriority_timers || isEmpty())
return 0; // nothing to do
- bool firstTime = true;
- timeval currentTime;
- int n_act = 0, maxCount = count();
+ int n_act = 0, maxCount = 0;
firstTimerInfo = 0;
- while (maxCount--) {
- currentTime = updateCurrentTime();
- if (firstTime) {
- repairTimersIfNeeded();
- firstTime = false;
- }
+ timeval currentTime = updateCurrentTime();
+ repairTimersIfNeeded();
+
+ // Find out how many timer have expired
+ for (QTimerInfoList::const_iterator it = constBegin(); it != constEnd(); ++it) {
+ if (currentTime < (*it)->timeout)
+ break;
+ maxCount++;
+ }
+
+ //fire the timers.
+ while (maxCount--) {
if (isEmpty())
break;
diff --git a/src/corelib/kernel/qmath.qdoc b/src/corelib/kernel/qmath.qdoc
new file mode 100644
index 0000000..48f74b6
--- /dev/null
+++ b/src/corelib/kernel/qmath.qdoc
@@ -0,0 +1,155 @@
+/****************************************************************************
+**
+** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the documentation of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:FDL$
+** Commercial Usage
+** Licensees holding valid Qt Commercial licenses may use this file in
+** accordance with the Qt Commercial License Agreement provided with the
+** Software or, alternatively, in accordance with the terms contained in a
+** written agreement between you and Nokia.
+**
+** GNU Free Documentation License
+** Alternatively, this file may be used under the terms of the GNU Free
+** Documentation License version 1.3 as published by the Free Software
+** Foundation and appearing in the file included in the packaging of this
+** file.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+/*!
+ \headerfile <QtCore/qmath.h>
+ \title Math Functions
+ \ingroup funclists
+ \brief The <QtCore/qmath.h> header provides various math functions.
+ \pagekeywords math trigonometry qmath floor ceiling absolute sine cosine tangent inverse tan exponent power natural logarithm
+*/
+
+/*!
+ \fn int qCeil(qreal v)
+ Return the ceiling of the value \a v.
+
+ The ceiling is the smallest integer that is not less than \a v.
+ For example, if \a v is 41.2, then the ceiling is 42.
+
+ \relates <QtCore/qmath.h>
+ \sa qFloor()
+*/
+
+/*!
+ \fn int qFloor(qreal v)
+ Return the floor of the value \a v.
+
+ The floor is the largest integer that is not greater than \a v.
+ For example, if \a v is 41.2, then the floor is 41.
+
+ \relates <QtCore/qmath.h>
+ \sa qCeil()
+*/
+
+/*!
+ \fn qreal qFabs(qreal v)
+ Returns the absolute value of \a v as a qreal.
+*/
+
+/*!
+ \fn qreal qSin(qreal v)
+ Returns the sine of the angle \a v in radians.
+
+ \relates <QtCore/qmath.h>
+ \sa qCos(), qTan()
+*/
+
+/*!
+ \fn qreal qCos(qreal v)
+ Returns the cosine of an angle \a v in radians.
+
+ \relates <QtCore/qmath.h>
+ \sa qSin(), qTan()
+*/
+
+/*!
+ \fn qreal qTan(qreal v)
+ Returns the tangent of an angle \a v in radians.
+
+ \relates <QtCore/qmath.h>
+ \sa qSin(), qCos()
+*/
+
+/*!
+ \fn qreal qAcos(qreal v)
+ Returns the arccosine of \a v as an angle in radians.
+ Arccosine is the inverse operation of cosine.
+
+ \relates <QtCore/qmath.h>
+ \sa qAtan(), qAsin(), qCos()
+*/
+
+/*!
+ \fn qreal qAsin(qreal v)
+ Returns the arcsine of \a v as an angle in radians.
+ Arcsine is the inverse operation of sine.
+
+ \relates <QtCore/qmath.h>
+ \sa qSin(), qAtan(), qAcos()
+*/
+
+/*!
+ \fn qreal qAtan(qreal v)
+ Returns the arctangent of \a v as an angle in radians.
+ Arctangent is the inverse operation of tangent.
+
+ \relates <QtCore/qmath.h>
+ \sa qTan(), qAcos(), qAsin()
+*/
+
+/*!
+ \fn qreal qAtan2(qreal x, qreal y)
+ Returns the arctangent of a point specified by the coordinates \a x and \a y.
+ This function will return the angle and its direction.
+
+ \relates <QtCore/qmath.h>
+ \sa qAtan()
+*/
+
+/*!
+ \fn qreal qSqrt(qreal v)
+ Returns the square root of \a v.
+ This function returns a NaN if \a v is a negative number.
+
+ \relates <QtCore/qmath.h>
+ \sa qPow()
+*/
+
+/*!
+ \fn qreal qLn(qreal v)
+ Returns the natural logarithm of \a v. Natural logarithm uses base e.
+
+ \relates <QtCore/qmath.h>
+ \sa qExp()
+*/
+
+/*!
+ \fn qreal qExp(qreal v)
+ Returns the exponential function of \c e to the power of \a v.
+
+ \relates <QtCore/qmath.h>
+ \sa qLn()
+*/
+
+/*!
+ \fn qreal qPow(qreal x, qreal y)
+ Returns the value of \a x raised to the power of \a y.
+ That is, \a x is the base and \a y is the exponent.
+
+ \relates <QtCore/qmath.h>
+ \sa qSqrt()
+*/
diff --git a/src/corelib/kernel/qmetatype.h b/src/corelib/kernel/qmetatype.h
index 2108b92..e16ffe8 100644
--- a/src/corelib/kernel/qmetatype.h
+++ b/src/corelib/kernel/qmetatype.h
@@ -156,7 +156,18 @@ void qMetaTypeLoadHelper(QDataStream &stream, T *t)
}
#endif // QT_NO_DATASTREAM
-template <typename T> struct QMetaTypeId2;
+template <typename T>
+struct QMetaTypeId
+{
+ enum { Defined = 0 };
+};
+
+template <typename T>
+struct QMetaTypeId2
+{
+ enum { Defined = QMetaTypeId<T>::Defined };
+ static inline int qt_metatype_id() { return QMetaTypeId<T>::qt_metatype_id(); }
+};
namespace QtPrivate {
template <typename T, bool Defined = QMetaTypeId2<T>::Defined>
@@ -210,19 +221,6 @@ void qRegisterMetaTypeStreamOperators(const char *typeName
#endif // QT_NO_DATASTREAM
template <typename T>
-struct QMetaTypeId
-{
- enum { Defined = 0 };
-};
-
-template <typename T>
-struct QMetaTypeId2
-{
- enum { Defined = QMetaTypeId<T>::Defined };
- static inline int qt_metatype_id() { return QMetaTypeId<T>::qt_metatype_id(); }
-};
-
-template <typename T>
inline int qMetaTypeId(
#ifndef qdoc
T * /* dummy */ = 0
diff --git a/src/corelib/kernel/qobject.h b/src/corelib/kernel/qobject.h
index 1b613a6..d98d1f0 100644
--- a/src/corelib/kernel/qobject.h
+++ b/src/corelib/kernel/qobject.h
@@ -325,95 +325,6 @@ Q_CORE_EXPORT void qt_qFindChildren_helper(const QObject *parent, const QString
const QMetaObject &mo, QList<void *> *list);
Q_CORE_EXPORT QObject *qt_qFindChild_helper(const QObject *parent, const QString &name, const QMetaObject &mo);
-#if defined Q_CC_MSVC && _MSC_VER < 1300
-
-template<typename T>
-inline T qFindChild(const QObject *o, const QString &name, T)
-{ return static_cast<T>(qt_qFindChild_helper(o, name, ((T)0)->staticMetaObject)); }
-
-template<typename T>
-inline QList<T> qFindChildren(const QObject *o, const QString &name, T)
-{
- QList<T> list;
- union {
- QList<T> *typedList;
- QList<void *> *voidList;
- } u;
- u.typedList = &list;
- qt_qFindChildren_helper(o, name, 0, ((T)0)->staticMetaObject, u.voidList);
- return list;
-}
-
-template<typename T>
-inline T qFindChild(const QObject *o, const QString &name)
-{ return qFindChild<T>(o, name, T(0)); }
-
-template<typename T>
-inline T qFindChild(const QObject *o)
-{ return qFindChild<T>(o, QString(), T(0)); }
-
-template<typename T>
-inline QList<T> qFindChildren(const QObject *o, const QString &name)
-{ return qFindChildren<T>(o, name, T(0)); }
-
-template<typename T>
-inline QList<T> qFindChildren(const QObject *o)
-{ return qFindChildren<T>(o, QString(), T(0)); }
-
-#ifndef QT_NO_REGEXP
-template<typename T>
-inline QList<T> qFindChildren(const QObject *o, const QRegExp &re, T)
-{
- QList<T> list;
- union {
- QList<T> *typedList;
- QList<void *> *voidList;
- } u;
- u.typedList = &list;
- qt_qFindChildren_helper(o, 0, &re, ((T)0)->staticMetaObject, u.voidList);
- return list;
-}
-
-template<typename T>
-inline QList<T> qFindChildren(const QObject *o, const QRegExp &re)
-{ return qFindChildren<T>(o, re, T(0)); }
-
-#endif
-
-#ifdef Q_MOC_RUN
-# define Q_DECLARE_INTERFACE(IFace, IId) Q_DECLARE_INTERFACE(IFace, IId)
-#endif // Q_MOC_RUN
-
-
-template <class T> inline const char * qobject_interface_iid()
-{ return 0; }
-
-template <class T> inline T qobject_cast_helper(QObject *object, T)
-{ return static_cast<T>(((T)0)->staticMetaObject.cast(object)); }
-
-template <class T> inline T qobject_cast_helper(const QObject *object, T)
-{ return static_cast<T>(const_cast<const QObject *>(((T)0)->staticMetaObject.cast(const_cast<QObject *>(object)))); }
-
-template <class T>
-inline T qobject_cast(QObject *object)
-{ return qobject_cast_helper<T>(object, T(0)); }
-
-template <class T>
-inline T qobject_cast(const QObject *object)
-{ return qobject_cast_helper<T>(object, T(0)); }
-
-#ifndef Q_MOC_RUN
-# define Q_DECLARE_INTERFACE(IFace, IId) \
- template <> inline const char *qobject_interface_iid<IFace *>() \
- { return IId; } \
- template <> inline IFace *qobject_cast_helper<IFace *>(QObject *object, IFace *) \
- { return (IFace *)(object ? object->qt_metacast(IId) : 0); } \
- template <> inline IFace *qobject_cast_helper<IFace *>(const QObject *object, IFace *) \
- { return (IFace *)(object ? const_cast<QObject *>(object)->qt_metacast(IId) : 0); }
-#endif // Q_MOC_RUN
-
-#else
-
template<typename T>
inline T qFindChild(const QObject *o, const QString &name)
{ return static_cast<T>(qt_qFindChild_helper(o, name, reinterpret_cast<T>(0)->staticMetaObject)); }
@@ -482,8 +393,6 @@ template <class T> inline const char * qobject_interface_iid()
{ return reinterpret_cast<IFace *>((object ? const_cast<QObject *>(object)->qt_metacast(IId) : 0)); }
#endif // Q_MOC_RUN
-#endif
-
#ifndef QT_NO_DEBUG_STREAM
Q_CORE_EXPORT QDebug operator<<(QDebug, const QObject *);
#endif
diff --git a/src/corelib/kernel/qpointer.cpp b/src/corelib/kernel/qpointer.cpp
index 5cd0220..fbfb961 100644
--- a/src/corelib/kernel/qpointer.cpp
+++ b/src/corelib/kernel/qpointer.cpp
@@ -41,7 +41,7 @@
/*!
\class QPointer
- \brief The QPointer class is a template class that provides guarded pointers to QObjects.
+ \brief The QPointer class is a template class that provides guarded pointers to QObject.
\ingroup objectmodel