Commit Graph

9028 Commits

Author SHA1 Message Date
Giuseppe D'Angelo
d4435a37ca Add qobject_cast operators for std::shared_ptr
Mimicking what we currently have for QSharedPointer, but also adding
* snake_case version (matching the ones in std)
* rvalue-overloaded versions (matching the C++2a overloads).

[ChangeLog][QtCore][QSharedPointer] Overloads of
qSharedPointerObjectCast have been added to work on std::shared_ptr.

Change-Id: I26ddffd82b000bf876e7c141fdce86a7b8c1d75a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2019-05-01 18:37:32 +00:00
Shawn Rutledge
23c2da3cc2 Add QTextMarkdownWriter, QTextEdit::markdown property etc.
A QTextDocument can now be written out in Markdown format.

- Add the QTextMarkdownWriter as a private class for now
- Add QTextDocument::toMarkdown()
- QTextDocumentWriter uses QTextMarkdownWriter if setFormat("markdown")
  is called or if the file suffix is .md or .mkd
- Add QTextEdit::toMarkdown() and the markdown property

[ChangeLog][QtGui][Text] Markdown (CommonMark or GitHub dialect) is now
a supported format for reading into and writing from QTextDocument.

Change-Id: I663a77017fac7ae1b3f9a400f5cd357bb40750af
Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
2019-05-01 14:31:27 +00:00
Jesus Fernandez
d647cf85fa Tests: Simplify MyCookieJar
Don't reimplement the protected functions in the base class just
override the access with the using keyword.

Change-Id: I323487d9ddb1d458d5faca020c3eb4d931a9b226
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2019-04-29 14:11:00 +00:00
Qt Forward Merge Bot
4a54e8fd82 Merge remote-tracking branch 'origin/5.13' into dev
Change-Id: Ic712e8a84b01b212bb1121d7a2c9b85e0d2da9da
2019-04-29 01:00:22 +02:00
Qt Forward Merge Bot
9f1a1e320c Merge remote-tracking branch 'origin/5.12' into 5.13
Change-Id: Ibce9bfef928ce39070183c488ce86ae32e5ea705
2019-04-28 01:00:26 +02:00
Qt Forward Merge Bot
03f7d0a005 Merge remote-tracking branch 'origin/5.13' into dev
Change-Id: I1c9449ab064deed1367a7e5dbedfcb489f28140e
2019-04-27 01:00:11 +02:00
Lars Knoll
b4cc294347 Fix page breaking with large images
Don't go into an infinite loop breaking pages, when an image is about
as large as the page. Correctly take top and bottom margins into account
when calculating whether the image could fit on one page.

Amends change 416b4cf685.

Fixes: QTBUG-73730
Change-Id: Id311ddf05510be3b1d131702f4e17025a9861e58
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
2019-04-26 18:21:18 +00:00
Tony Sarajärvi
902ae438aa Extend blacklisting of dirsBeforeFiles as it's flaky
Task-number: QTBUG-75452
Change-Id: I4b35dfff6c0a888e62441e51985e0bccb2081be1
Reviewed-by: Heikki Halmet <heikki.halmet@qt.io>
2019-04-26 16:41:51 +00:00
Eirik Aavitsland
ecfda0d523 Fix manual lance test: avoid using deprecated api
...and other slight modernizations and minor fixes.

Change-Id: Ide587d9fe59ca9113ae775882c99a50debaf9000
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2019-04-26 07:47:12 +00:00
Qt Forward Merge Bot
0dff40adf8 Merge remote-tracking branch 'origin/5.12' into 5.13
Change-Id: I6ecf7074eda57ef4954fb3fdc7a6d1e8cd229340
2019-04-26 01:00:13 +02:00
Christian Ehrlicher
c530ca1c17 QLineF: add intersects() as a replacement for intersect()
QLineF::intersect() does not follow the naming rules for functions.
Therefore add a replacement function intersects() instead and also
rename the return type from IntersectType to IntersectionType

[ChangeLog][QtCore][QLineF] added QLineF::intersects() as a replacement
for QLineF::intersect()

