summaryrefslogtreecommitdiffstats
path: root/src/corelib/tools
Commit message (Collapse)AuthorAgeFilesLines
* Ensure QLocale's shared C-locale QLocalePrivate is never deletedTor Arne Vestbø2013-11-041-3/+7
| | | | | | | | | | | | | | | | | Other static data such as QTextStream might be initialized before the static C-locale, in which case QLocale would adopt c_private and bump the ref-count to 2, only to see it reset back to 1 when the c_locale's static initialization happened. The result was that at application shutdown the ref-count would fall down to 0, and we tried deleting the static data. This issue was observed with clang in a debug build, where the c_private is initialized at runtime. Change-Id: If05221a5e87886e1805ad3c1b1520483f425c0fb Reviewed-by: Simon Hausmann <simon.hausmann@digia.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* QDateTime - Optimize refreshDateTime()John Layt2013-10-311-4/+1
| | | | | | | | | | A small optimization to the private refreshDateTime() function, improves standard performance tests by 0.3 msecs per iteration for affected functions, e.g. isValid() and offsetFromUtc() improve from 5.4 to 5.1. Change-Id: Ie67812649ef244388b484af35848b09d92dee38a Reviewed-by: Mitch Curtis <mitch.curtis@digia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QDateTime - Optimize date() and time() methodsJohn Layt2013-10-311-6/+8
| | | | | | | | | | | | | | | | | Optimize the performance of date() and time(), resulting in a one-third improvement, and subsequent improvements in all date/time based functions. Tested over 1000 iterations of the standard benchmarks, in msecs per iteration: Before After date()/time() 0.3 0.2 setDate()/setTime() 0.9 0.8 daysTo() 0.6 0.4 Note original performance before msecs storage was 0.06. Change-Id: Ie838e560ddf7129281531dc965af56ac19cce91d Reviewed-by: Mitch Curtis <mitch.curtis@digia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Remove unused static function systemtimeToMsecs()Kai Koehne2013-10-281-8/+0
| | | | | | | See also commit 660aed3516f91c that removed the reverse method. Change-Id: Ib20c5be863ba6644485c581e3ece47a390ce467d Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
* Change an addition into a subtractionThiago Macieira2013-10-191-1/+1
| | | | | | | | | | | | | | | | This potentially resolves the long-standing warning from GCC: assuming signed overflow does not occur when assuming that (X + c) < X is always false GCC prints the warning to warn people that you can't check for overflow with signed integers by doing that (signed integers don't overflow in the standard). If we change this to X < X - c, there's no overflow. Task-number: QTBUG-33314 Change-Id: I5b166610a39559ec7b03c4c31ee5999efefa0c06 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* QDateTime - Fix RFC 2822 Date FormattingJohn Layt2013-10-171-25/+3
| | | | | | | | | The RFC 2822 date format should always use en_US locale for month and day names instead of whatever the system locale is. Also remove some duplicate code. Change-Id: Ia2f7ee405b4e0e2f04980301783b9488628da73f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QLocale - Mac fix typos in commentsJohn Layt2013-10-171-2/+2
| | | | | | | Fix some typos in the comments. Change-Id: I14eed0ffed74f0a60b05441430158f71cb530c01 Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
* QDateTime - Fix toTimeSpec() for invalid datetimesJohn Layt2013-10-161-3/+30
| | | | | | | | | | Check if the datetime is valid before converting it to a different time spec. If it is invalid then just change the spec to keep behavior consistent with 5.1. Task-number: QTBUG-34020 Change-Id: I6630ec1d50f810a2178ab3222bd32af018085f81 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix wide-char use in Posix collatorMatt Hoosier2013-10-161-1/+2
| | | | | | | | | | | | | | Although the C++ language builds in the 'wchar_t' datatype, the library functions such as wcscmp() which manipulate them are not automatically available. For these, inclusion of the <cwhar> header is still required. This changeset fixes build breakage observed from failure to include the requisite system header for accessing wcscmp() and other related functions on non-GNU standard C++ library implementations. Change-Id: I5b2f9148ea011004e5dd00cf41698339db172de8 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QTimeZone - Fix finding Linux System Time ZoneJohn Layt2013-10-151-2/+2
| | | | | | | Extract the correct length sub-string from the /etc/sysconfig/clock file Change-Id: I37b4f625a51b172ed11ecefbd1b7dc562c5bb89d Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Add missing operators QMargins -=,+= (int).Friedemann Kleint2013-10-151-0/+18
| | | | | | | Task-number: QTBUG-34079 Change-Id: If61cc01ba70345b01f13072769d3a38f23e8cefc Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QMap - improve docs a bit (mainly by adding more time complexities)Thorbjørn Martsum2013-10-151-2/+13
| | | | | | Change-Id: I8a361ef09c338bbba228fd774b2bfd938869adc5 Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Improve implicit shared documentation a bitThorbjørn Martsum2013-10-156-7/+61
| | | | | | | | Task-number: QTBUG-27061 Change-Id: I66e000a9f59fda3654066013e6e78c3ba6fd27fe Reviewed-by: Mitch Curtis <mitch.curtis@digia.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QList - fix a few doc issuesThorbjørn Martsum2013-10-151-10/+14
| | | | | | | | | Though some of it was mensioned in the introduction to the class, we are not in O(1) if we modify a shared container. Change-Id: If63b4cb4bdfc98d6b1333bae307e5650341e5484 Reviewed-by: Sze Howe Koh <szehowe.koh@gmail.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Doc: Fix typos and add missing words.Marcel Krems2013-10-122-3/+3
| | | | | Change-Id: I40e4780bcabbca29425945a69d8a0781cd5c0e9f Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
* QVector: add some functions missing for QList compatMarc Mutz2013-10-112-9/+52
| | | | | | | | | | | | Eases migration from QList to QVector. Had to rename the 'length' parameter to mid() to suppress -Wshadow warnings. Task-number: QTBUG-3781 Change-Id: I755c6caefe4de81ea42a81b1c76aab728e639613 Reviewed-by: Lars Knoll <lars.knoll@digia.com>
* Doc: Adding mark-up to boolean default values.Jerome Pasion2013-10-0839-635/+635
| | | | | | | | | | | | | | | | | Default values should have mark-up to denote that they are code. This commit changes: -"property is true" to "property is \c true". -"Returns true" to "Returns \c true". -"property is false" to "property is \c false". -"returns true" to "returns \c true". -"returns false" to "returns \c false". src/3rdparty and non-documentation instances were ignored. Task-number: QTBUG-33360 Change-Id: Ie87eaa57af947caa1230602b61c5c46292a4cf4e Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@digia.com> Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
* QCommandLineOption: declare as sharedMarc Mutz2013-10-071-0/+2
| | | | | | | | | QCommandLineOptions are held in a QList in QCommandLineParser, so they better be declared movable, which is one of the things Q_DECLARE_SHARED enables. Change-Id: I75c8185534b4e9c1ea4417a9507095c8a6512aab Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* Remove unused static function msecsToSystemtime() from qtimezoneprivate_win.cpp.Friedemann Kleint2013-10-011-11/+0
| | | | | Change-Id: I8d6b4c9215fb4499affefd0b892cea1b77aa8ac9 Reviewed-by: John Layt <jlayt@kde.org>
* Fix grammar in QScopedPointer.Mitch Curtis2013-09-301-1/+1
| | | | | | | have => has Change-Id: Ib77110b8ffd2f970e15c2159480e56be9ef964ca Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
* QDateTime - Fix round-trip of second occurrence timesJohn Layt2013-09-272-15/+55
| | | | | | | | | | | | | | | | | | | | | | | At the Daylight Tme to Standard Time transition, the local time repeats itself, i.e. 2am occurs twice. Qt's behavior when setting this using the local time is ambiguous, as it depends on the system implementation of mktime, which behaves differently on different platforms. Currently this behavior remains undefined. When setting using an msecs or time_t value however we can determine the correct instance to use and cache it to ensure that any conversion back from local time to msecs is performed consistantly on all platforms. Note that caching this value will result in any calculations being wrong should the system time zone change, or its rules change. This will be fixed in Qt 5.3 when the system time zone change signal is implemented and QDateTime switches to using QTimeZone instead of mktime to provide consistnt behavior across platforms. The QTimeZone spec does not require this fix as it already caches the correct offset in setMSecsFromEpoch(). Change-Id: I799588db474e744a6d81e80f6a0442920569ebd3 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Doc: Add docs for rvalue references and move constructorsGeir Vattekar2013-09-2714-0/+219
| | | | | | | | | These members were introduced in 4.8, but left undocumented. Because we consider undocumented API to be internal, the members are \since 5.2. Change-Id: I52e2840a8cfaa7f59f410b3e2a06c0942ea06539 Reviewed-by: Jerome Pasion <jerome.pasion@digia.com> Reviewed-by: Stephen Kelly <stephen.kelly@kdab.com>
* QVarLengthArray - doc fix.Thorbjørn Martsum2013-09-271-2/+2
| | | | | | | | | QVarLengthArray actually does support iterators. It was added in Qt 4.8. Change-Id: I9f714a09eab1d2e5dc023bd701ab7c743b078ec0 Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* QLocale - Fix Mac date format code translationJohn Layt2013-09-261-29/+76
| | | | | | | | | | | | | | | | | | | | Mac uses the CLDR format codes which need to be translated into their Qt equivalent. The existing code mistranslates the year code, is outdated for a number of new codes introduced in recent versions of CLDR, and by default accepted any codes it didn't recognize. This change updates support to the latest version of CLDR, fixes the treatment of years, and defaults to ignoring any new format codes added in the future. Note that this change cannot have auto tests written as the system locale formats change between versions of OSX. Testing must be done manually by changing system locale and formats. Task-number: QTBUG-25057 Change-Id: I69dda25b4a0b38d3971995644546306876922d57 Reviewed-by: Morten Johan Sørvig <morten.sorvig@digia.com>
* QString::reserve fix to avoid truncationMarko Pellikka2013-09-261-2/+2
| | | | | | | | | | In case of implicit memory sharing, QString::reserve caused data truncation if given size was smaller than size of data. Task-number: QTBUG-29664 Change-Id: If2da5ad051385635ebb829c18b5ebaa349f08e8a Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@digia.com>
* Fix truncation and conversion warnings on MSVC2010.Mitch Curtis2013-09-251-1/+1
| | | | | Change-Id: I44845e13b97753333a7c80a80ead0b352b8906b0 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
* Fix configure warnings on Windows 7 with MSVC2010.Mitch Curtis2013-09-251-1/+1
| | | | | Change-Id: I5c4e27d6437cdf7b0dfd17df812d4506d1be4fb9 Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
* Fix warning about uninitialized variableLars Knoll2013-09-251-1/+1
| | | | | | Change-Id: I9c1a04556d4c77183d7025ca33314e7dfbf953ab Reviewed-by: John Layt <jlayt@kde.org> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix WinCE/MSVC2008 build.Sérgio Martins2013-09-242-0/+6
| | | | | | | See QTBUG-33473 for a similar problem. Change-Id: Ib446618945dc1e7e1e7d43819cfae5f3c411f1bb Reviewed-by: Marc Mutz <marc.mutz@kdab.com>
* Remove some qSort usages from QTimeZoneGiuseppe D'Angelo2013-09-241-3/+5
| | | | | | | | This is done per the mailing list discussion at http://www.mail-archive.com/development@qt-project.org/msg01603.html Change-Id: I974d41e986c67d1883c7d8dec879edd1fcbd08c2 Reviewed-by: John Layt <jlayt@kde.org>
* Fix conversion from 8-bit to QString without proper encodingThiago Macieira2013-09-231-1/+1
| | | | | | | | Found by ICC. Change-Id: Icd89e7df828afdb2acf2c46e00698ef04d5d94c9 Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com> Reviewed-by: John Layt <jlayt@kde.org>
* Fixed build issue on BlackBerryBernd Weimer2013-09-231-1/+1
| | | | | | | | | BlackBerry build was missing QTzTimeZonePrivate implementation. Change-Id: Ieaf6148a67c66f330e846c93f829ca17a4494359 Reviewed-by: Mehdi Fekari <mfekari@blackberry.com> Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Wolfgang Bremer <wbremer@blackberry.com>
* QDateTime - Add QTimeZone supportJohn Layt2013-09-236-14/+408
| | | | | | | | | | | Add support to QDateTime for time zones using the new QTimeZone class. [ChangeLog][QtCore][QDateTime] Add support for a new Qt::TimeZone spec to be used with QTimeZone to define times in a specific time zone. Change-Id: I21bfa52a8ba8989b55bb74e025d1f2b2b623b2a7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QTimeZone - Add Windows backendJohn Layt2013-09-234-1/+731
| | | | | | | Add backend implementation for Windows times zones. Change-Id: I30946f6672488c3f1d1d05754e9479aa62cce46f Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QTimeZone - Add Mac backendJohn Layt2013-09-234-2/+318
| | | | | | | Add Mac backend support Change-Id: Iafa2dbd925e18431f571e3eac62983015f8bc977 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QTimeZone - Add TZ File BackendJohn Layt2013-09-224-3/+1006
| | | | | | | | | | Add a backend for TZ Files. If available uses ICU for the display names and translations, otherwise the abbreviation is used. Change-Id: I58c777462810b1a76ea7bd95886836b70b8a3db5 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QTimeZone - Add ICU supportJohn Layt2013-09-224-1/+561
| | | | | | | Add ICU backend for QTimeZone Change-Id: I92e53a848477e366591102064b093e936f0b49d2 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* QTimeZone - Define new class and apiJohn Layt2013-09-226-0/+3029
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | Implement the new QTimeZone class based on the Olsen Time Zone ID's. This is the base implementation and does not include the Platform backends which are implemented separately. This change does include a default UTC backed to be used if no Platform backend is available, i.e. if QT_NO_SYSTEMLOCALE is set and ICU is not configured. This backend also provides a default set of time zones in the standard "UTC+00:00" offset format that are guaranteed to always exist regardless of the Platform backend. This change includes conversion functions between the Olsen ID's and Windows ID's using a conversion table based on Unicode CLDR data. This is implemented for all platforms for scenarios such as a Linux program needing to communicate with a Windows Exchange Server using the Windows ID. The CLDR conversion table is included under the UNICODE license, see http://unicode.org/copyright.html for details. [ChangeLog][QtCore][QTimeZone] Added new QTimeZone class to support time tone calculations using the host platform time zone database and the Olsen time zone ID's. Change-Id: Ibb417d08cf2663a0979d2be855d2c6ad6ad01509 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* Fix some doc errors.Frederik Gladhorn2013-09-213-2/+3
| | | | | | | Change-Id: Ib874d7e9671d9cee75fe41f4dac5d0de7b09245e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Topi Reiniö <topi.reinio@digia.com> Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
* Mark most of the contents of QtAlgorithms as deprecated.Robin Burchell2013-09-212-93/+223
| | | | | | | | | This is done per the mailing list discussion at http://www.mail-archive.com/development@qt-project.org/msg01603.html Change-Id: Ic31c052e7f35c576250bf11826ca82e371142c82 Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: Robin Burchell <robin+qt@viroteck.net>
* Add Mac type conversion functions to QtCoreMorten Johan Sørvig2013-09-214-2/+123
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | New API: static QString QString::fromCFString(CFStringRef string); CFStringRef QString::toCFString() const; static QString QString::fromNSString(const NSString *string); NSString *QString::toNSString() const; static QUrl QUrl::fromCFURL(CFURLRef url); CFURLRef QUrl::toCFURL() const; static QUrl QUrl::fromNSURL(const NSURL *url); NSURL * QUrl::toNSURL() const; Add Q_OS_MAC-protected function declarations to header files, add implementation to _mm files. CF and NS types are forward-declared in the header files to avoid including the CoreFoundation and Foundation headers. This prevents accidental use of native types in application code. Add helper macros for forward- declaration to qglobal.h Add cf_returns_retained/ns_returns_autoreleased attributes to toCFString() and toNSURL(). These attributes assists the clang static analyzer. Add Q_DECL_ helper macros to qcompilerdetection.h. Add test functions (in _mac.mm files) to the QString and QUrl tests. Split out the test class declarations into a separate headers files. Change-Id: I60fd5e93f042316196284c3db0595835fe8c4ad4 Reviewed-by: Gabriel de Dietrich <gabriel.dedietrich@digia.com>
* Merge "Merge remote-tracking branch 'origin/stable' into dev" into ↵Sergio Ahumada2013-09-211-7/+4
|\ | | | | | | refs/staging/dev
| * Merge remote-tracking branch 'origin/stable' into devFrederik Gladhorn2013-09-161-7/+4
| |\ | | | | | | | | | | | | | | | | | | Conflicts: src/corelib/tools/qstring.cpp Change-Id: Ifc6cd3a0f1cf14cc0fe6cf30afb0c7f40cfdbc3e
| | * Doc: Fix copy+paste errors in the QString class refSze Howe Koh2013-09-141-8/+4
| | | | | | | | | | | | | | | | | | | | | | | | Also bring text closer to the style guide at http://qt-project.org/wiki/CppDocumentationStyle Change-Id: I30b1c36ac125a10c002efeb36978ced0d7a8f8bf Reviewed-by: Jerome Pasion <jerome.pasion@digia.com>
* | | Remove qBinaryFind usages from bootstrapped filesGiuseppe D'Angelo2013-09-202-7/+11
| | | | | | | | | | | | | | | | | | | | | | | | This is done per the mailing list discussion at http://www.mail-archive.com/development@qt-project.org/msg01603.html Change-Id: I492b49553bc889892f5ca0c47aa13c75e11518e2 Reviewed-by: Olivier Goffart <ogoffart@woboq.com>
* | | QLinkedList: implement missing initializer_list ctorMarc Mutz2013-09-202-0/+20
| | | | | | | | | | | | | | | | | | | | | | | | | | | Found by tst_QLinkedList once compiled in C++11 mode. Change-Id: Idbf79d775c5271437dbb99c1c8cc7a2e8a7f08bf Reviewed-by: Thiago Macieira <thiago.macieira@intel.com> Reviewed-by: Olivier Goffart <ogoffart@woboq.com> Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
* | | QDateTime - Move some code aroundJohn Layt2013-09-201-231/+229
| | | | | | | | | | | | | | | | | | | | | | | | Move some of the static helper and private functions to better organize the code. No code actually changed. Change-Id: I6d5dd6bcb9fc5af56d2dbe9e53bc9f0a000c4fa4 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | | QDateTime - Add api for isDaylightTime()John Layt2013-09-202-0/+27
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Add new method to return if the current time is Daylight Time. [ChangeLog][QtCore][QDateTime] Added new method isDaylightTime() to return if the datetime is in Daylight Time or not. Change-Id: Icb93fd5dd0b2f7d83d2d4643eeb12922c1137e3e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | | QDateTime - Change serialise formatJohn Layt2013-09-201-28/+61
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Change the datetime serialisation from using QDateTimePrivate::Spec to using Qt::TimeSpec. Only public classes and enums are now used to serialise, making the format safer.. Clean up the code to make each version clearer, this duplicates some code but is easier to read and support. Change-Id: I3d8fc05f50f8e8acb9edbb992e5ce06063654b8e Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
* | | QDateTime - Fix Daylight Transition for "missing" hourJohn Layt2013-09-202-31/+153
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | When Daylight Time transtion goes from Standard Time to Daylight Time there is a "missing" hour, i.e. at 2am CET the clock goes forward to 3am. Currently QDateTime ignores this gap and considers the time to be valid and able to be manipulated. This change respects the transition, so any time set in the missing hour is considered invalid, and any date maths returns valid results. The validity in the current time zone needs to be checked every time isValid() is called in case the system time zone has changed since the last time it was checked. This is done by calling mktime to check the returned result matches the expected result. This could be very inefficient, but the returned offset value is cached each time so mktime is not required to be called again within each method call, effectively meaning mktime is called the same number of times by each method. Note that this means any new methods added must be careful to ensure either isValid() or refreshLocalTime() is called first by any method needing to use the UTC value. [ChangeLog][QtCore][QDateTime] The Standard Time to Daylight Time transition for Qt::LocalTime is now handled correctly. Any date set in the "missing" hour is now considered invalid. All date math results that fall into the missing hour will be automatically adjusted to a valid time in the following hour. Change-Id: Ia652c8511b45df15f4917acf12403ec01a7f08e7 Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>