Commit Graph

48700 Commits

Author SHA1 Message Date
Morten Johan Sørvig
210128cc0e QHighDpi: revert window-on-multiple-screens handling
Make fromNativePixels() use QWindow:screen() for determining
which screen's scale factor to use, even if the point-to-be-scaled
is on a different screen.

We'll add API for handling the window-on-multiple-screens
case in subsequent commits.

Task-number: QTBUG-81695
Change-Id: Ib9f40a5a636b2487204c14301ad0190727dcf4ac
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-10-20 07:26:00 +02:00
Giuseppe D'Angelo
85ed79e591 QFileSystemWatcher: use nullptr, instead of 0
I'm not sure why this hasn't been flagged so far, probably
we don't have this warning enabled on MSVC.

Task-number: QTBUG-87713
Change-Id: I97c65079c8f8e439645ff7fe75eede9b01b26166
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-10-20 01:25:38 +02:00
Giuseppe D'Angelo
b60c39fe65 QThread::create: mark as [[nodiscard]]
Also mark the helper function.

Change-Id: I1469abf22cd132dbb1afe680121b6c928ffbe41e
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-10-20 01:25:31 +02:00
Ulf Hermann
2d0a5f7a01 QAssociativeIterable: Unwrap variants on value()
Fixes: QTBUG-87688
Change-Id: I66515eaa1217c34f003648af6423b318b54977c4
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-10-19 22:12:12 +02:00
Ulf Hermann
45c248a011 QAssociativeIterable: Add methods to add/remove keys and values
This way we can actually modify the container. Previously the interface
was rather useless.

Change-Id: I278aae46999862ada115c9066a010d7de5cde4ff
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-10-19 22:12:04 +02:00
Ulf Hermann
37c7ef4f4a QMetaContainer: Consistently coerce types
The high-level iterable interfaces should coerce the types of most
QVariants passed to the expected ones. To do this, move the type
coercion code into qvariant.{h|cpp} so that it is available to the
QVariantRef specializations.

The exception are variants passed to the find() functions of associative
iterables. Here, we should not coerce values we cannot convert to the
default-constructed keys. Instead we return end() in such cases.

Fixes: QTBUG-87687
Change-Id: I0bd4e5c4e4e270dd3bf36cb3fb115794828077f2
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-10-19 22:11:50 +02:00
Fabian Kosmale
52083e4da5 QRhiBackendCommandList: avoid new[]/delete mismatch
Change-Id: Iac2645ebd1d42753817078f194ba61520f5f70c9
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2020-10-19 18:03:18 +02:00
Edward Welbourne
4f9ed76709 QLocale: do the inlining in the class body to save repetition
It also makes it easier to find the definition when looking at the declaration.

Change-Id: Idae18d3881f3cf8ba6c6c7e48201ec925815013e
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-10-19 17:46:00 +02:00
Edward Welbourne
488584c944 Refine QLocale constructor documentation
Clarify that the "minus sign" is a plain ASCII U+002D dash, not U+2212
minus sign; and, for symmetry, that the underscore is U+005F.

Change-Id: I7250959d36e56f960dac24a739a1a8826a6bc578
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2020-10-19 17:45:39 +02:00
Edward Welbourne
5a948dd50b Fix [[nodiscard]] compile errors in QLocale benchmark
QString::toUpper() now insists we use its return, so the benchmark
won't compile unless we do so. Also document the helper macro used by
the tests, to explain why it's even there at all.

Change-Id: I830f121d92867bcd09277ecdeb1c764413b34fa6
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2020-10-19 17:45:30 +02:00
Edward Welbourne
55e16b25f5 Fix QLocale's findLocaleDataById(): skip likely sub-tag look-up
It was always called in pairs, first with likely sub-tags added, then
with the base that started from. So doing a likely sub-tag lookup
inside the function was redundant for the former while making the
latter redundant - and it's needed.

Task-number: QTBUG-84669
Pick-to: 5.15
Change-Id: I18bf1d4976a51d9436efd20d1a84a36cfc60f618
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-19 17:45:12 +02:00
Edward Welbourne
78b58d4de1 Tidy up tst_QLocale::ctor(), reduce needless repetition
The test macro's first three parameters were given a QLocale:: prefix
by the macro, but the last three weren't. Save uses of the macro the
need to repeat the prefix in all parameters, thereby making the test
cases easier to read. Also, we can compare enum values, rather than
casting them to int; and, when a test fails, reporting the enum name
is far more informative than reporting the integer that represents it.

Change-Id: Ib0360c51049333b4a00ea84e271c99db6724334f
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-10-19 17:44:43 +02:00
Edward Welbourne
f2cd9d9ddb Fix blatant typo in QTimeZone test
This revealed that the test was always broken; it had simply never
actually been checked.