Change-Id: I744b960ea339cb817facb12f296f78cca3e7d938
Reviewed-by: Jędrzej Nowacki <jedrzej.nowacki@qt.io>
Reviewed-by: Konstantin Shegunov <kshegunov@gmail.com>
2019-04-25 17:58:40 +00:00
Ryan Chu
658f12d735 Expose docker test server as an internal config to all modules
Before testserver becomes a stable feature, let's keep testserver.prf in
"mkspecs/features/unsupported". The test server's shared files will be
stored in "mkspecs/features/data/testserver".

Because the path of testserver has been changed, all the tests relying
on the docker servers should be updated as well.

Change-Id: Id2494d2b58ee2a9522d99ae61c6236021506b876
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2019-04-25 15:33:06 +00:00
Ryan Chu
713f77176e Support multi-stage builds to provision the configurations and test data
In order to reuse the test server to the external modules, it is much
easier to share the common configurations (scripts) and test data via
Dockerfile. In addition, the external module can create more layers
depending on their needs. Therefore, supporting multi-stage builds is
needed. The disadvantage is that the docker-compose needs to re-build
the images every time. However, it is just a one-time effort. If the
Dockerfile doesn't get changed, the extra build time can be ignored.

Because of multi-stage builds, the test server will keep a Dockerfile at
least. Therefore, the volume sharing is no more needed. The test data of
a service can be added into the images by using COPY/ADD commands.

NOTE:
This patch relies on docker-compose v1.21.0 (docker-compose build now
supports the use of Dockerfile from outside the build context).

Change-Id: Ib3f6a5fcf6979732ae8a40a494a1360fca4ac7bf
Reviewed-by: Maurice Kalinowski <maurice.kalinowski@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2019-04-25 15:32:57 +00:00
Eirik Aavitsland
d6c3fa6e0c Fix aliased painting with non-uniform scaling
The full stroker does not produce good results for aliased lines
thinner than 1 pixel. Avoid it by making sure that such thin lines
are painted by the cosmetic stroker, even when they have
non-uniform transformation.

Fixes: QTBUG-73866
Change-Id: I7b5f0fa555903246e0c3fd92cd435cc8c0b15a24
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2019-04-25 06:07:00 +00:00
Marc Mutz
e6d9617c79 QHash/QMultiHash: add range constructors
QMap and QMultiMap will go in a separate commit, due to QMap's
insertion behavior that "reverses" the inserted elements.

[ChangeLog][QtCore][QHash] Added range constructor.

[ChangeLog][QtCore][QMultiHash] Added range constructor.

Change-Id: Icfd0d0afde27792e8439ed6df3e8774696b134d3
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Sérgio Martins <sergio.martins@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2019-04-25 00:10:03 +00:00
Edward Welbourne
80853afd73 Add startOfDay() and endOfDay() methods to QDate
These methods give the first and last QDateTime values in the given
day, for a given time-zone or time-spec.  These are usually the
relevant midnight, or the millisecond before, except when time-zone
transitions (typically DST changes) skip it, when care is needed to
select the right moment.  Adapted some code to make use of the new
API, eliminating some old cruft from qdatetimeparser_p.h in the
process.

[ChangeLog][QtCore][QDate] Added startOfDay() and endOfDay() methods
to provide a QDateTime at the start and end of a given date, taking
account of any time skipped by transitions, e.g. a DST spring-forward,
which can lead to a day starting at 01:00 or ending just before 23:00.

Task-number: QTBUG-64485
Change-Id: I3dd7a34bedfbec8f8af00c43d13f50f99346ecd0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2019-04-24 13:09:26 +00:00
Edward Welbourne
3abfa4dfff QtTestLib: handle float16 the same as double and float
In QCOMPARE, handle NaNs and infinities the way tests want them
handled, rather than by strict IEEE rules. In particular, if a test
expects NaN, this lets it treat that just like any other expected
value, despite NaN != NaN as float16 values. Likewise, format
infinities and NaNs specially in toString() so that they're reported
consistently.

Enable the qfloat16 tests that depend on this QCOMPARE() behavior.
Refise the testlib selftest's float test to test qfloat16 the same way
it tests float and double (and format the test the same way).

This is a follow-up to 37f617c405.

