From 1b47059c886d76cc1a403e74abd034cce3b53a34 Mon Sep 17 00:00:00 2001 From: Mitch Curtis Date: Thu, 3 Jan 2013 13:01:17 +0100 Subject: Clarify how two digit years are parsed by QDateTime::fromString(). It's currently not obvious that two digit years will always be in the 20th century (1900's). Task-number: QTBUG-28797 Change-Id: I7dee9a46e0cb803a8f097debc5443d1789c2f16c Reviewed-by: Thiago Macieira Reviewed-by: Venugopal Shivashankar --- src/corelib/tools/qdatetime.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/corelib/tools') diff --git a/src/corelib/tools/qdatetime.cpp b/src/corelib/tools/qdatetime.cpp index 9ac4c1a87f..9949aeb7a1 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: -- cgit v1.2.3 From a094bf5a893c3cccffff10c1420bfbe3a3c02a7c Mon Sep 17 00:00:00 2001 From: Thiago Macieira Date: Thu, 3 Jan 2013 15:17:21 -0200 Subject: Don't increase the reference count if dynamic_cast failed If the dynamic_cast failed in QSharedPointer::dynamicCast or qSharedPointerDynamicCast, we should avoid creating the QSharedPointer that shares the weak and strong reference counts. In Qt 5, this does not imply a leak since the original pointer is stored internally for deletion. In Qt 4 it implies a leak under certain circumstances, which this change fixes. Task-number: QTBUG-28924 Change-Id: Id2de140de4cf676461e14b201ad250c53666b79d Reviewed-by: Olivier Goffart --- src/corelib/tools/qsharedpointer_impl.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/corelib/tools') diff --git a/src/corelib/tools/qsharedpointer_impl.h b/src/corelib/tools/qsharedpointer_impl.h index 6f3e577e55..cce48e0d07 100644 --- a/src/corelib/tools/qsharedpointer_impl.h +++ b/src/corelib/tools/qsharedpointer_impl.h @@ -786,6 +786,8 @@ template Q_INLINE_TEMPLATE QSharedPointer qSharedPointerDynamicCast(const QSharedPointer &src) { register X *ptr = dynamic_cast(src.data()); // if you get an error in this line, the cast is invalid + if (!ptr) + return QSharedPointer(); return QtSharedPointer::copyAndSetPointer(ptr, src); } template -- cgit v1.2.3 From fbd3cd867952a43d008dcfe6ae5657387603283a Mon Sep 17 00:00:00 2001 From: Joerg Bornemann Date: Fri, 4 Jan 2013 15:04:54 +0100 Subject: remove unused member from QSystemLocalePrivate This is a refactoring leftover from commit bb86e77cc437b92d49692bb7026c57626d77079f in qt/qt.git. Change-Id: I04993faca44ad0ffca2ae163049770c29d232a47 Reviewed-by: Zeno Albisser Reviewed-by: Denis Dzyubenko --- src/corelib/tools/qlocale_win.cpp | 3 --- 1 file changed, 3 deletions(-) (limited to 'src/corelib/tools') 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(); } -- cgit v1.2.3