QDateTime's short names setUtcOffset() and utcOffset() have been
deprecated since 5.2, in favor of setOffsetFromUtc() and
offsetFromUtc().
QDate's shortDayName() and shortMOnthName() have been deprecated since
5.10, in favor of QLocale's dayName() and monthName(). Also, the
tests that were using them are testing methods only present when the
datestring feature is enabled; so condition them on that feature.
Change-Id: Ibfd4b132523ca8fbc1cb163353a44e0500877fd5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Includes a fixup for 03fadc26e7, which
removed the check on empty transition list, needed when no data are
available. Ensured that such a data-free zone would in fact be
noticed as invalid during init().
Fixed handling of times before the epoch (we still want to consult a
POSIX rule, if that's all that's available) while ensuring we (as
documented) ignore DST for such times.
Fixed handling of large times (milliseconds since epoch outside int
range) when looking up POSIX rules. Gave QTimeZonePrivate a YearRange
enum (to be moved to QTimeZone once this merges up to dev) so as to
eliminate a magic number (and avoid adding another). Moved
year-munging in POSIX rules after the one early return, which doesn't
need the year range.
Added test-cases for the distant past/future (just checking UTC's
offsets; SLES has a minimal version of the UTC data-file that triggers
the bugs fixed here for them).
Fixes: QTBUG-74666
Fixes: QTBUG-74550
Change-Id: Ief7b7e55c62cf11064700934f404b2fc283614e1
Reviewed-by: Tony Sarajärvi <tony.sarajarvi@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
A string can parse as a non-zero double that's smaller than the
smallest float yet be a faithful representation of the smallest float.
So rather than testing for non-zero doubles less than the smallest
float, test for non-zero doubles that cast to float zero; these
underflow. This means small values close below the smallest float
shall round up to it, rather than down to zero, requiring a tweak to
an existing test. Added a test for the boundary case (and tidied the
test data).
Fixes: QTBUG-74833
Change-Id: I4cb30b3c0e54683574b98253505607caaf88fbfb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
While an invalid time-zone shall have no transitions, so may various
constant zones, like UTC. The TZ data may include only the POSIX rule
for such a zone, in which case we should use it, even if there are no
transitions.
Broke out a piece of repeated code as a common method, in the process,
since I was complicating it further.
Added test for the case that revealed this; and made sure we see a
warning if any of the checkOffset() tests gets skipped because its
zone is unsupported.
Fixes: QTBUG-74614
Change-Id: Ic8e039a2a9b3f4e0f567585682a94f4b494b558d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
[ChangeLog][qmake] A new feature "cmdline" was added that implies
"CONFIG += console" and "CONFIG -= app_bundle".
Task-number: QTBUG-27079
Change-Id: I6e52b07c9341c904bb1424fc717057432f9360e1
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Constructing a QStringRef directly from the string, offset and a
length is UB if the offset + length exceeds the string's length.
Thanks to Robert Loehning and libFuzzer for finding this.
QString::midRef (as correctly used in both changed uses of QStringRef,
since 432d3b6962) takes care of that for us. Changed one UB case and
a matching but correct case, for consistency.
In the process, deduplicate a QStringList look-up.
Added tests to exercise the code (but the one that exercises the
formerly UB case doesn't crash before the fix, so isn't very useful;
the invalid read is only outside the array it's scanning, not outside
allocated memory).
Change-Id: I7051bbbc0267dd7ec0a8f75eee2034d0b7eb75a2
Reviewed-by: Anton Kudryavtsev <antkudr@mail.ru>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
The test started to fail now also for latest Windows 10 Update
Restone 2. It's unclear why the test was succeeding before, since this
seems a generic Windows API issue.
Task-number: QTBUG-64985
Task-number: QTQAINFRA-2255
Change-Id: I804f6a61c63ea70157353d1aee9027d0735073ab
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Various tests were setting the default locale and relying on cleanup()
to "restore" the C locale; which needn't actually be the locale we
started out in and, in any case, was the wrong locale for some tests.
So handle this via an RAII class that records the actual prior locale
and restores it on destruction.
Fixes: QTBUG-73116
Change-Id: If44f7cb8c6e0ce81be396ac1ea8bab7038a86729
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
tst_QString::localeAwareCompare() is failing since
ab448f731e because the 'C' locale no
longer initializes ICU and falls back to simple QString comparison.
Fix it by explicitly setting the locale for the testdata to en_US so the
QCollator is properly initialized.
Task-number: QTBUG-73116
Change-Id: I9d4d55e666c5c52f93298dedb7e22da01a25318d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Also blacklist tst_QRawFont::unsupportedWritingSystem() and
tst_QGlyphRun::mixedScripts() on windows for now.
Conflicts:
qmake/generators/makefile.cpp
src/corelib/itemmodels/qstringlistmodel.cpp
src/platformsupport/fontdatabases/windows/qwindowsfontengine_p.h
tests/auto/corelib/itemmodels/qstringlistmodel/tst_qstringlistmodel.cpp
tests/auto/gui/text/qglyphrun/BLACKLIST
tests/auto/gui/text/qrawfont/BLACKLIST
Task-number: QTBUG-72836
Change-Id: I10fea1493f0ae1a5708e1e48d0a4d7d6b76258b9
The current implementation of wildcardToRegularExpression doesn't
anchor the pattern which makes it not narrow enough for globbing
patterns. This patch fixes that by applying anchoredPattern before
returning the wildcard pattern.
[ChangeLog][QtCore][QRegularExpression] The wildcardToRegularExpression
method now returns a properly anchored pattern.
Change-Id: I7bee73389d408cf42499652e4fb854517a8125b5
Fixes: QTBUG-72539
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Previously, the C locale was treated as English because each back-end
takes the locale's bcp47Name(), which maps C to en. However, the C
locale has its own rules; which QString helpfully implements; so we
can delegate to it in this case. Extended this to sort keys, where
possible. Clean up existing implementations in the process.
Extended tst_QCollator::compare() with some cases to check this. That
required wrapping the test's calls to collator.compare() in a sign
canonicalizer, since it can return any -ve for < or +ve for >, not
just -1 and +1 for these cases (and it'd be rash to hard-code specific
negative and positive values, as they may vary between backends).
[ChangeLog][QtCore][QCollator] Added support for collation in the C
locale, albeit this is only well-defined for ASCII. Collation sort
keys remain unsupported on Darwin.
Fixes: QTBUG-58621
Change-Id: I327010d90f09bd1b1816f5590cb124e3d423e61d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
All types that can be trivially copied and destructed are by definition
relocatable, and we should apply those semantics when moving them in
memory.
Types that are trivial, are by definition not complex and should be
treated as such.
[ChangeLog][QtCore] Qt Containers and meta type system now use C++11
type traits (std::is_trivial, std::is_trivially_copyable and
std::is_trivially_destructible) to detect the class of a type not
explicitly set by Q_DECLARE_TYPEINFO. (Q_DECLARE_TYPEINFO is still
needed for QList.)
Done-with: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
Change-Id: Iebb87ece425ea919e86169d06cd509c54a074282
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Fixed a misguided condition in the check for bogus texts in the sscanf
branch of the decoder; it checked for 'e' but neglected 'E', which is
just as valid.
Change-Id: I9236c76faea000c92df641930e401bce445e06c8
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Revised some toFloat()s to be consistent with the matching
toDouble()s; previously, they would return infinity if toDouble() did
but return 0 if toDouble() got a finite value outside float's range.
That also applied to values that underflowed float's range, succeeding
and returning 0 as long as they were within double's range but failing
if toDouble() underflowed. Now float-underflow also fails. Amended
their documentation to reflect this more consistent reality.
Added some tests of out-of-range values, infinities and NaNs.
[ChangeLog][QtCore][toFloat] QString, QByteArray and QLocale returned
an infinity on double-overflow (since 5.7) but returned 0 on a finite
double outside float's range, while setting ok to false; this was at
odds with their documented behavior of returning 0 on any failure.
They also succeeded, returning zero, on underflow of float's range,
unless double underflowed, where they failed. Changed the handling of
values outside float's range to match that of values outside double's
range: fail, returning an infinity on overflow or zero on underflow.
The documentation now reflects the revised behavior, which matches
toDouble().
Change-Id: Ia168bcacf7def0df924840d45d8edc5f850449d6
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
They actually return infinity if conversion overflows, while still
setting ok to false; they were documented to return 0 on failure, with
no mention of this special handling of overflow. Documented reality
rather than changing the behavior. Gave underflow as an example of
failure other than overflow (toDouble()s do indeed fail on it).
Added some tests of out-of-range values, infinities and NaNs.
[ChangeLog][QtCore][toDouble] QString, QByteArray and QLocale return
an infinity on overflow (since 5.7), while setting ok to false; this
was at odds with their documented behavior of returning 0 on failure.
The documentation now reflects the actual behavior.
Fixes: QTBUG-71256
Change-Id: I8d7e80ba1f06091cf0f1480c341553381103703b
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
A couple of QLocale tests were using setlocale twice to provide a
transient locale tweak in tests; however, if the test in between
fails, that can leave the program running in the "transient" locale
after. So implement a proper class whose destructor ensures the
transient is tidied away. Also change the locale in use by one of
these transient changes: it purported to be checking things didn't
depend on locale, but was using the same local as most of the
test-cases for its test.
Change-Id: I0d954edcc96019a8c2eb12b7a7c568e8b87a41d5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Use 'msvc' instead of 'win32-msvc' or even 'win32-mscv*'.
Change-Id: I21dc7748a4019119066aea0a88a29a61827f9429
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
This test was taking so much time that it regularly timed out on WinRT
and when running in qemu. Reduce it from around 40 to 7 seconds on a
powerful desktop.
Now it either runs for two full seconds for each test function or until
it has done 50 iterations.
Fixes: QTBUG-71405
Change-Id: If752c1e65d3b19009b883f64edc96d020df479d1
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
This avoids memory allocation and data copying in e.g.
QObject::property().
Detected by heaptrack's "Temporary allocations" counter in an
application using the breeze widget style (many animations).
Change-Id: Iabdb58a3e504cb121cce906ef707b0722de89df6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
PCRE2 does not support JIT on winrt. This test row takes a long time
(30 seconds here) without JIT and thus might cause test timeouts in
COIN when run on winrt.
Change-Id: I79d9f6be16dbe16594ae2bf51f353acd06b3d2fe
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
POSIX specifies that tzset() consults environment variable TZ and
modifies some globals; it also specifies mktime(), localtime() and
strftime() to behave as if they called tzset(). Fortunately, we only
call strftime() from a test and only call localtime() when not
threaded. Provide wrappers for tzset() and mktime() that share the
lock used by our environment-access code, to prevent races on the
environment (and tzset()'s globals) when we call them.
In the process, re-use tst_QDateTime's TimeZoneRollback in its older
test systemTimeZoneChange() and presume that this can now be tested
cross-platform, since TimeZoneRollback is used in another test where
this works.
Fixes: QTBUG-71030
Change-Id: I79f559b8857ea2803e73501008bf0d7158c6731f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
When a time-zone does a spring-forward, skipping an hour (either to
start DST or to move its standard time), there's an hour that doesn't
exist on the day in question. That hour can be the first hour of the
day, in which case using 0:0 as the default time is broken. So catch
this case and use the first time that day that makes sense.
Fixes: QTBUG-70823
Change-Id: I23dae9320a3cdd2c988841a7db1b111edb945730
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Before this change we inserted newline only if an option has a
description and ended up with an arbitrary long line with all options.
[ChangeLog][QtCore][QCommandLineParser] Fixed a bug that caused the help
output to show two options or more in the same line if the options didn't
have a description.
Task-number: QTBUG-70174
Change-Id: Id54b9ae13ee596869e4dc14e09301aea19eed2f8
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
This is already blacklisted for macOS 10.12 and reproducing in 10.13.
Task-number: QTBUG-61037
Change-Id: I464e42d0ae5ab24104250edc69a90454ba605eaa
Reviewed-by: Liang Qi <liang.qi@qt.io>