Change-Id: I433256a09b1657e6725d68d07c5f80d805bf586a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2019-04-24 13:09:15 +00:00
Edward Welbourne
934000c11a Implement qFpClassify(qfloat16)
This extends support for qfloat16 sufficiently for the things testlib
needs in order to treat it as a first-class citizen.  Extended tests
for qfloat to check qFpClassify() on it.

Change-Id: I906292afaf51cd9c94ba384ff5aaa855edd56da1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2019-04-24 13:08:52 +00:00
Edward Welbourne
2eb849ed51 Implement std::numeric_limits<qfloat16>
This shall make it more nearly a first-class numeric type; in
particular, I need some of these for testlib's comparing and
formatting of float16 to handle NaNs and infinities sensibly.

Change-Id: Ic894dd0eb3e05653cd7645ab496463e7a884dff8
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2019-04-24 13:08:43 +00:00
Liang Qi
dc37318684 Merge remote-tracking branch 'origin/5.13' into dev
Conflicts:
	src/gui/util/qshaderformat.cpp
	src/gui/util/qshaderformat_p.h
	src/widgets/graphicsview/qgraphicsitem_p.h

Change-Id: Idafd88eb9a0a15b4af29f6143d009c1ec8ceecca
2019-04-24 09:52:30 +02:00
Edward Welbourne
9dfc2aa75d Purge use of some deprecated methods from QDateTime tests
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>
2019-04-23 17:31:21 +00:00
David Faure
ed66c932b1 QListWidgetItem constructors: don't emit dataChanged(invalid, invalid)
This is a regression introduced by 63967313f5 which blocked signals
on the view, but not on the model.

Change-Id: Ib2f93fe6ef842264aaba200c98ee4a19065ca220
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Konstantin Shegunov <kshegunov@gmail.com>
Reviewed-by: Laurent Montel <laurent.montel@kdab.com>
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
2019-04-23 16:17:20 +00:00
Shawn Rutledge
7718b70898 Blacklist tst_QWidget::windowState on WinRT
Task-number: QTBUG-75270
Change-Id: Icf1089b4d3681bc6a42be9c095acb5315dd67781
Reviewed-by: Gatis Paeglis <gatis.paeglis@qt.io>
2019-04-23 11:32:28 +00:00
David Faure
ba6e0e4aac QHeaderView: fix assert when restoring section sizes over less columns
If columns are removed and we get notified via layoutChanged, the code
tries to restore old section sizes, and went out of bounds, leading to
an assert in QVector. Simply add an if() to skip restoring out-of-bounds columns.

This comes from https://bugs.kde.org/show_bug.cgi?id=395181,
which translates into the unittest that is part of this commit.

Change-Id: Ide42176a758f87b21957c40508127d67f1d5a2d9
Reviewed-by: Christian Ehrlicher <ch.ehrlicher@gmx.de>
Reviewed-by: Thorbjørn Lund Martsum <tmartsum@gmail.com>
2019-04-23 09:42:54 +00:00
Samuel Gaist
e2906ea5c4 QRegExp include cleanup
QRegExp includes can be found in several files where there's not even a
use of the class. This patch aims to avoid needless includes as well as
follow the "include only what you use" moto.

This patch removes a QRegExp include from the QStringList header which
means that there is likely going to be code breaking since QStringList
is used in many places and would get QRegExp in.

[ChangeLog][Potentially Source-Incompatible Changes] qstringlist.h no
longer includes qregexp.h.

Change-Id: I32847532f16e419d4cb735ddc11a26551127e923
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2019-04-19 21:21:17 +00:00
Marc Mutz
2e1763d83a Non-associative containers: add range constructors
Something nice we'd like to detect for array-backed containers
is if the iterator passed is a Contiguous one; if the type is also
trivially copyable / Q_PRIMITIVE_TYPE, we could memcpy() the whole
range.

However, there's no trait in the Standard to detect contiguous
iterators (the best approximation would be detecting if the iterator
is actually a pointer). Also, it's probably not smart to do the work
now for QVector since QVector needs refactoring anyhow, and this work
will be lost.

QString and QByteArray are left in another commit.

[ChangeLog][QtCore][QVector] Added range constructor.

