Commit Graph

3266 Commits

Author SHA1 Message Date
Sérgio Martins
9229452e57 Introduce QScopeGuard
A RAII style class which calls a function at end of scope.

Example usage:
    auto cleanup = qScopeGuard([] { <my cleanup code> ; });

[ChangeLog][QtCore] Introduced QScopeGuard.

Task-number: QTBUG-62894
Change-Id: Ife67f5c76255a1fafbae03367263da0bac9a0070
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-07-21 17:47:35 +00:00
Friedemann Kleint
189e40e11e Add QTextStream operators for QStringView
Change-Id: I72d597fa21521a04b7f7c0e41bd45ee9dabb6222
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2018-07-20 20:51:08 +00:00
Joni Jäntti
588fcde580 Revert "Blacklist tst_QThread::create"
The "boot2qt" platform needs to be blacklisted,
not "ubuntu-18.04".

This reverts commit 0d49ac0ffc.

Change-Id: I768a66c56f5fc7e0771473152579ed1c01bbbdb9
Reviewed-by: Sami Nurmenniemi <sami.nurmenniemi@qt.io>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2018-07-20 07:00:29 +00:00
Thiago Macieira
cc5d816800 Merge "Merge remote-tracking branch 'origin/5.11' into dev" into refs/staging/dev 2018-07-17 18:20:12 +00:00
Edward Welbourne
a9dfe71cca Fix typo: s/Numering/Numbering/
Kept the intended word (rather than "number system" or "numeral
system" as might seem more natural) since CLDR's
common/supplemental/numberingSystems.xml uses numbering in its name
and in the XML tag-names in its contents.  Thanks to Kari Oikarinen
for noticing, in review.

Change-Id: I85077611f9de8c4e812e1b5324fa2e99868b7b95
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2018-07-17 14:40:05 +00:00
Edward Welbourne
9d52eb9ed0 Made more tst_QLocale tests data-driven
This should improve reporting and ensure we know about each failing
case, not just the first, when one fails.

Change-Id: Ic00272201f69a2fd8508df23b1d746ea605aa539
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Kari Oikarinen <kari.oikarinen@qt.io>
2018-07-17 14:39:55 +00:00
Edward Welbourne
3c0f33e4a0 Assume Win >= Win7 in code that used to test it
Cleaned up some related #if-ery in the process.

Change-Id: I70f3152f2096ec34f36782fa1c3329f51c9b34f0
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2018-07-17 14:39:44 +00:00
Qt Forward Merge Bot
1783fca897 Merge remote-tracking branch 'origin/5.11' into dev
Conflicts:
	src/plugins/platforms/cocoa/qcocoawindow.mm
	src/plugins/platforms/xcb/qxcbintegration.cpp

 Conflicts git missed:
	src/plugins/platforms/qnx/qqnxglcontext.cpp

Change-Id: I0582cdc9e66e43efe79038b9c43d4f9572ac88fc
2018-07-17 10:19:22 +02:00
Edward Welbourne
b82648bd59 Update CLDR to version 33.1 (2018/June/20)
Routine update in preparation for 5.12
* omitting Chakma because QLocale can't represent the zero digit,
* de_DE no longer uses vorm./nachm. but AM/PM

[ChangeLog][Third-party code] Updated CLDR to version 33.1

Task-number: QTBUG-67654
Change-Id: If20c47bb030abc3700b4f5a592152e617e2767c2
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2018-07-16 15:47:28 +00:00
Edward Welbourne
9a58ba4793 Split up many long lines in tst_QLocale
Rewrote some of them away, in the process, using string arithmetic.

Change-Id: Ie1a29abefab001889a22a8bc66c7eee608496786
Reviewed-by: Albert Astals Cid <albert.astals.cid@kdab.com>
2018-07-16 15:23:11 +00:00
Edward Welbourne
cbd6a864e4 Adjust some indentation and spacing in tst_QLocale
This is preparation (the WS-only parts) for splitting up some
over-long lines, in the course of which I also fix some indentation.

Change-Id: I800490e328b5e16d40685dff04c09cd145d5eacf
Reviewed-by: Albert Astals Cid <albert.astals.cid@kdab.com>
2018-07-16 15:23:04 +00:00
Thiago Macieira
1f27c1161b QPluginLoader: limit the amount of memory used when scanning plugins
When using actual memory allocation, limit to 64 MB, not the full file
size. On most systems, the memory map technique will work, so this won't
even be tried. In any case, we don't need the fix for the OOM situation
that was applied in commit e211ab76d7.

As for the memory mapping technique, this commit limits the allocation
to reasonable values given the virtual memory addressing space. Half a
gigabyte is probably acceptable on 32-bit systems, where there should be
a contiguous space for the OS to allocate the file in. This commit also
fixes an overflow when converting from qint64 of the file size to ulong
(32-bit on 32-bit platforms and on Windows).

For 64-bit systems, we currently limit to 1 TB.

Change-Id: I117816bf0f5e469b8d34fffd153dc1705a8eedc4
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-07-14 04:37:46 +00:00
Friedemann Kleint
019dd88d2c QStringView: Add compare() member function
There was no public API for doing case-insensitive comparisons
of QStringView.

Task-number: QTBUG-69389
Change-Id: I1b021eefec35e135b97fb87704c8dc137232d83d
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2018-07-13 13:32:34 +00:00
Kai Koehne
9146432dc6 Allow loading of empty translation files
Do not return false for loading an empty .qm file - that is, a valid
file without any translations. We're already shipping empty .qm
files for English translations of Qt since a while, mainly as a
stop for the QTranslator::load(const QLocale &, ...) logic.

Note that QCoreApplication::installTranslator() will still return
false for an empty translation file - which is ok, because it
arguably does not make much sense to install it.

[ChangeLog][QtCore][QTranslator] It is now possible to load qm files
without any translations. This is particularly useful for the
language the untranslated strings are written in; logic to
load translations can now handle the source language like all
other languages.

Task-number: QTBUG-31031
Change-Id: Ibcb84aa755538cb2fa21b14f8635295a58440bbb
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
2018-07-12 08:54:33 +00:00
Allan Sandfeld Jensen
ad8df72156 Fix regression in QPointF::operator==
Handle hard zero independently in each coordinate, otherwise hard zero
is never equal to anything but itself.

Task-number: QTBUG-69368
Change-Id: I8b1131472bb92efc706a04e0b067e2211a5ccb0c
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2018-07-09 15:38:31 +00:00
Andre Hartmann
f98ee77cd3 QByteArray: toInt() and toDouble() ignore surrounding whitespaces
[ChangeLog][QtCore][QByteArray] QByteArray::toInt(),
QByteArray::toDouble() and the other number conversion functions
now ignore leading and trailing whitespaces, as their QString
counterparts already did. For consistency reasons, the same
behavior was added to qEnvironmentVariableIntValue() also.

Task-number: QTBUG-66187
Change-Id: I8b5e478ea8577b811d969286ea9e269f539c1ea4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2018-07-07 19:58:18 +00:00
Simon Hausmann
42cc42acae Fix QString::localeAwareCompare with composed/decomposed strings on macOS
Similar to commit cd64a96b31 we also need
to normalize the strings before comparison in order to be compliant with
the ECMAScript test suite.

This patch also adds the remaining test cases from
built-ins/String/prototype/localeCompare/15.5.4.9_CE.

Since the same tests are also failing with strcoll/qt_compare_strings,
this simplifies the code to always normalize except when using ICU
(which gets it right by default).

Change-Id: I16b32da7fc70dc7e6725c49f66fe9941d0bf3a47
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
2018-07-06 20:49:29 +00:00
Thiago Macieira
340472534c QCborValue: refactor extended types so isTag() is true
This makes QCborValue more future compatible, as code written today for
tags that QCborValue does not recognize will continue to work if
QCborValue gains support for it in the future.

This change also obviates the need for reinterpretAsTag(), which I had
not written unit tests for as I knew this change was coming.

Change-Id: I052407b777ec43f78378fffd15302bdc34f66755
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2018-07-05 14:56:12 +00:00
Edward Welbourne
9fc6b021f9 Fix a mis-use of QSKIP() to use qDebug() instead
QSKIP() discards the whole test it appears in; so is not the right way
to announce that (and why) the test has just skipped a few sub-tests.
This was concealing a later failure on macOS, here fixed.

Change-Id: I9b07208413b9e101569a22505ad41f07ade4062b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2018-07-04 07:07:04 +00:00
Edward Welbourne
64d6b82bf7 Fix tst_QLocale's mis-use of QSKIP() to use qDebug() instead
QSKIP() discards the whole test it appears in; so is not the right way
to announce that (and why) the test has just skipped a few sub-tests.
This was concealing a later failure on macOS, here fixed.
This matches an earlier fix for tst_QDateTime.

Change-Id: Idaf34a9d60d84202fd41d15455209457cc281f60
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2018-07-04 07:06:53 +00:00
Thiago Macieira
d0427759c6 Add qbswap for a memory region
The compiler was generating some vectorized code for qresource.cpp but
it wasn't very efficient. So improve upon it and make use in other
places where we read UTF-16BE strings.

[ChangeLog][QtCore] Added an overload of q{To,From}{Big,Little}Endian
that operates on a memory region.

Change-Id: I6a540578e810472bb455fffd1531fa2f1d724dfc
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2018-07-04 03:04:40 +00:00
Thiago Macieira
2bb44414ff QCborArray & Map: implement efficient take() / extract()
Questions:
 1) should QCborMap::extract return value_type (a pair) instead of just
    the value?
 2) should the both return the iterator to the next element too, like
    erase()?