Done-with: Andreas Buhr <andreas.buhr@qt.io>
Change-Id: I85ac7ba30738fa3b41bf8440a059ee3fabb4726b
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
2020-10-19 17:44:32 +02:00
Edward Welbourne
68bfab534e Use unchecked substring methods in date-time code
Change-Id: I38b9aaa0335c6168706c2508ed1117fd908e679c
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
2020-10-19 17:44:23 +02:00
Edward Welbourne
229c9736bb Check time-text is long enough while checking for its colons
Added some tests that trigger an assert without this check.
(Drive-by: renamed one QTime test to match its QDate(Time)? counterparts.)

Change-Id: I3d6767605fdcca13a9b4d43a32904f584eb57cf9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
2020-10-19 17:44:05 +02:00
Edward Welbourne
9d2a107da2 Remove vacuous tst_QLocale::cleanupTestCase()
Change-Id: I8bf9915045dce434f19de9c3745e1be28a833e8f
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-10-19 17:42:13 +02:00
Giuseppe D'Angelo
4139afafac QFontDatabase: fix a uint->int implicit conversion
Just use an int, as it'll be converted to that anyhow for insertion.

Change-Id: Ie5a9d35a7c10e38cbba49d8915602f9207b8e0ac
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-10-19 16:51:33 +02:00
Giuseppe D'Angelo
8ff197cd11 QPdf: consolidate usage of uint
Objects in QPdf are indexed by uint. In a couple of places
(incl. QFontSubset) int were used instead, causing sign conversion
warnings (turned into errors by -Werror). Use uint instead.

Change-Id: Ie0436c8aff3b67d8ef95a5f26fc16403e7e02bd1
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-10-19 16:51:29 +02:00
Giuseppe D'Angelo
c554f9ef0a QTextTable: fix an implicit uint->int conversion
Make it explicit; didn't investigate why mixed comparisons are
used here.

Change-Id: Idd353c76a65ca1c8c4a158886f64c9cbb321494b
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-10-19 16:51:25 +02:00
Giuseppe D'Angelo
4ea7fbaf00 QList docs: remove some QVector->QList leftovers
Change-Id: I2a7b5ef07ddb07a261110914088b9942801a3c25
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2020-10-19 16:50:11 +02:00
Shawn Rutledge
e4bc148ba2 Remove redundant QPointingDevicePrivate::extra
The inherited QInputDevicePrivate::extra is enough.

Change-Id: I663c63d9b6616ee1f3c312a905a34180a6a038c3
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2020-10-19 16:45:13 +02:00
Alexandru Croitor
4da14d64f1 CMake: Provide add_qt_gui_executable for a short time
Until all repos are updated to use qt_add_executable instead.
This is a minimal addition, instead of the previous
QT_NO_INTERNAL_COMPATIBILITY_FUNCTIONS approach which did not
work in all cases.

Amends c3fee0d984

Task-number: QTBUG-87661
Change-Id: I03bbb1451de8e54be4e075f878ed104c287aa93f
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-10-19 16:41:34 +02:00
Joerg Bornemann
b9bdea3b07 pro2cmake: Fix singleton declaration
The singleton modifier must be written without square brackets.

Task-number: QTBUG-87684
Change-Id: I924bbf97789edd7f2b4f2b9bbca2cb99841d2906
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-19 16:38:48 +02:00
Joerg Bornemann
748b3b9c89 CMake: Fix html_docs targets for top-level builds
Do not append "/qtbase" to QT_BUILD_INTERNALS_RELOCATABLE_INSTALL_PREFIX
when doing a top-level build. The "/qtbase" suffix is already part of
this variable's content.

Fixes: QTBUG-87682
Change-Id: If1c2075dc58d4b07a4c3a1eed12cc3336c5dc8e6
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-19 16:38:39 +02:00
Giuseppe D'Angelo
f87c027931 QVLA: make (last)IndexOf and contains function templates
Just like QList.

[ChangeLog][QtCore][QVarLengthArray] The indexOf, lastIndexOf and contains
methods now take an object of any datatype -- and not just the
array's own value type. This allows for heterogenous lookup in
QVarLengthArray objects.

Change-Id: Ibc55191a140612a4e9be46b4d18457415ea3717f
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-10-19 16:29:49 +02:00
Allan Sandfeld Jensen
28df51caff Add noexcept to d-ptr accessor functions
In theory this could be source incompatible with Q_DECLARE_PRIVATE
on a QSharedDataPointer, but that would both be a misuse, and all places
where something like that could have been used in Qt, Q_DECLARE_PRIVATE
is already manually inlined.

Change-Id: I60bdde3a71646129cef84f31624d0432e7af91ab
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-19 16:29:49 +02:00
Ulf Hermann
91ab8c173d QProperty: Add value() and setValue() to QBindable
This simplifies code that would otherwise need to use the setter and
getter in addition to the bindable.

