summaryrefslogtreecommitdiffstats
path: root/src/corelib
diff options
context:
space:
mode:
authorAlexis Menard <alexis.menard@nokia.com>2009-10-12 14:48:33 (GMT)
committerAlexis Menard <alexis.menard@nokia.com>2009-10-12 14:48:33 (GMT)
commitbc53cf1334738307110a661f19b6fbb9be9b72d6 (patch)
tree268f8a23eba6e491258d0189362e44deb3fdce6d /src/corelib
parent8da7252de0badb818302763cbe62c38ad699f1f3 (diff)
parent8df79a473e1a7e5c79b9b10827985bf3e9501002 (diff)
downloadQt-bc53cf1334738307110a661f19b6fbb9be9b72d6.zip
Qt-bc53cf1334738307110a661f19b6fbb9be9b72d6.tar.gz
Qt-bc53cf1334738307110a661f19b6fbb9be9b72d6.tar.bz2
Merge commit '8df79a473e1a7e5c79b9b10827985bf3e9501002' into 4.6
Diffstat (limited to 'src/corelib')
-rw-r--r--src/corelib/global/qglobal.cpp28
-rw-r--r--src/corelib/global/qnamespace.h29
-rw-r--r--src/corelib/global/qnamespace.qdoc2
-rw-r--r--src/corelib/kernel/qcoreevent.cpp2
-rw-r--r--src/corelib/kernel/qcoreevent.h4
-rw-r--r--src/corelib/plugin/quuid.cpp13
-rw-r--r--src/corelib/tools/qdatetime.cpp32
7 files changed, 68 insertions, 42 deletions
diff --git a/src/corelib/global/qglobal.cpp b/src/corelib/global/qglobal.cpp
index 742f4ec..9fc3c8d 100644
--- a/src/corelib/global/qglobal.cpp
+++ b/src/corelib/global/qglobal.cpp
@@ -46,6 +46,7 @@
#include "qthreadstorage.h"
#include "qdir.h"
#include "qstringlist.h"
+#include "qdatetime.h"
#ifndef QT_NO_QOBJECT
#include <private/qthread_p.h>
@@ -2523,6 +2524,33 @@ void qsrand(uint seed)
#endif
}
+/*! \internal
+ \relates <QtGlobal>
+ \since 4.6
+
+ Seed the PRNG, but only if it has not already been seeded.
+
+ The default seed is a combination of current time, a stack address and a
+ serial counter (since thread stack addresses are re-used).
+*/
+void qsrand()
+{
+#if defined(Q_OS_UNIX) && !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);
+ *pseed = QDateTime::currentDateTime().toTime_t()
+ + quintptr(&pseed)
+ + serial.fetchAndAddRelaxed(1);
+#else
+ // On Windows, we assume that rand() already does the right thing
+#endif
+}
+
/*!
\relates <QtGlobal>
\since 4.2
diff --git a/src/corelib/global/qnamespace.h b/src/corelib/global/qnamespace.h
index 4234a7e..ad4bc55 100644
--- a/src/corelib/global/qnamespace.h
+++ b/src/corelib/global/qnamespace.h
@@ -501,8 +501,6 @@ public:
WA_WState_AcceptedTouchBeginEvent = 122,
WA_TouchPadAcceptSingleTouchEvents = 123,
- WA_DontUseStandardGestures = 124,
-
// Add new attributes before this line
WA_AttributeCount
};
@@ -1615,9 +1613,29 @@ public:
enum GestureState
{
NoGesture,
- GestureStarted = 1,
- GestureUpdated = 2,
- GestureFinished = 3
+ GestureStarted = 1,
+ GestureUpdated = 2,
+ GestureFinished = 3,
+ GestureCanceled = 4
+ };
+
+ enum GestureType
+ {
+ TapGesture = 1,
+ TapAndHoldGesture = 2,
+ PanGesture = 3,
+ PinchGesture = 4,
+ SwipeGesture = 5,
+
+ CustomGesture = 0x0100,
+
+ LastGestureType = ~0u
+ };
+
+ enum GestureContext
+ {
+ WidgetGesture = 0,
+ WidgetWithChildrenGesture = 3
};
enum NavigationMode
@@ -1638,7 +1656,6 @@ public:
;
#endif
-
Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::MouseButtons)
Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::Orientations)
Q_DECLARE_OPERATORS_FOR_FLAGS(Qt::KeyboardModifiers)
diff --git a/src/corelib/global/qnamespace.qdoc b/src/corelib/global/qnamespace.qdoc
index ab232bf..385edad 100644
--- a/src/corelib/global/qnamespace.qdoc
+++ b/src/corelib/global/qnamespace.qdoc
@@ -1225,8 +1225,6 @@
\value WA_TouchPadAcceptSingleTouchEvents Allows touchpad single
touch events to be sent to the widget.
- \value WA_DontUseStandardGestures Disables standard gestures on Qt widgets.
-
\omitvalue WA_SetLayoutDirection
\omitvalue WA_InputMethodTransparent
\omitvalue WA_WState_CompressKeys
diff --git a/src/corelib/kernel/qcoreevent.cpp b/src/corelib/kernel/qcoreevent.cpp
index 744e6a9..5883042 100644
--- a/src/corelib/kernel/qcoreevent.cpp
+++ b/src/corelib/kernel/qcoreevent.cpp
@@ -228,6 +228,8 @@ 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 Gesture A gesture was triggered (QGestureEvent)
+ \value GestureOverride A gesture override was triggered (QGestureEvent)
User events should have values between \c User and \c{MaxUser}:
diff --git a/src/corelib/kernel/qcoreevent.h b/src/corelib/kernel/qcoreevent.h
index d66cead..ee1e1b9 100644
--- a/src/corelib/kernel/qcoreevent.h
+++ b/src/corelib/kernel/qcoreevent.h
@@ -283,6 +283,9 @@ public:
UpdateSoftKeys = 201, // Internal for compressing soft key updates
+ Gesture = 198,
+ GestureOverride = 202,
+
// 512 reserved for Qt Jambi's MetaCall event
// 513 reserved for Qt Jambi's DeleteOnMainThread event
@@ -324,6 +327,7 @@ private:
friend class QGraphicsView;
friend class QGraphicsViewPrivate;
friend class QGraphicsScenePrivate;
+ friend class QGestureManager;
};
class Q_CORE_EXPORT QTimerEvent : public QEvent
diff --git a/src/corelib/plugin/quuid.cpp b/src/corelib/plugin/quuid.cpp
index 7224ad3..3c79653 100644
--- a/src/corelib/plugin/quuid.cpp
+++ b/src/corelib/plugin/quuid.cpp
@@ -548,9 +548,11 @@ bool QUuid::operator>(const QUuid &other) const
On any platform other than Windows, this function returns a new
UUID with variant QUuid::DCE and version QUuid::Random. The random
numbers used to construct the UUID are obtained from the local
- pseudo-random generator, which is usually not a cryptographic
+ pseudo-random generator, qrand(), which is usually not a cryptographic
quality random number generator. Therefore, a UUID generated by
- this function can't be guaranteed to be unique.
+ this function can't be guaranteed to be unique. If the pseudo-random
+ number generator for the calling thread has not yet been seeded, this
+ function will seed the pseudo-random number generator by calling qsrand().
On a Windows platform, a GUID is generated, which almost certainly
\e{will} be unique, on this or any other system, networked or not.
@@ -578,6 +580,8 @@ QT_BEGIN_INCLUDE_NAMESPACE
#include "stdlib.h" // For srand/rand
QT_END_INCLUDE_NAMESPACE
+extern void qsrand(); // in qglobal.cpp
+
QUuid QUuid::createUuid()
{
static const int intbits = sizeof(int)*8;
@@ -585,10 +589,11 @@ QUuid QUuid::createUuid()
if (!randbits) {
int max = RAND_MAX;
do { ++randbits; } while ((max=max>>1));
- qsrand((uint)QDateTime::currentDateTime().toTime_t());
- qrand(); // Skip first
}
+ // reseed, but only if not already seeded
+ qsrand();
+
QUuid result;
uint *data = &(result.data1);
int chunks = 16 / sizeof(uint);
diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp
index 1277623..1b559cf 100644
--- a/src/corelib/tools/qdatetime.cpp
+++ b/src/corelib/tools/qdatetime.cpp
@@ -54,6 +54,7 @@
#ifndef Q_WS_WIN
#include <locale.h>
#endif
+
#include <time.h>
#if defined(Q_OS_WINCE)
#include "qfunctions_wince.h"
@@ -68,31 +69,6 @@
# define QDTPDEBUGN if (false) qDebug
#endif
-#if defined(Q_OS_SYMBIAN)
- // Workaround for OpenC bug.
-
- // OpenC incorrectly caches DST information between localtime_r
- // calls, i.e. if previous call to localtime_r has been called for DST
- // affected date, also the second call will be affected by DST even
- // the date is such that DST should not be applied.
-
- // The workaround is to call mktime with non-DST affected date before
- // calling localtime_r. mktime call resets the OpenC internal DST cache
- // to right value and localtime_r will return correct values.
-#define FIX_OPENC_DSTCACHE \
- tm localTM; \
- localTM.tm_sec = 0; \
- localTM.tm_min = 0; \
- localTM.tm_hour = 12; \
- localTM.tm_mday = 1; \
- localTM.tm_mon = 1; \
- localTM.tm_year = 2002 - 1900; \
- localTM.tm_isdst = -1; \
- time_t temp = mktime(&localTM);
-#else
-#define FIX_OPENC_DSTCACHE
-#endif
-
#if defined(Q_WS_MAC)
#include <private/qcore_mac_p.h>
#endif
@@ -1162,7 +1138,6 @@ QDate QDate::currentDate()
// use the reentrant version of localtime() where available
tzset();
tm res;
- FIX_OPENC_DSTCACHE
t = localtime_r(&ltime, &res);
#else
t = localtime(&ltime);
@@ -1859,13 +1834,12 @@ QTime QTime::currentTime()
// use the reentrant version of localtime() where available
tzset();
tm res;
- FIX_OPENC_DSTCACHE
t = localtime_r(&ltime, &res);
#else
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
@@ -2913,7 +2887,6 @@ QDateTime QDateTime::currentDateTime()
// use the reentrant version of localtime() where available
tzset();
tm res;
- FIX_OPENC_DSTCACHE
t = localtime_r(&ltime, &res);
#else
t = localtime(&ltime);
@@ -3731,7 +3704,6 @@ static QDateTimePrivate::Spec utcToLocal(QDate &date, QTime &time)
// use the reentrant version of localtime() where available
tzset();
tm res;
- FIX_OPENC_DSTCACHE
brokenDown = localtime_r(&secsSince1Jan1970UTC, &res);
#elif defined(_MSC_VER) && _MSC_VER >= 1400
tm res;