Change-Id: I052407b777ec43f78378fffd15302a9c14468db3
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2018-07-04 03:04:21 +00:00
Thiago Macieira
fcb0f68e77 CBOR: Complete the conversions between CBOR, JSON and Qt meta types
Change-Id: I56b444f9d6274221a3b7fffd150d3130db6ef1a0
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2018-07-04 03:04:17 +00:00
Thiago Macieira
6c64a9b2d2 Metatype: make the Qt CBOR value-like types built-in meta types
This change only adds them to the registry and reserves the IDs. The
next commit will handle conversions.

Change-Id: I56b444f9d6274221a3b7fffd150d2d49f40940c2
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2018-07-04 03:04:15 +00:00
Liang Qi
e3ed2281c0 Merge remote-tracking branch 'origin/5.11' into dev
Conflicts:
	src/plugins/platforms/cocoa/qnsview.mm
	src/plugins/platforms/cocoa/qnsview_dragging.mm
	src/plugins/platforms/ios/qiosinputcontext.mm
	src/plugins/platforms/xcb/qxcbconnection.cpp
	src/plugins/platforms/xcb/qxcbconnection_xi2.cpp
	src/plugins/platforms/xcb/qxcbwindow.cpp
	src/tools/androiddeployqt/main.cpp
		Was moved from qttools into qtbase in 5.11.
		So re-apply 32398e4d here.
	tests/auto/corelib/global/qlogging/test/test.pro
	tests/auto/corelib/global/qlogging/tst_qlogging.cpp
	tests/auto/corelib/io/qfile/tst_qfile.cpp
	tests/auto/corelib/kernel/qtimer/tst_qtimer.cpp
	tests/auto/corelib/thread/qthreadstorage/test/test.pro
	tests/auto/widgets/itemviews/qheaderview/tst_qheaderview.cpp
	tests/auto/widgets/kernel/qapplication/test/test.pro