Change-Id: Iec6510b4f578f5b223c63b3a0719257a0cf2463d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-10-19 16:29:48 +02:00
Eskil Abrahamsen Blomfeldt
05078459de Use valid glyph index for box font engine
Glyph index 0 is reserved for "glyph not found", which can
confuse Harfbuzz. For QFontEngineBox we always return a valid
glyph since it is the fallback font when no other fonts are
available.

Symptom of issue was that we could get to Q_UNREACHABLE for
certain strings when Harfbuzz returned a glyph count of 0.

[ChangeLog][QtGui] Fixed a potential crash when rendering text
with an empty font database.

Fixes: QTBUG-85016
Pick-to: 5.15
Change-Id: Iaf1d003cdff57320bf4327aa8e63dffd9d1da82c
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-10-19 11:52:07 +02:00
Alexandru Croitor
2ffbac7cb2 CMake: Regenerate examples to use qt_add_executable
Task-number: QTBUG-87661
Change-Id: I0dacfdc97a3fb7d88da85b67800f2c1b084d869b
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-10-19 11:51:47 +02:00
Alexandru Croitor
c3fee0d984 CMake: Rename add_qt_gui_executable to qt_add_executable
Also adjust pro2cmake to use the new qt_add_executable name
instead of add_qt_gui_executable.

No compatibility functions provided this time, so we'll need to follow
through all repos and regenerate all examples.

Two reasons for not providing compaitibility functions:
1) We don't intend add_qt_gui_executable to be public API
2) A previous case with qtquickcontrols2 and qttools pointed out that
making top-level builds work with cross-compatibility API is not
simple. So just go ahead and regenerate everything.

Task-number: QTBUG-87661
Change-Id: I2f228827b786ae03bf7e1bf3908ea02a8794ed52
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-10-19 11:51:44 +02:00
Zhang Yu
407e171b40 Fix QFontDialog::selectedFont() does not return actual selected font
"QFontDialog::accepted" was emitted before setting "selectedFont" to current font. So when calling "QFontDialog::selectedFont()" in slot of signal "QFontDialog::accepted",it does not return actual selected font.

Fixes: QTBUG-87483
Pick-to: 5.15
Change-Id: Ic9303e3df73ddd876fc78a0038f9379dbdf1853c
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2020-10-19 14:01:12 +08:00
Giuseppe D'Angelo
aee81c00cf Revert "QRegularExpression: add move constructor(s)"
The QRE classes are not ready for move construction. They would
need to deal with the possibility of a null-dpointer, and they
currently don't; this clashes with the policy of having
moved-from classes in valid-but-unspecified state.

This reverts commit 733ab10961.

Change-Id: I36720dc9d0bf754a980eba373e37abf725cea174
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-19 00:47:19 +02:00
Giuseppe D'Angelo
79917d7965 QRegularExpression: port to QESDP
For QRegularExpressionMatchIterator there is actually one code
path that modifies the object itself. Avoid spurious calls to
detach() in there by making the detach explicit, and streamline
the rest of the code around it.

QRegularExpressionMatch only has a const API so it "doesn't care",
but port it for consistency.

Change-Id: I26881b3af9ae75082dd39462115869b1a9ee1339
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-19 00:47:19 +02:00
Shantanu Tushar
927cd268aa Add function to access QLockFile's file name
This is useful in cases like error handling when you need to print the
name of the lock file.

Change-Id: Ife4901ed53ae81d19e68cce7f1c173ef3745d56f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-18 20:16:38 +02:00
Giuseppe D'Angelo
9402a351dd tst_containerapisymmetry: code tidies
We now require C++17 and thus C++11 features or standard headers
should no longer be conditional.

Change-Id: I6b72306e809f71ec77acf7ffb97e2ed2ccd96e9d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-10-18 19:55:42 +02:00
Giuseppe D'Angelo
c2d250fd1c Use std::void_t instead of the hand-rolled version
Change-Id: Ibcf0e3d32f05b95f5f1996a071a50bc0eba1ae61
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-10-18 19:55:36 +02:00
Kai Koehne
263b29eedb Fix allocated memory of QByteArray returned by QIODevice::readLine
If the maxSize argument is 0 (the default), QIODevice::readLine will
allocate a QByteArray with the size of the next chunk of data, which
may be quite large. Before returning, it then resizes the byte array
to the actual size that was read.

But since change 6b884d2aa1, QByteArray::resize() does no
longer shrink the capacity. This means that the returned QByteArray
keeps it's maximum size as allocated memory. This can lead to
excessive memory consumption, especially if the returned QByteArray's
are stored for further processing in the client code.

Fix this by explicitly calling QByteArray::squeeze() before returning.

[ChangeLog][QtCore][QIODevice] Fixes a regression in Qt 5.15 causing
QByteArray's that are returned by QIODevice::readLine() to
consume large amounts of memory.