[ChangeLog][QtCore][QVarLengthArray] Added range constructor.

[ChangeLog][QtCore][QList] Added range constructor.

[ChangeLog][QtCore][QStringList] Added range constructor.

[ChangeLog][QtCore][QLinkedList] Added range constructor.

[ChangeLog][QtCore][QSet] Added range constructor.

Change-Id: I220edb796053c9c4d31a6dbdc7efc5fc0f6678f9
Reviewed-by: Milian Wolff <milian.wolff@kdab.com>
2019-04-17 08:11:21 +00:00
Friedemann Kleint
7a84a0a6d1 uic test: Test Python
Add a test that checks for the Presence of Qt for Python
and runs Python compile tests on the baseline files.

Task-number: PYSIDE-797
Change-Id: I7e15c3c75261a7d94fc6654a95d49ba323cbe7d6
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
2019-04-16 07:40:45 +00:00
Friedemann Kleint
7fe52779f4 uic test: Pre-populate the test data array
Task-number: PYSIDE-797
Change-Id: I2beed73f20bbfc8b5b4f2352cc53d80a64b95d8e
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
2019-04-16 07:40:41 +00:00
Liang Qi
9d67bf6e96 Merge remote-tracking branch 'origin/5.12' into 5.13
Conflicts:
	src/corelib/tools/qlocale.qdoc
	tests/auto/corelib/io/qfileinfo/tst_qfileinfo.cpp

Done-with: Edward Welbourne <edward.welbourne@qt.io>
Done-with: Volker Hilsheimer <volker.hilsheimer@qt.io>
Change-Id: I88e0757b2d020f0a244714c87844631df4b3fd13
2019-04-16 09:34:50 +02:00
Hugo Beauzée-Luyssen
2a815855a9 corelib: invokeMethod: Allow non copyable functors to be used
[ChangeLog][QtCore][QMetaObject] Non-copyable lambdas can now be used
with invokeMethod(). For consistency reasons, the functor object is
now always moved.

Fixes: QTBUG-69683
Change-Id: I66ff5e21d6d1926f0f7c5f8c304bed1a90b69917
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2019-04-12 20:18:20 +00:00
Allan Sandfeld Jensen
8f44aeb103 Add Extended RGB model to QColor
Can be used to represent wide-gamut and HDR colors.

Change-Id: I1cca442069ce2f2c070f723fe930fe1f2f5580ad
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2019-04-12 14:57:02 +00:00
Frederik Gladhorn
21dcb96ddc QStyleSheetStyle::repolish: only run on direct children
When re-parenting, some widgets change their children. For example
QLabel, when set to rich text, will not update, until receiving a polish
call, at which time getting a list of all children recursively and then
trying to call functions on them will crash, since the children change
in the middle of this operation.

Fixes: QTBUG-69204
Fixes: QTBUG-74667
Change-Id: I95dd83ebeed14c017e22552ddd47658ae8a09353
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2019-04-12 14:33:32 +00:00
Ulf Hermann
e7e557cea2 moc: Add a standard way of specifying a URI as part of Q_PLUGIN_METADATA
Usually, when you load a plugin, you don't want to load just any plugin
that fulfills a given interface, but rather a specific one. When loading
dynamic plugins you can differentiate the plugins by file name. This
doesn't work in the static case, and file names are also separate from
the plugin metadata shipped inside the plugin files.

To solve this problem, different hacks have been developed in various
places. QML extension plugins add a special property "uri" via the -M
option of moc, QML debug plugins expect you to add a json file with
an array of "Keys", Qt Creator plugins have a "Name" in their json
files, etc.

By allowing the identifier for the plugin to be specified inline with
the metadata declaration we can make many of the above workarounds
obsolete and provide a clean way for users to find their plugins.

Task-number: QTBUG-74775
Change-Id: Ie2af16c49d4c5aa5a77fab0fae1e0a4449bd7a39
Reviewed-by: Olivier Goffart (Woboq GmbH) <ogoffart@woboq.com>
2019-04-11 14:43:27 +00:00
Johan Klokkhammer Helsing
217f3d83d7 tst_QWidget: Skip based on capabilities instead of platform == wayland
Skip based on support for window activation instead of platform. Makes it clear
why the tests are skipped, and also enables them automatically if we implement
a shell extension that adds support for it.