Done-with: Gatis Paeglis <gatis.paeglis@qt.io>
Done-with: Mårten Nordheim <marten.nordheim@qt.io>
Done-with: Oliver Wolff <oliver.wolff@qt.io>
Change-Id: Id970486c5315a1718c540f00deb2633533e8fc7b
2018-07-02 11:23:45 +02:00
Mårten Nordheim
6501c04250 Android: Pass tst_QFactoryLoader
Similar to the changes made for tst_QLibrary:
0ac09c40f2
but even less intrusive.

Change-Id: I4bc0ba385e639f07f9b39cf8ba9542c27be8a3ff
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2018-06-30 19:32:51 +00:00
Daniel Vrátil
35e005bc4f Fix metatype trait for types that are both QObject and Q_GADGET
Fixes ambiguous template instantiation for types that derive from both
a QObject and Q_GADGET. For such types we treat them only as QObjects
as they extend the functionality of the gadget.

Task-number: QTBUG-68803
Change-Id: Ic42766034e14e5df43c4e6f7811e2c0be1dc7e74
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2018-06-30 13:23:03 +00:00
Mårten Nordheim
0ac09c40f2 Android: Pass tst_qlibrary
To make the minimum amount of changes:
- Extract the library files into the expected hierarchy.
- Introduce a variable with the path to the directory.
- Make the static function a member function so it can use the variable