Fixes: QTBUG-87010
Pick-to: 5.15
Change-Id: I1f95fc4098849e900680fc945238bfeda881022c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-18 17:46:14 +00:00
Thiago Macieira
0096562299 QRandomGenerator: optimize for the common use case
The most common uses of QRandomGenerator are getting 32- and 64-bit
quantities, either through the generate() and generate64() functions or
by ones that call those, like bounded() or generateDouble(). So optimize
for those with the same entry point by returning one 64-bit value from
the _fillRange() function. Further optimize by not requiring a buffer
for those two cases, which required us to replace the (begin, end)
parameters with (begin, count).

Change-Id: I3eb349b832c14610895efffd16356859eecd5397
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-10-18 10:45:29 -07:00
Ulf Hermann
d0c4d18b01 Core: Make the metacontainer interfaces constexpr
Change-Id: Ib8e486a855673b191a9854e1c4d62614a2b87e72
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-10-18 18:50:50 +02:00
Giuseppe D'Angelo
2a1b44f57b Remove QByteArrayList_indexOf
It was used as exported symbol for the implementation of
QByteArrayList::indexOf. Since then, the implementation has
been changed, and this code is unused.

Change-Id: I468d05507b6b520cf5bfa4bc567a3d67c43b9a32
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-10-18 18:38:02 +02:00
Volker Hilsheimer
d1785f73db Swallow some runtime warnings from tst_qapplication
Change-Id: I226c3b55a1666eb3ccd369a3307919d4c72a2600
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-10-18 17:00:34 +02:00
Volker Hilsheimer
87f29754ec Fix compile warning from testing deprecated signal
Silence the warning, and test event delivery in addition.

Change-Id: I59c49a2ac70ecd32429116b76643700a7ad5ce3e
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-10-18 17:00:24 +02:00
Giuseppe D'Angelo
f1408d9966 QColorSpace: port to QESDP
Replace the hand-rolled refcount management with QESDP.
Since the class has a default-constructed / moved-from state
where the d-pointer can be nullptr, add a in-class detach() that
ensures a private object.

Change-Id: Id81431fa60132dbc0eed45bb60b38d4f7d73833f
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2020-10-18 14:02:32 +02:00
Ulf Hermann
9ceedd5863 Make most of QMetaTypeInterface constexpr
The only thing we need to modify at runtime is the typeId and that can
be mutable. This way we can have a constexpr ctor for QMetaType which
hopefully makes the importing and exporting of related symbols less
fickle.

On Windows we cannot make QMetaTypeForType constexpr as that leads to
mysterious errors in other places. Until we figure out why that is, we
just leave this class as non-constexpr.

This reveals that qcoreapplication.h and qvariant.h are using QDebug
without including it. We now get template instantiation errors. Include
qdebug.h to avoid that.

Change-Id: If1bf0437ada52459c59c6fa45bab3d22dfb0bc92
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-10-18 13:48:16 +02:00
Ulf Hermann
0b0acce5a7 Cbor: Export the datastream operators for QCborSimpleType
Otherwise they are not available to the tests. This is exposed by making
the metatype interfaces constexpr.

Change-Id: I1b3214f339985f2f8ffaf0640cf51e41e92198d0
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-10-18 13:48:07 +02:00
Tor Arne Vestbø
40e6fe7801 doc: Update and flesh out native interface docs
The namespace and overviews are in the qtdoc repository.

Docs for individual interfaces should live with their platform.

Change-Id: Iba5fd7e9ebc4f1f634ec9dc3ec125ce88a1312ba
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2020-10-18 13:31:09 +02:00
Fabian Kosmale
1f66d914e4 QMutableEventPoint::detach: deref old private
After detaching, the current QMutableEventPoint obviously doesn't
reference old QMutableEventPointPrivate anymore. Deref it, so that we
do not leak memory.

Change-Id: I3b59667603d41f452eead9a2db13e1d005f622ec
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2020-10-18 10:42:48 +02:00
Joerg Bornemann
73f9c514dc CMake: Ignore license-related configure arguments
Do not print warnings for the configure arguments -commercial,
-opensource and -confirm-license. We're not removing the arguments yet
to keep existing build scripts working.

Fixes: QTBUG-86096
Change-Id: Ieb63e2f2b81c022e8559cde6c3e0be0b8ce655ca
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-17 23:27:31 +02:00
Tor Arne Vestbø
d6ff54a1ae doc: Make QtGui docs depend on platform integration docs
Change-Id: I72cad7f399219d448d78763c50369f087e9d0cf7
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2020-10-17 23:27:02 +02:00
Volker Hilsheimer
0d9934d4bc Consistenly deprecate QMultiMap insert, add moving unite overload
Change-Id: I8d1d30f3962b0444c27591bf45b6b3c538172039
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2020-10-17 17:34:52 +00:00