Task-number: QTBUG-66849
Change-Id: I322aba5ce5f8db651db7b71f223ffacec037c920
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2019-04-11 11:48:33 +00:00
Liang Qi
c7af193d2e Merge remote-tracking branch 'origin/5.13' into dev
Conflicts:
	src/widgets/styles/qstyle_p.h

Change-Id: I0e6e856bd6628da1135b3ba674dddffabbeb5c09
2019-04-11 07:47:21 +02:00
Paul Lemire
a552864c3b QShaderGenerator: don't generate temporary variables for global inputs
Up until now, the QShaderGenerator would create temporary variables
for uniform, attributes, const. This change makes it use the global
inputs directly rather than relying on the intermediate properties.

Change-Id: Ia9497367d61e536969fe87536606f309c286dbb2
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
2019-04-10 09:52:53 +00:00
Paul Lemire
60181f13a3 QShaderGenerator: fix substitution for attributes on GL2/ES2
GL2/ES2 expect it to be attribute and not in like later versions of OpenGL.

Task-number: QTBUG-74829
Change-Id: Iddd22386ed315d6e6843d8225e49a4b73b6ad9ba
Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
2019-04-10 09:52:50 +00:00
Liang Qi
a20da2353c Merge remote-tracking branch 'origin/5.13' into dev
Conflicts:
	mkspecs/win32-clang-msvc/qmake.conf
	src/gui/image/qpnghandler.cpp

Change-Id: Ied79d02912ffb3a307a99483df7db08c7f9d0cd8
2019-04-10 08:16:20 +02:00
Volker Hilsheimer
3f17029aa1 Fix resolving NTFS symbolic links that point to UNC shares
Without this change, the target of a symbolic link that points to a UNC
share would include UNC in the target path, and not be correctly made
absolute.

Add a relevant test case, and use the opportunity to factor out the
helper code that creates NTFS symlinks into a function that takes
care of error handling.

The file created with the new test case only gets cleaned up correctly
when passing the file path into QDir::rmdir, which is either way the
right thing to do.

[ChangeLog][QtCore][QFileInfo] Fixed resolving of symbolic links to UNC
shares on NTFS file systems.

Change-Id: I9ba75d627aedf7c4cc289f0cb71088d795d30d8a
Fixes: QTBUG-73688
Task-number: QTBUG-63970
Task-number: QTBUG-30401
Task-number: QTBUG-20791
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2019-04-10 04:53:52 +00:00
Qt Forward Merge Bot
ff88e20b83 Merge remote-tracking branch 'origin/5.12' into 5.13
Change-Id: I44eda44bf424fdcffab048a2534905d6162e5559
2019-04-10 01:00:08 +02:00
Milian Wolff
5f2afe18cc Fix QMetaObject::newInstance on non-QObject meta object
QMetaObject::newInstance returns a QObject, thus it's not possible to
create a new instance of a Q_GADGET using this function. Previously, we
returned a non-null QObject pointer for such scenarios, which then
leads to crashes when one tries to use it. Now, we check whether the
meta object inherits QObject's meta object, and error out early
otherwise.

Change-Id: I7b1fb6c8d48b3e98161894be2f281a491963345e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2019-04-09 15:46:35 +00:00
Allan Sandfeld Jensen
95f787bfdc Replace Q_DECL_NOTHROW with noexcept the remaining places
The first replacement had missed objective-C++ code some places ourside
the src dir.

In C-files Q_DECL_NOTHROW is replaced with Q_DECL_NOEXCEPT as we still
need to turn it off when compiled in C mode, but can get rid of the old
NOTHROW moniker.

Change-Id: I6370f57066679c5120d0265a69e7e378e09d4759
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2019-04-09 14:48:42 +00:00
Allan Sandfeld Jensen
0bee05f4c1 Make the 64 bit raster backend an optional feature
Can be used to make smaller binaries, and possibly speed up ARGB32
rendering on some platforms.

