diff options
Diffstat (limited to 'src/corelib')
-rw-r--r-- | src/corelib/doc/snippets/code/src_corelib_tools_qdatetime.cpp | 16 | ||||
-rw-r--r-- | src/corelib/global/qcompilerdetection.h | 7 | ||||
-rw-r--r-- | src/corelib/kernel/qeventdispatcher_blackberry.cpp | 31 | ||||
-rw-r--r-- | src/corelib/kernel/qmetaobject.cpp | 2 | ||||
-rw-r--r-- | src/corelib/kernel/qmetatype.cpp | 1 | ||||
-rw-r--r-- | src/corelib/tools/qdatetime.cpp | 12 | ||||
-rw-r--r-- | src/corelib/tools/qlocale_win.cpp | 3 | ||||
-rw-r--r-- | src/corelib/tools/qsharedpointer_impl.h | 2 |
8 files changed, 57 insertions, 17 deletions
diff --git a/src/corelib/doc/snippets/code/src_corelib_tools_qdatetime.cpp b/src/corelib/doc/snippets/code/src_corelib_tools_qdatetime.cpp index a2b128800e..d57c1314a8 100644 --- a/src/corelib/doc/snippets/code/src_corelib_tools_qdatetime.cpp +++ b/src/corelib/doc/snippets/code/src_corelib_tools_qdatetime.cpp @@ -143,6 +143,8 @@ QDateTime dateTime = QDateTime::fromString("130", "Mm"); // invalid //! [14] QDateTime dateTime = QDateTime::fromString("1.30.1", "M.d.s"); // dateTime is January 30 in 1900 at 00:00:01. +dateTime = QDateTime::fromString("12", "yy"); +// dateTime is January 1 in 1912 at 00:00:00. //! [14] //! [15] @@ -191,4 +193,16 @@ UTC.setTimeSpec(Qt::UTC); qDebug() << "UTC time is:" << UTC; qDebug() << "There are" << local.secsTo(UTC) << "seconds difference between the datetimes."; -//! [19]
\ No newline at end of file +//! [19] + +//! [20] +QString string = "Monday, 23 April 12 22:51:41"; +QString format = "dddd, d MMMM yy hh:mm:ss"; +QDateTime invalid = QDateTime::fromString(string, format); +//! [20] + +//! [21] +QString string = "Tuesday, 23 April 12 22:51:41"; +QString format = "dddd, d MMMM yy hh:mm:ss"; +QDateTime valid = QDateTime::fromString(string, format); +//! [21] diff --git a/src/corelib/global/qcompilerdetection.h b/src/corelib/global/qcompilerdetection.h index 7fae3d9dbc..0ba0d9be63 100644 --- a/src/corelib/global/qcompilerdetection.h +++ b/src/corelib/global/qcompilerdetection.h @@ -693,7 +693,7 @@ #endif /* Q_CC_MSVC */ #ifdef __cplusplus -# if defined(Q_OS_BLACKBERRY) || defined(Q_OS_QNX) +# if defined(Q_OS_QNX) # include <utility> # if defined(_YVALS) || defined(_LIBCPP_VER) // QNX: libcpp (Dinkumware-based) doesn't have the <initializer_list> @@ -702,9 +702,12 @@ # ifdef Q_COMPILER_INITIALIZER_LISTS # undef Q_COMPILER_INITIALIZER_LISTS # endif +# ifdef Q_COMPILER_RVALUE_REFS +# undef Q_COMPILER_RVALUE_REFS +# endif # endif # endif -#endif // Q_OS_BLACKBERRY || Q_OS_QNX +#endif // Q_OS_QNX /* * C++11 keywords and expressions diff --git a/src/corelib/kernel/qeventdispatcher_blackberry.cpp b/src/corelib/kernel/qeventdispatcher_blackberry.cpp index 69b4a8b172..3e958ee277 100644 --- a/src/corelib/kernel/qeventdispatcher_blackberry.cpp +++ b/src/corelib/kernel/qeventdispatcher_blackberry.cpp @@ -271,6 +271,11 @@ void QEventDispatcherBlackberry::unregisterSocketNotifier(QSocketNotifier *notif } } +static inline int timevalToMillisecs(const timeval &tv) +{ + return (tv.tv_sec * 1000) + (tv.tv_usec / 1000); +} + int QEventDispatcherBlackberry::select(int nfds, fd_set *readfds, fd_set *writefds, fd_set *exceptfds, timeval *timeout) { @@ -279,9 +284,6 @@ int QEventDispatcherBlackberry::select(int nfds, fd_set *readfds, fd_set *writef BpsChannelScopeSwitcher channelSwitcher(d->bps_channel); - // Make a note of the start time - timeval startTime = qt_gettime(); - // prepare file sets for bps callback d->ioData->count = 0; d->ioData->readfds = readfds; @@ -298,15 +300,15 @@ int QEventDispatcherBlackberry::select(int nfds, fd_set *readfds, fd_set *writef if (exceptfds) FD_ZERO(exceptfds); + bps_event_t *event = 0; + unsigned int eventCount = 0; + // Convert timeout to milliseconds int timeoutTotal = -1; if (timeout) - timeoutTotal = (timeout->tv_sec * 1000) + (timeout->tv_usec / 1000); - + timeoutTotal = timevalToMillisecs(*timeout); int timeoutLeft = timeoutTotal; - - bps_event_t *event = 0; - unsigned int eventCount = 0; + timeval startTime = qt_gettime(); // This loop exists such that we can drain the bps event queue of all native events // more efficiently than if we were to return control to Qt after each event. This @@ -331,11 +333,20 @@ int QEventDispatcherBlackberry::select(int nfds, fd_set *readfds, fd_set *writef // Clock source is monotonic, so we can recalculate how much timeout is left if (timeoutTotal != -1) { timeval t2 = qt_gettime(); - timeoutLeft = timeoutTotal - ((t2.tv_sec * 1000 + t2.tv_usec / 1000) - - (startTime.tv_sec * 1000 + startTime.tv_usec / 1000)); + timeoutLeft = timeoutTotal + - (timevalToMillisecs(t2) - timevalToMillisecs(startTime)); if (timeoutLeft < 0) timeoutLeft = 0; } + + timeval tnext; + if (d->timerList.timerWait(tnext)) { + int timeoutNext = timevalToMillisecs(tnext); + if (timeoutNext < timeoutLeft || timeoutTotal == -1) { + timeoutTotal = timeoutLeft = timeoutNext; + startTime = qt_gettime(); + } + } } // Wait for event or file to be ready diff --git a/src/corelib/kernel/qmetaobject.cpp b/src/corelib/kernel/qmetaobject.cpp index 3616d0e825..b9bd74c2bd 100644 --- a/src/corelib/kernel/qmetaobject.cpp +++ b/src/corelib/kernel/qmetaobject.cpp @@ -472,7 +472,7 @@ int QMetaObject::constructorCount() const /*! Returns the number of methods in this class, including the number of - properties provided by each base class. These include signals and slots + methods provided by each base class. These include signals and slots as well as normal member functions. Use code like the following to obtain a QStringList containing the methods diff --git a/src/corelib/kernel/qmetatype.cpp b/src/corelib/kernel/qmetatype.cpp index 6194f20912..0d737ac1a3 100644 --- a/src/corelib/kernel/qmetatype.cpp +++ b/src/corelib/kernel/qmetatype.cpp @@ -240,6 +240,7 @@ struct DefinedTypesFilter { \omitvalue PointerToQObject \omitvalue WeakPointerToQObject \omitvalue TrackingPointerToQObject + \omitvalue WasDeclaredAsMetaType */ /*! diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index f84644b37d..f4770b528c 100644 --- a/src/corelib/tools/qdatetime.cpp +++ b/src/corelib/tools/qdatetime.cpp @@ -3533,6 +3533,18 @@ QDateTime QDateTime::fromString(const QString& s, Qt::DateFormat f) This could have meant 1 January 00:30.00 but the M will grab two digits. + Incorrectly specified fields of the \a string will cause an invalid + QDateTime to be returned. For example, consider the following code, + where the two digit year 12 is read as 1912 (see the table below for all + field defaults); the resulting datetime is invalid because 23 April 1912 + was a Tuesday, not a Monday: + + \snippet code/src_corelib_tools_qdatetime.cpp 20 + + The correct code is: + + \snippet code/src_corelib_tools_qdatetime.cpp 21 + For any field that is not represented in the format, the following defaults are used: diff --git a/src/corelib/tools/qlocale_win.cpp b/src/corelib/tools/qlocale_win.cpp index ec9db24b57..a61f9b39fe 100644 --- a/src/corelib/tools/qlocale_win.cpp +++ b/src/corelib/tools/qlocale_win.cpp @@ -113,8 +113,6 @@ struct QSystemLocalePrivate void update(); private: - QByteArray langEnvVar; - enum SubstitutionType { SUnknown, SContext, @@ -142,7 +140,6 @@ Q_GLOBAL_STATIC(QSystemLocalePrivate, systemLocalePrivate) QSystemLocalePrivate::QSystemLocalePrivate() : substitutionType(SUnknown) { - langEnvVar = qgetenv("LANG"); lcid = GetUserDefaultLCID(); } diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index 6393cc3970..2c8e03a5dd 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -813,6 +813,8 @@ template <class X, class T> Q_INLINE_TEMPLATE QSharedPointer<X> qSharedPointerDynamicCast(const QSharedPointer<T> &src) { register X *ptr = dynamic_cast<X *>(src.data()); // if you get an error in this line, the cast is invalid + if (!ptr) + return QSharedPointer<X>(); return QtSharedPointer::copyAndSetPointer(ptr, src); } template <class X, class T> |