Change-Id: Ibf3106c3606d198a8deb8cb2a5cbde57207221c7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2018-06-29 19:02:09 +00:00
Oliver Wolff
40668b82f4 tst_qfile: Do not build helper application for winrt
The existence of the helper application confuses Coin which will
result in an error.

Change-Id: I3edf3f27acbe133b180d41a8ae950991e9a5b5da
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
2018-06-28 15:44:03 +00:00
Oliver Wolff
63f78e41dc tst_qthreadstorage: Fix execution for WinRT
Not putting executables into debug/release subdirectories leads to the
WinRT AppxManifest being overwritten by the wrong configuration. When Qt
is configured with -release for example, it was possible that the debug
manifest (Manifest files are always created next to the target) is
written last and thus contains debug VCLibs as a dependency.

Additionally the test was changed in that way, that the resulting file
system structure (having helper and test application in a "top level"
debug and release folder) is the same structure as in tst_qobject.

Change-Id: I53d5238ff36706eb9c6f8eb04b954ec595ca30de
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-06-28 15:44:00 +00:00
Oliver Wolff
8f143c75f0 tst_qfile: Fix execution for WinRT
Not putting executables into debug/release subdirectories leads to the
WinRT AppxManifest being overwritten by the wrong configuration. When Qt
is configured with -release for example, it was possible that the debug
manifest (Manifest files are always created next to the target) is
written last and thus contains debug VCLibs as a dependency.

Additionally the test was changed in that way, that the resulting file
system structure (having helper and test application in a "top level"
debug and release folder) is the same structure as in tst_qobject.

Change-Id: I55078563304959c41e0dd9bb7bb91a6fc51e005a
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2018-06-28 15:43:58 +00:00
Mårten Nordheim
8757e6fee1 Android: Make tst_qfile pass
By disabling the "stdinprocess"-related tests/code...

... but differently. After fixing my earlier mistakes I'm getting
segmentation faults when it executes a couple different library calls
after the QProcess object has started.

Task-number: QTBUG-68596
Change-Id: Id42a1f939c000754a187dee90c4a4cdfec816232
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2018-06-28 07:31:27 +00:00
Mårten Nordheim
d420987d54 Android: fix tst_qlogging
The "app" subfolder was already excluded in the .pro-file but Android
supports QProcess, so lets include it in the build. Unfortunately it
currently has trouble and crashes (the child process or both processes).
So we skip those tests.

Task-number: QTBUG-68596
Change-Id: I2e6d0869c408bf08b22c02145db8ce522c64c617
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2018-06-28 07:29:30 +00:00
Mårten Nordheim
568ee7da5a Android: Pass tst_qlocale
To make it run we make sure it finds the syslocaleapp, however since it
causes a crash we skip the test that uses it...

"formatTimeZone" was failing, but it is the exact same issue as in
e08ba34f26, so we solve it the exact same
way.

Change-Id: Ifd5c796735775dad94acf55210cf18c0f4d375ca
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2018-06-28 07:27:22 +00:00
Mårten Nordheim
6ee26c543e Android: Pass tst_QUuid
Same issue as has been seen a few other places: path to executable being
wrong, and then a crash when the paths are fixed.

Change-Id: I77a596c6e52d2a02a69a6b9dfe91f878b3ffe07c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2018-06-28 07:12:47 +00:00
David Faure
8a73085a0d QSortFilterProxyModel unittest: add test for filtered-out-after-setData
The row names for this test were very unspecific.
After reverse-engineering what they are testing, I gave them proper
descriptive names, which allowed me to notice that there were tests
for "filtered in after sourceModel->setData" but not for
"filtered out after sourceModel->setData".

Change-Id: Ib79108db803ae77fb65d29cf0c0ef96c26655980
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
2018-06-28 07:00:00 +00:00
Giuseppe D'Angelo
aaf60da01c QRegularExpression: fix compiler warning in test
QTest::addRow expects a format specifier; this usage makes GCC complain
with -Wformat-security. Use the "old" newRow call instead.

Change-Id: Ieed8e4f64ff5e3d0d4e87325629d20ed6839ff9d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2018-06-27 17:52:45 +00:00
Mårten Nordheim
7995540292 tst_qthreadpool: Skip "stackSize" if unsupported
If you're on a Unix platform which don't have the necessary defines then
the thread will never be launched due to an error. Skip the test
instead.