Change-Id: I7647b197ba7a6582187cc9736b7e0d752bd5bee5
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2019-04-09 12:53:19 +00:00
Friedemann Kleint
84ce5022ce QFileDialog (widgets-based): Remember selection in history
Extend the history by a persistent model index list
reflecting the selection.

[ChangeLog][QtWidgets][QFileDialog] The widgets-based dialog now
remembers the selected files when navigating the history

Fixes: QTBUG-71415
Change-Id: I86774439be070c1b922acd0e9a27d029f02f68d3
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2019-04-09 11:15:36 +00:00
Timur Pocheptsov
4b445481c3 tst_http2 - extend 'singleRequest' test case
to test different h2 modes: "h2c" (clear text with protocol upgrade),
"h2" (encrypted, negotiating via ALPN extension), "h2-direct" (encrypted,
no ALPN), "h2c-direct" (plain text, no protocol upgrade). This patch-set
is  an amendment to the recent fix in the protocol handler where we were
crashing in "h2c-direct" mode.

Change-Id: I3ff5ed1396a59b72b59a95f927d404ccd202d0b8
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2019-04-09 04:08:01 +00:00
Qt Forward Merge Bot
93acb76222 Merge remote-tracking branch 'origin/5.12' into 5.13
Change-Id: I05d14a40e17554691bad369d0363e88413afd9b3
2019-04-09 01:00:06 +02:00
Friedemann Kleint
f7949df243 tst_QUrl: Fix left-over temporary directory on Windows
The test changes the current directory to the test directory
in fromUserInputWithCwd(), but did not restore it, causing:

Totals 898 passed, 0 failed, 1 skipped, 0 blacklisted, 368ms
********* Finished testing of tst_QUrl *********
QTemporaryDir Unable to remove "C:\\TEMP\\tst_qurl-ryVxqu" most likely due to the presence of read-only files.

Restore the old directory at the end to fix this.

Change-Id: I62669868f3c6d97dd38ebac76515428c14b7e1e7
Reviewed-by: David Faure <david.faure@kdab.com>
2019-04-08 18:44:25 +00:00
Qt Forward Merge Bot
01a269593d Merge remote-tracking branch 'origin/5.12.3' into 5.12
Change-Id: Id60d508c0f25fd5e67be07daafd2d4c56ae73934
2019-04-08 09:53:39 +02:00
Milian Wolff
58b4e07369 Optimize QTimer::singleShot(0, ...) when taking PMF or Functor callable
QTimer::singleShot is optimized for zero timeouts when using the API
taking a string method name. This optimization was not used for the API
taking a PMF or functor. This patch adds it, making the various API
calls behave similarly from a performance point of view.

The approach taken here requires a QObject context object. If none is
available, e.g. a nullptr was passed explicitly, or the
QTimer::singleShot(O, Functor) API was used, the optimization could
not easily be applied. This is not only bad from a performance POV,
but also poses as a potential source for heisenbugs: Using the
different API versions of QTimer::singleShot would use different code
paths internally, which then would not ensure the expected slot call
order. This problem actually existed already when mixing the
string-based slot syntax with PMF/functors in the QTimer::singleShot
API.

This patch overcomes this hurdle and fixes all of the above: When we
encounter a 0ms single shot timer, and no QObject context object is
available, we fall back to the main thread, or create a temporary
QObject for any other thread. The updated and extended benchmark
shows that this is still a significant performance improvement
over using a timer:

********* Start testing of qtimer_vs_qmetaobject *********
Config: Using QtTest library 5.14.0, Qt 5.14.0 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 8.2.1 20181127)
PASS   : qtimer_vs_qmetaobject::initTestCase()
PASS   : qtimer_vs_qmetaobject::bench(singleShot_slot)
RESULT : qtimer_vs_qmetaobject::bench():"singleShot_slot":
     7.48 msecs per iteration (total: 748, iterations: 100)
PASS   : qtimer_vs_qmetaobject::bench(singleShot_pmf)
RESULT : qtimer_vs_qmetaobject::bench():"singleShot_pmf":
     7.20 msecs per iteration (total: 720, iterations: 100)
PASS   : qtimer_vs_qmetaobject::bench(singleShot_functor)
RESULT : qtimer_vs_qmetaobject::bench():"singleShot_functor":
     6.79 msecs per iteration (total: 679, iterations: 100)
PASS   : qtimer_vs_qmetaobject::bench(singleShot_functor_noctx)
RESULT : qtimer_vs_qmetaobject::bench():"singleShot_functor_noctx":
     6.92 msecs per iteration (total: 693, iterations: 100)
PASS   : qtimer_vs_qmetaobject::bench(invokeMethod_string)
RESULT : qtimer_vs_qmetaobject::bench():"invokeMethod_string":
     7.34 msecs per iteration (total: 735, iterations: 100)
PASS   : qtimer_vs_qmetaobject::bench(invokeMethod_pmf)
RESULT : qtimer_vs_qmetaobject::bench():"invokeMethod_pmf":
     6.90 msecs per iteration (total: 690, iterations: 100)
PASS   : qtimer_vs_qmetaobject::bench(invokeMethod_functor)
RESULT : qtimer_vs_qmetaobject::bench():"invokeMethod_functor":
     6.62 msecs per iteration (total: 662, iterations: 100)
PASS   : qtimer_vs_qmetaobject::benchBackgroundThread(singleShot_slot)
RESULT : qtimer_vs_qmetaobject::benchBackgroundThread():"singleShot_slot":
     7.45 msecs per iteration (total: 745, iterations: 100)
PASS   : qtimer_vs_qmetaobject::benchBackgroundThread(singleShot_pmf)
RESULT : qtimer_vs_qmetaobject::benchBackgroundThread():"singleShot_pmf":
     7.46 msecs per iteration (total: 747, iterations: 100)
PASS   : qtimer_vs_qmetaobject::benchBackgroundThread(singleShot_functor)
RESULT : qtimer_vs_qmetaobject::benchBackgroundThread():"singleShot_functor":
     6.70 msecs per iteration (total: 671, iterations: 100)
PASS   : qtimer_vs_qmetaobject::benchBackgroundThread(singleShot_functor_noctx)
RESULT : qtimer_vs_qmetaobject::benchBackgroundThread():"singleShot_functor_noctx":
     13.75 msecs per iteration (total: 1,376, iterations: 100)
PASS   : qtimer_vs_qmetaobject::benchBackgroundThread(invokeMethod_string)
RESULT : qtimer_vs_qmetaobject::benchBackgroundThread():"invokeMethod_string":
     7.05 msecs per iteration (total: 706, iterations: 100)
PASS   : qtimer_vs_qmetaobject::benchBackgroundThread(invokeMethod_pmf)
RESULT : qtimer_vs_qmetaobject::benchBackgroundThread():"invokeMethod_pmf":
     6.70 msecs per iteration (total: 670, iterations: 100)
PASS   : qtimer_vs_qmetaobject::benchBackgroundThread(invokeMethod_functor)
RESULT : qtimer_vs_qmetaobject::benchBackgroundThread():"invokeMethod_functor":
     6.58 msecs per iteration (total: 658, iterations: 100)
PASS   : qtimer_vs_qmetaobject::cleanupTestCase()
Totals: 16 passed, 0 failed, 0 skipped, 0 blacklisted, 20977ms
********* Finished testing of qtimer_vs_qmetaobject *********

Without the change to qtimer.cpp, the results are:

********* Start testing of qtimer_vs_qmetaobject *********
Config: Using QtTest library 5.14.0, Qt 5.14.0 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 8.2.1 20181127)
PASS   : qtimer_vs_qmetaobject::initTestCase()
PASS   : qtimer_vs_qmetaobject::bench(singleShot_slot)
RESULT : qtimer_vs_qmetaobject::bench():"singleShot_slot":
     7.45 msecs per iteration (total: 745, iterations: 100)
PASS   : qtimer_vs_qmetaobject::bench(singleShot_pmf)
RESULT : qtimer_vs_qmetaobject::bench():"singleShot_pmf":
     112.84 msecs per iteration (total: 11,285, iterations: 100)
PASS   : qtimer_vs_qmetaobject::bench(singleShot_functor)
RESULT : qtimer_vs_qmetaobject::bench():"singleShot_functor":
     115.62 msecs per iteration (total: 11,563, iterations: 100)