Change-Id: I83159988b8f330a750c7aa328a8805e4fa478070
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2018-06-27 17:40:28 +00:00
Thiago Macieira
10e5ec2557 QByteArray: implement qstricmp with SSE 4.1
Using SSE 4.1 because of the need for PMINUB.

Change-Id: Ib48364abee9f464c96c6fffd152ebd3f8ea7fe94
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2018-06-27 16:29:14 +00:00
Simon Hausmann
cd64a96b31 Fix QString::localeAwareCompare with composed/decomposed strings on Windows
With ICU and on macOS it appears that the comparison is done on a
canonical form, while CompareString(Ex) does not do that, as the added
test verifies. Explicit normalization fixes that.

As a bonus, this also unifies the code path between regular Windows
and UWP by unconditionally using CompareStringEx (which requires
Vista or later).

This issue surfaced while running the ECMASCript 6 Conformance Test
Suite in QtQml.

This re-uses the existing test for localeAwareCompare, which was
disabled on Windows, macOS and Linux with ICU (the common case).

Change-Id: I52440fce60b54745ead1eff005ec51e98e2a79ec
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
2018-06-27 16:21:22 +00:00
Oliver Wolff
00d9ade6e6 tst_qlogging: Fix execution for WinRT
Not putting executables into debug/release subdirectories leads to the
WinRT AppxManifest being overwritten by the wrong configuration. When Qt
is configured with -release for example, it was possible that the debug
manifest (Manifest files are always created next to the target) is
written last and thus contains debug VCLibs as a dependency.

Additionally the test was changed in that way, that the resulting file
system structure (having helper and test application in a "top level"
debug and release folder) is the same structure as in tst_qobject.

Change-Id: I034752b4e5d22b98f6def95fb53c2b1947dded03
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
2018-06-27 16:06:01 +00:00
David Faure
27ea5a65dd QAbstractItemModelTester: fix out-of-bounds index() calls
When removing rows, the tester is looking at the data of the row
"just before" and the row "just after" the removed rows, to see if
they are still the same at the end of the removal operation.
Guard this with bounds check, in case there is no row just before
or just after.

This is the opportunity to use modeltester in tst_qidentityproxymodel,
which was already a testcase for removing the only row in a given parent.

Change-Id: Iec8228c16b9c670b794e2665356d153679178494
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2018-06-27 10:11:35 +00:00
Mårten Nordheim
3079b3433d Android: tst_qtimezone: Blacklist a bunch
Task-number: QTBUG-69122
Task-number: QTBUG-69128
Task-number: QTBUG-69129
Task-number: QTBUG-69131
Change-Id: Ida626a6675764e9554785b5e56cfba3ab7206f17
Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io>
2018-06-27 07:52:26 +00:00
Mårten Nordheim
da82bfd823 Android: tst_QTimeZone::transitionEachZone: skip 2 zones
When testing zones "America/Mazatlan" and "Mexico/BajaSur" the test
crashes from an assert. Skip testing the zones for now.

Task-number: QTBUG-69132
Change-Id: I595089647792e9a2c094d63cb837584b8cdc9cb9
Reviewed-by: Jesus Fernandez <Jesus.Fernandez@qt.io>
2018-06-27 07:52:10 +00:00
Oliver Wolff
4d7137c4a0 tst_qobject: Fix execution in debug&release shadow builds
The previous approach of having the signalbug helper in a subdirectory did
not work for shadow builds, as QFINDTESTDATA would not find that dir. By
putting both test and helper into the same directory, the helper will be
found in the test's current working directory.

The second problem was that not putting executables into debug/release
subdirectories might have lead to the WinRT AppxManifest being overwritten
by the wrong configuration. When Qt is configured with -release for
example, it was possible that the debug manifest (Manifest files are
always created next to the target) is written last and thus contains
debug VCLibs as a dependency.

Change-Id: Ia39315432860405642542449296c16dd2ae9fa9f
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@qt.io>
2018-06-26 10:56:31 +00:00
Edward Welbourne
cffa010d42 Kludge round Android's ignorance of some esoteric time-zone transitions
Skip a few tests that Android's time-zone information doesn't suffice
to get right.

Task-number: QTBUG-68835
Change-Id: Ibf8d213c96b29d74fc478a0ede686ae52b5200fb
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2018-06-26 08:05:17 +00:00
Kari Oikarinen
1049d3f9db tst_QTimer: Replace unconditional qWait()s with QSignalSpy
Where possible. Sometimes the replacement is QTRY_COMPARE instead.