PASS   : qtimer_vs_qmetaobject::bench(singleShot_functor_noctx)
RESULT : qtimer_vs_qmetaobject::bench():"singleShot_functor_noctx":
     110.81 msecs per iteration (total: 11,082, iterations: 100)
PASS   : qtimer_vs_qmetaobject::bench(invokeMethod_string)
RESULT : qtimer_vs_qmetaobject::bench():"invokeMethod_string":
     7.04 msecs per iteration (total: 704, iterations: 100)
PASS   : qtimer_vs_qmetaobject::bench(invokeMethod_pmf)
RESULT : qtimer_vs_qmetaobject::bench():"invokeMethod_pmf":
     6.62 msecs per iteration (total: 662, iterations: 100)
PASS   : qtimer_vs_qmetaobject::bench(invokeMethod_functor)
RESULT : qtimer_vs_qmetaobject::bench():"invokeMethod_functor":
     6.62 msecs per iteration (total: 662, iterations: 100)
PASS   : qtimer_vs_qmetaobject::benchBackgroundThread(singleShot_slot)
RESULT : qtimer_vs_qmetaobject::benchBackgroundThread():"singleShot_slot":
     7.45 msecs per iteration (total: 746, iterations: 100)
PASS   : qtimer_vs_qmetaobject::benchBackgroundThread(singleShot_pmf)
RESULT : qtimer_vs_qmetaobject::benchBackgroundThread():"singleShot_pmf":
     118.42 msecs per iteration (total: 11,842, iterations: 100)
PASS   : qtimer_vs_qmetaobject::benchBackgroundThread(singleShot_functor)
RESULT : qtimer_vs_qmetaobject::benchBackgroundThread():"singleShot_functor":
     119.35 msecs per iteration (total: 11,936, iterations: 100)
PASS   : qtimer_vs_qmetaobject::benchBackgroundThread(singleShot_functor_noctx)
RESULT : qtimer_vs_qmetaobject::benchBackgroundThread():"singleShot_functor_noctx":
     130.96 msecs per iteration (total: 13,096, iterations: 100)
PASS   : qtimer_vs_qmetaobject::benchBackgroundThread(invokeMethod_string)
RESULT : qtimer_vs_qmetaobject::benchBackgroundThread():"invokeMethod_string":
     8.08 msecs per iteration (total: 808, iterations: 100)
PASS   : qtimer_vs_qmetaobject::benchBackgroundThread(invokeMethod_pmf)
RESULT : qtimer_vs_qmetaobject::benchBackgroundThread():"invokeMethod_pmf":
     6.79 msecs per iteration (total: 680, iterations: 100)
PASS   : qtimer_vs_qmetaobject::benchBackgroundThread(invokeMethod_functor)
RESULT : qtimer_vs_qmetaobject::benchBackgroundThread():"invokeMethod_functor":
     7.49 msecs per iteration (total: 749, iterations: 100)
PASS   : qtimer_vs_qmetaobject::cleanupTestCase()
Totals: 16 passed, 0 failed, 0 skipped, 0 blacklisted, 153995ms
********* Finished testing of qtimer_vs_qmetaobject *********

Additionally, this patch adds a unit test to verify that the slot call
order for 0ms single shot timers is followed while mixing the various
API versions. It fails without this patch but passes now.

Finally, another test is added to verify that using QTimer::singleShot
before a QCoreApplication was constructed is still working properly.

Change-Id: I0d6211554b6198cb3e527be9ec3adc572b1b54ee
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2019-04-06 21:16:56 +00:00
Samuel Gaist
946d868619 QEasyingCurve: fix data stream operators
Until now, QEasingCurve was not streaming all it's internal state.
Therefore, doing store/reload operation through QDataStream would not
yield the same curve as the original. This patch fixes it.

[ChangeLog][QtCore][QEasingCurve] QEasingCurve now properly streams all
the data needed to QDataStream.

Change-Id: I1619501f5b4237983c8c68e148745a5e58863f55
Fixes: QTBUG-68181
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2019-04-06 21:12:40 +00:00