Also don't use QTestEventLoop directly when it can also be replaced with
QSignalSpy use.

Remove the TimerHelper class, since its uses can be done with QSignalSpy (and a
lambda when remainingTime is checked). Although checking static single-shot
timers still needs a target object, so use a stripped down version in those
tests.

remainingTimeDuringActivation() was not actually testing the repeating case, but
single-shot case twice, so fix that. In the repeating case the remaining time is
exactly 20 ms on my machine, but QEMU emulation seems to be slow enough for time
to advance before the lambda is executed, so relax the conditions.

Task-number: QTBUG-63992
Change-Id: Iae92ff7862a13d36e695eec63b54403ec872f2b4
Reviewed-by: Sami Nurmenniemi <sami.nurmenniemi@qt.io>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
2018-06-26 05:51:15 +00:00
Liang Qi
c3059391fe Make tests compile for Android
This only enables compilation, it doesn't fix any test.

Qt on Android supports process, but not TEST_HELPER_INSTALLS. See also
acdd57cb for winrt.

android-ndk-r10e is used to compile, see
http://doc-snapshots.qt.io/qt5-5.11/androidgs.html .

corelib/io/{qdir,qresourceengine} need to be fixed later.

Done-with: Frederik Gladhorn <frederik.gladhorn@qt.io>
Done-with: Mårten Nordheim <marten.nordheim@qt.io>
Change-Id: I34b924c8ae5d46d6835b8f0a6606450920f4423b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Frederik Gladhorn <frederik.gladhorn@qt.io>
2018-06-25 08:01:19 +00:00
Thiago Macieira
cad7100fda QByteArray: add compare() with case sensitivity options
Need to do the same for startsWith() and endsWith(). indexOf() is a lot
harder.

[ChangeLog][QtCore][QByteArray] Added compare(), which takes
Qt::CaseSensitivity as one of the parameters. This function is more
efficient than using toLower() or toUpper() and then comparing.

Change-Id: Ib48364abee9f464c96c6fffd152e69bde4194df7
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2018-06-22 20:12:41 +00:00
Giuseppe D'Angelo
06af9a1e38 QRegularExpression: refactor pattern optimization
After the move to PCRE2, optimizing patterns has been a thorn in the
side due to the fact that PCRE2's JIT compiler modifies the pattern
object itself (instead of returning a new set of data, like PCRE1
did). To make this fit with the existing behavior, a read/write
lock was introduced, with the read part locking when matching and
the write when compiling (or JIT-compiling) the pattern.

This locking strategy however introduced a performance issue,
as we needed:

* to acquire a write lock to compile/optimize the pattern (incl. the
common case where the pattern was already compiled, so bailing out
immediately);

* to acquire a read lock during the actual match, to prevent
some other thread from optimizing the pattern under our nose.

This was due to the "lazy" optimization policy of QRegularExpression
-- optimize a pattern after a certain number of usages. The
excessive amount of locking effectively limited scalability.

Simplify the code, and drop that policy altogether: since JIT
compiling in PCRE2 is faster and pretty much "always recommended",
just always do it for any pattern (unless it gets disabled via
env variables) when compiling it.

This allows to go back to a plain QMutex, and now the actual
matching doesn't require acquiring any locks any longer. Of course,
there is still a mutex acquired just before matching for checking
whether the pattern needs recompiling in the first place; this can
probably be further optimized via double-checked locking (using
atomics), but not doing it right now.

This shift makes a couple of pattern options controlling
optimization useless, and allows to centralize the 3
QRegularExpression tests (which were actually the very same test,
just setting slightly different optimizations strategies).

While at it, install a stress-test for threading, with the idea
of running it under TSAN or helgrind to catch bugs in
QRegularExpression's locking.

[ChangeLog][Important Behavior Changes][QRegularExpression] Regular
expressions are now automatically optimized (including JIT
compiling) on their first usage. The pattern options
OptimizeOnFirstUsageOption and DontAutomaticallyOptimizeOption no
longer have any effect, and will get removed in a future version of
Qt. QRegularExpression::optimize() can be still used to compile and
optimize the regular expression in advance (before any match), if
needed.

Task-number: QTBUG-66781
Change-Id: Ia0e97208ae78255fe811b78029ed01c204e47bd2
Reviewed-by: David Faure <david.faure@kdab.com>
2018-06-22 19:43:54 +00:00