Commit Graph

35937 Commits

Author SHA1 Message Date
Allan Sandfeld Jensen
ff776a3059 Whitespace cleanup in corelib/global
Change-Id: I087d7d949cfd43e48e8a008621a4eeaa9d104ceb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-21 21:15:17 +02:00
Tor Arne Vestbø
33617c03a4 cmake: Sync FbSupport module name with pro file
Change-Id: I5374618a34811d516eb8fd12c1429b851fd108c4
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-21 17:56:48 +02:00
Edward Welbourne
e69b81101c Fix locale look-up when language is unspecified
Looking up a locale with unspecified language got the C locale, due to
taking a short-cut that would make sense if no locale were found for a
specified language. Stop assuming the language was specified.

Task-number: QTBUG-74287
Pick-to: 5.15 5.12
Change-Id: I8b3c232da584fb187ebb6c190729c377d0083808
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-10-21 17:56:48 +02:00
Helio Chissini de Castro
c67ea659e5 Fix compilation when using -no-mimetype-database
Change-Id: I4f706a26d73f61e4a6022338e0fc0be48627e4a1
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: David Faure <david.faure@kdab.com>
2020-10-21 13:26:20 +00:00
Allan Sandfeld Jensen
f7f1a71ea4 Make QPoint*, QSize*, and QRect* binary operators hidden friends
Moves them to class scope, which will avoid them showing up as
possibilities in error messages for missing operators.

Also consolidates how they are compared, so QRectF and QSizeF act
similar to QPointF.

Change-Id: I1e12cb7e5a5c65e85c32281878da03c6136c17de
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-10-21 10:52:39 +00:00
Stanislav Yelenskiy
b39b018f4a QTabBar: update index of last visible tab in insertTab
Index of the last visible tab was not updated, if a new tab was inserted
after the current tab and before the last tab.

When the new tab is inserted before the last visible tab, the index of
the last tab increments by one.
When the new tab is inserted after the last visible tab, then the newly
inserted tab becomes the last visible.

Fixes: QTBUG-86898
Change-Id: I2f4b7f705261ec35a5aa7b883ecdddba25f007b7
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-10-21 07:19:36 +00:00
Piotr Mikolajczyk
a02ea26b46 [Android] Make sure expose events are emitted after window resize
Expose event would not be sent when window was resized

Fixes: QTBUG-69155
Pick-to: 5.15
Change-Id: I81bf2d54f830a0dabf15398e1f25b55ff7ff4479
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Reviewed-by: Heikki Halmet <heikki.halmet@qt.io>
2020-10-21 07:08:54 +00:00
Allan Sandfeld Jensen
1be271713e Whitespace cleanup in corelib/ mimetypes, plugin and thread
Done with selective application of clang-format

Change-Id: Iee6bf2426de81356b6d480629ba972f980b6d93d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-21 08:53:38 +02:00
Jan Grulich
3e09ac369d OpenFile portal: use "writable" option to specify our FD is writable
When using OpenFile portal and passing a file descriptor, we open the
file with qt_safe_open() which by defaults make the file descriptor
writable. However we didn't specify in options that the FD is writable
which leads into rejection on xdg-desktop-portal side as there is a
mismatch between writable FD and read-only request.

Pick-to: 5.15
Change-Id: I7a430339a9615f0a054e777e0f3de56e219d1706
Reviewed-by: Aleix Pol Gonzalez <aleixpol@kde.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-21 08:38:15 +02:00
Jan Arve Sæther
2a5afb88db Do not crash if QPA plugin does not support cursors
This was the case on Android, and caused a crash

Fixes: QTBUG-83916
Pick-to: 5.15
Change-Id: Iabc17237498091d815241730a2b14ece5a45d0b9
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2020-10-21 08:37:15 +02:00
Allan Sandfeld Jensen
05685708b7 Whitespace cleanup in corelib/tools
Change-Id: Ibe796c398a8e5488b7203abb07aa54740744f1ab
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-21 08:26:38 +02:00
Shawn Rutledge
9aba868571 QEvent copy constructor: copy the type flags too
Failure to copy m_inputEvent and m_pointerEvent actually left them
uninitialized, and resulted in random behavior in Qt Quick when
Flickable clones a pointer event for later replay.

Remove the comment about copying events being a "bad idea" in Qt 4,
while we're at it.  Copying became more common in Qt 5, and we
probably won't be able to stop doing it now.

Change-Id: I40b6ba5ad696e7aaafbeefbca86eca00cab40616
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-21 08:22:36 +02:00
Thiago Macieira
21d3916817 QRandomGenerator: add 64-bit bounded() versions
Unlike the 32-bit version, we can't go to a bigger integer type to do
the multiplication with. So instead accept looping. Both libstdc++ and
libc++ implement std::uniform_int_distribution this way anyway, but in a
far more complex way.

There is no looping if the "highest" is a power of two. The worst-case
scenario is when "highest" is one past a power of two (like 65). In that
case, we'll loop until the number is in range. Since all bits have equal
probability of being zero or one, there's a 50-50 chance that the most
significant useful bit will be set[*], in which case we'll need to loop
and we again get the same probability. So on average, we only need two
iterations to get an acceptable result.

[*] There's also a possibility that the other bits are such that the
number is still in range. For 65, we'd need the other 5 bits to be zero
(64 is a valid result), but the probability of that is only 1/2^5 =
3.125%. The bigger "highest" is, the closer we get to zero, so
approximate by saying that never happens and instead calculate that the
most significant useful bit is the controlling one.

[ChangeLog][QtCore][QRandomGenerator] Added 64-bit versions of the
bounded() functions. They are useful in conjunction with Qt 6's 64-bit
container sizes, so code that used to call bounded(list.size()) in Qt 5
will continue to compile and work in Qt 6.

Fixes: QTBUG-86318
Change-Id: I3eb349b832c14610895efffd16356927fe78fd02
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-10-20 22:45:06 -07:00
Volker Hilsheimer
74bf2cd21d Fix compiler warning from uninitialized members
When building tst_qmetatype.cpp, clang generates the warning that

class 'AlignmentDummy' does not declare any constructor to initialize
its non-modifiable members

Turn the class into a struct, which doesn't generate such warnings.

Change-Id: I61013a10418238a11824b18ff1e927bbafa46ec2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-21 07:43:51 +02:00
Volker Hilsheimer
43738cfdaf Fix qdoc warnings from QMutex and QMutexLocker
Change-Id: I25faab16ad2df3682e6c6b55d4aaff1c20402995
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-21 07:31:26 +02:00
Volker Hilsheimer
58060e7b6b Fix qdoc warnings in QtDBus
And remove the limitation to 8 types from the documentation.

Change-Id: I92c67368e53d69fd851886c621f3f894f638bae9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-21 07:31:26 +02:00
Allan Sandfeld Jensen
b6cd3bca28 Whitespace cleanup in corelib/io
Selective application of clang-format to follow our coding style where
it is significantly off.

Change-Id: I0ff4ed146fe53922691d5473d0c236f31d478a04
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-10-20 21:09:00 +02:00
Volker Hilsheimer
f1af51fd81 Add forwarding headers for classes moved from QtWidgets to QtGui
The

QT_BEGIN_NAMESPACE
QT_END_NAMESPACE

block is added to avoid warnings from the build system's sanity
check.

As a drive-by, fix the include guards in the QtGui/QActionGroup header.

Change-Id: Ie10e7830c3b00a3548123f58498def49b194c7aa
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-10-20 19:27:04 +02:00
Andrei Golubev
301ed73487 Convert QList alias definitions to 'using'
Modern syntax for type aliases looks much nicer and is easier to read.
Additionally, QDoc is able to generate better documentation for 'using'
based aliases. Also, aliases are simplified for QDoc

Task-number: QTBUG-86553
Change-Id: I44932fbd94f32c1463eafedd1b48c1e840b697e3
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-20 19:22:16 +02:00
Andrei Golubev
bf73495a66 Fix QDoc warnings for QList/QVector
Task-number: QTBUG-86553
Change-Id: Iac944c78640bfcfb6ee137c0ef3dd89387700b4c
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2020-10-20 19:22:12 +02:00
Friedemann Kleint
8ba59441fc Windows QPA/WmPointer: Register tablet devices of pointer handler
Task-number: QTBUG-46412
Change-Id: Ib9b5fd6056a5474ce46c7bde53be7a12c1494611
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2020-10-20 19:21:50 +02:00
Friedemann Kleint
abb5f0d376 Windows QPA/wintab: Register tablet devices
Inherit a class from QPointingDevice with a shared pointer
to the data for a physical cursor.

As a drive-by, keep the event time in QWindowsTabletSupport
for leave proximity events that do not have a time associated.
The previous code was relying on QWindowSystemInterface for
this, which may be at odds with the tablet's time.

Refactor and streamline the code a bit.

Task-number: QTBUG-46412
Change-Id: I2f4fab25a49a9d9f1befbd7fc040e8eb23be71ff
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2020-10-20 17:21:18 +00:00
Allan Sandfeld Jensen
e8873003f0 Fix crash in tst_QSystemTrayIcon::lastWindowClosed()
Handle null QIcons. Note this was already fixed in 5.15 separately,
see 6c8adfaf5d.

Fixes: QTBUG-87729
Change-Id: Ia759fbe95fafcea9451d393dc1aa077f5651919b
Reviewed-by: Liang Qi <liang.qi@qt.io>
2020-10-20 16:45:15 +00:00
Tor Arne Vestbø
bb71abdfbd QWindowsXPStyle: Remove unused variables
Change-Id: Ide3880114bf8d779571b7cf1235ae95524950e5d
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2020-10-20 15:12:44 +00:00
Tor Arne Vestbø
4ad464461f Fix linking of non-console application on mingw
As a result of b5af140809 the link dependency to the
mingw32 static library was ordered after the entrypoint
library, which resulted in the WinMain symbol not being
found during linking due to how the static linker processes
archives.

Fixes: QTBUG-87725
Change-Id: I8e075f91f7f06dcdc618a4e0ae6d9c1d832888c0
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-20 17:12:44 +02:00
Werner Lemberg
0948846b42 CVE-2020-15999: Heap buffer overflow in freetype
Manual cherry-pick of fix in freetype:
Fix heap buffer overflow (#59308).

This is CVE-2020-15999.

* src/sfnt/pngshim.c (Load_SBit_Png): Test bitmap size earlier.

Pick-to: 5.15 5.12.10
Change-Id: I23824074f134802b3e4f737877d144b59e6b8151
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2020-10-20 10:43:10 +00:00
Edward Welbourne
5e43997a70 Use qmetaobject_p.h's MetaObjectFlag in QMetaObjectBuilder
This saves duplicating them with its own flags.

Task-number: QTBUG-85700
Change-Id: I9e938322fd787282cfd9f941f83af8c0d76aaa9d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-10-20 12:03:44 +02:00
Edward Welbourne
83cae7c9e3 Drop constexpr from QAtomicTraits::isLockFree()
As requested by a ### Qt 6 comment. This then implied a few other
functions weren't constexpr, which broke some tests.

Task-number: QTBUG-85700
Change-Id: I6522a9b2d7a74e117442121400a1d7198d323967
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-20 10:49:30 +02:00
Giuseppe D'Angelo
141fae112a QList::removeOne: make it generic as well
Change-Id: I0c50b2ae76f9d0f053b3d5b1ab98d12e0524e419
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-20 09:32:24 +02:00
Giuseppe D'Angelo
3c74ba1f8b QList::removeAll: make it generic
This is a bit more tricky than expected because we support passing
references to objects that are into the list itself (for instance,
list.removeAll(list.front())). For those objects we have to take
copies. This is fine, but the moment we make the function generic,
that's going to fail when passing arguments of types that cannot
be copied, such as arrays (e.g. stringList.removeAll("hello")).
For those, keep a reference, as they cannot be aliases into the
list anyhow.

[ChangeLog][QtCore][QList] The removeAll and removeOne methods
now take an object of any datatype -- and not just the
list's own value type. This allows for heterogenous removal inside
QLists.

Change-Id: I0c447770bbc7ff0ff4bb4c0e35081414c5ff963e
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-20 09:32:22 +02:00
Shawn Rutledge
5683c0afda Add QSinglePointEvent::exclusivePointGrabber convenience property
Since a single-point event (such as a QMouseEvent) only carries one
point, it only has one grabber, so we can have a normal Q_PROPERTY.

It's named exclusivePointGrabber to avoid shadowing the
QPointerEvent::[set]exclusiveGrabber functions that take QEventPoint&.

Change-Id: Ie18f1c1849ed057b98f229de7b17b7fc3f3eea36
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-10-20 09:17:35 +02:00
Eskil Abrahamsen Blomfeldt
dc6c263667 Fix output with box font engine
The box font engine was passing in alpha values in the blue
channel instead of alpha channel to QImage::setPixel(), probably
assuming that setPixel() accepts the input in the format of the
QImage. But the whole point of setPixel() is that it converts
the input. If we just want to set the alpha value, we can do
it directly on the QImage::bits().

[ChangeLog][Text] Fixed showing boxes for glyphs when there are
no fonts available in the font database.

Pick-to: 5.15
Change-Id: I7ae067c26b9ecba6aaa046e7e4b9ae520c4b3d23
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2020-10-20 07:40:12 +02:00
Morten Johan Sørvig
ed43f89f8d Update QHighDpiScaling internal documentation
Document new conversion functions and how the new
public API (rounding) effects QHighDpiScaling operation.

Change-Id: I801fc065cdb4904811a009510b08cac630b83fe7
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-10-20 07:27:10 +02:00
Morten Johan Sørvig
f4a66e5c4c QPA offscreen: make platform plugin configurable
Add ability to load a json config file containing screen
configuration at startup. The config file location
is specified using platform options:

    -platform offscfreen:configfile=/path/to/file

Config file format example:
{
    “screens”: [
        {
        "name", "screen-1",
        "x", 0,
        "y", 0,
        "width", 640,
        "height", 480,
        "dpi", 96,
        "dpr", 1,
        },
        …
    ]
}

Change-Id: Iac21aaafa6d0f361bdd6f6e9168b7e68db6ae011
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2020-10-20 07:26:46 +02:00
Morten Johan Sørvig
0ab89881c5 high-dpi: Re-implement mapToGlobal and mapFromGlobal
(This code is required to handle corner cases such as a QWindow
covering multiple screens, where the normal code path does not
give correct results.)

Move the map[to|from]Global implementation from qhighdpiscaling.cpp,
and implement it in terms of [to|from]NativeGlobalPosition. These
functions implement the required screenAt()-type searching.

The implementation strategy for both mapping functions is to first
map to the native coordinate system, perform the globalPos addition
or subtraction, and then map the result back to device independent
coordinates.

Task-number: QTBUG-81695
Change-Id: I44e9e68651634650964e839b1e564b50f434553f
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2020-10-20 07:26:38 +02:00
Morten Johan Sørvig
e8fabb2946 high-dpi: Set screen on QWindow::setGeometry()
Keep (requested) geometry and screen in sync, which
is required for correct high-dpi scaling. The platform
plugin can still override with new geometry (and screen),
as usual.

This has previously been fixed/worked around for QDialog,
see QTBUG-52735. That fix can now be removed in favor
of this change in QWindow.

Change-Id: Ieadb1bfee5fb966c5c2052e9daa5ba124a87f3cd
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2020-10-20 07:26:31 +02:00
Morten Johan Sørvig
95bce5b185 QHighDpi: window geometry scaling functions
Add functions which scales window geometry:

	framNativeWindowGeometry()
	toNativeWindowGeometry()

These correctly handles top-level and child windows,
where top-level window positions scale around the screen
origin while child window positions scale around (0, 0).

Modify call cites to use the new functions. We no longer
need the isTopLevel checks at the call site.

Change-Id: I0158672d46a3f52dfc7d37d021fc5cebd7859200
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2020-10-20 07:26:24 +02:00
Morten Johan Sørvig
73a93981ca QHighDpi: global geometry scaling functions
Add functions for scaling global coordinates:
	toNativeGlobalPosition()
	fromNativeGlobalPosition()

These correctly handle the cases where a window spans several
screens.

Change-Id: I268762499cd8d86a3c417342ddaf2fb6dab4dd20
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2020-10-20 07:26:17 +02:00
Morten Johan Sørvig
b8f5ed0d5a QHighDpi: Add screenForPosition()
Implement support for using the screen at a given position
when determining the scale factor and origin.

Add QHighDpiScaling::screenForPosition(), which searches
for a screen at the specified device independent or native
coordinates. The function returns the QScreen or nullptr
if no screen was found.

Add QHighDpiScaling::Point, used for representing
an invalid, device independent, or native point.

Change-Id: I58e4e3eebb8cdd5171e59f97833a00e7f8d9ecd6
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2020-10-20 05:26:08 +00:00
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
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
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
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
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
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
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
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
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
Fabian Kosmale
f660fedcab qcontainerinfo: make variable templates inline
Change-Id: I09d51f0a04a6dc12915ba6ad0b77af074238988d
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-10-17 16:40:20 +02:00
Ulf Hermann
c800e96523 qtypeinfo.h: We only need a const reference for most operator<<
If we require a value, then we need a dtor, too. This is not always the
case. For example QSessionManager has a private dtor, leading to
failures.

Change-Id: I3f715848ff5c63b2ea2773c17bced21e7a814ca9
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-10-17 12:15:44 +02:00
Cristian Adam
5216c56110 MinGW: Fix static direct2d plugin build using PCH
Ammends 27499d25fb

The value used to create the PCHs for _WIN32_WINNT is 0x601, and
qwindowspointerhandler.cpp requires for MinGW 0x603. Since the
precompile header value cannot be undefined while compiling the
source file, it's better not to use the PCH for this particular
source file.

Change-Id: I2dc10fa11f0a796c2d21d8880e32e911359f1602
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-17 12:13:11 +02:00
Cristian Adam
113f1ad324 CMake: Generate qrc files at configure time and make them traceable
Having the qrc files at configure time allows qmlimportscanner to
scan them when invoked with -qrcFiles argument.

The traceability part is done via _qt_generated_qrc_files property.

Task-number: QTBUG-85994
Change-Id: I75c252a987cd1c1f49ba73ec9d100edc73c23486
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-17 12:13:08 +02:00
Tor Arne Vestbø
b5af140809 Generalize the winmain/qtmain entry-point library
The use-case is relevant for other platforms as well.

Now that Qt has a module system we can also replace a lot of the
hand crafted logic for linking with simpler constructs.

Change-Id: Ib6853aaf81bfea79c31f2de741d65b4b56f23ef6
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-17 12:13:00 +02:00
Lars Knoll
3f477c7f0c Inline the members for QRecursiveMutex
Avoid creating a a d pointer for recursive mutexes.

Change-Id: I28af15a416ee17de346e2ea5b1442279d9d3e159
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-17 12:03:16 +02:00
Lars Knoll
f01ec0713d <chrono> should always be available with C++17
Change-Id: Ia4868259bfa25e4b929a51de6de580df7277c282
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-17 12:03:05 +02:00
Lars Knoll
d4b206b246 Split QMutex and QRecursiveMutex
These classes should not inherit from each other
anymore in Qt 6. The reason is that this makes
the 95% case of using a non-recursive mutex
much slower than it has to be.

This way, QMutex can now inline the fast path
and be pretty much as fast as QBasicMutex is
in Qt 5. They actually use the same code paths
now. The main difference is that QMutex allows
calling tryLock() with a timeout, which that
is not allowed for QBasicMutex.

[ChangeLog][QtCore][QMutex] QMutex does not support
recursive locking anymore. Use QRecursiveMutex for that
purpose. QRecursiveMutex does not inherit QMutex anymore
in Qt 6.

Change-Id: I10f9bab6269a9181a2e9f534fb72ce65bc76d989
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-17 12:02:56 +02:00
Lars Knoll
77d812683f Refactor QMutexLocker to be able to handle recursive mutexes
Since we're going to split QMutex and QRecursiveMutex into
separate classes, make sure QMutexLocker is prepared for that.

Change-Id: Id5e9a955d1db7c8ee663dd3811ad6448dad0aeae
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-10-17 12:02:49 +02:00
MagnaboscoL
f76530a617 Fix the initial cursor state for the VNC plugin
Ensure that we show a cursor directly after a client connects.

Fixes: QTBUG-85006
Pick-to: 5.15
Change-Id: Icb604beb1b0ca2e7efa42ac01c2aac0a3e002865
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2020-10-17 12:02:24 +02:00
Lars Knoll
2732231182 Cleanup remaining QVariant::Type uses in Qt Sql
Change-Id: Ibcaa678cd9f9c957392a75b477fa6821f9a69127
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-10-17 12:01:54 +02:00
Friedemann Kleint
9ed75b6716 QWindowSystemInterface: Add tablet event overloads without timestamps
On some platforms, tablet events do not have a time stamp.

Task-number: QTBUG-46412
Change-Id: I3cc820b1edaaf55511c000fefb805f5a3a7872a6
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2020-10-17 11:56:41 +02:00
David Skoland
4a7280598b Fix Clang compiler warnings (-Wrange-loop-analysis)
In a macOS environment, Clang throws a number of compiler warnings
about loop variables when building qtbase.

See task for more info about the environment.

This changes a handful of loop variables,
like QJsonValue references into QJsonValueRefs.

Task-number: QTBUG-87216
Pick-to: 5.15
Change-Id: I26006efd7c75c2d56ebc7f7efb4c9bdcabe92e8b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-17 11:56:30 +02:00
Volker Hilsheimer
833a6e18bf Implement move and comparison operators for QEventPoint
QEventPoints are equal when all data values are equal, the
refcount is ignored.

Change-Id: I6ef70faf0b12129eaa22bfc1f0a45bab2422d421
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2020-10-17 08:21:52 +02:00
Andy Shaw
a9982e64eb sqlite: Upgrade to 3.33.0
[ChangeLog][QtSQL][sqlite] Upgraded to v3.33.0

Pick-to: 5.15
Pick-to: 5.12
Change-Id: I379d8c62b449d4c6b04e5154c8c1a86761e5466e
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-10-17 08:21:52 +02:00
Giuseppe D'Angelo
32c68232a7 QColorConstants: code tidies
Change-Id: Ib4131a583529d2cd6a6d7d27513cca387cb1d722
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2020-10-17 03:04:42 +02:00
Andreas Buhr
df8489816b Fix compilation with optimization with g++-10.2
When compiling in RelWithDebInfo configuration with g++-10.2,
it complains:
qtbase/src/gui/painting/qdatabuffer_p.h:71:36: error: argument 1 range
[18446744065119617024, 18446744073709551612] exceeds maximum object size
9223372036854775807 [-Werror=alloc-size-larger-than=]
This patch disables this warning in this place.

Pick-to: 5.15
Change-Id: Id3154ce80a1921671031828aaa7144214adad5dd
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2020-10-16 18:49:02 +02:00
Alexandru Croitor
1f9ec097b2 CMake: Rename some public API functions
Some of them have a different (hopefully better) name now.
Some are marked as Technical Preview.
Some are renamed to be internal.

Marking add_qt_gui_executable as TP with the intention to un-TP it
after we rename it and change its behavior as discussed in the API
review meeting.

Additional changes to add_qt_gui_executable and qt6_add_resources have
been filed as separate tasks that will be worked on separately.

See comments on PS1 for details.

Task-number: QTBUG-86827
Change-Id: I56a84a1943b0902bb807310dc620eb381824e8dd
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-10-16 13:53:04 +02:00
Alexandru Croitor
c6b3680bcf CMake: Fix qt_add_plugin to be a proper public API function
When configuring an example like
widgets/tools/plugandpaint/plugins/basictools outside of a Qt build,
the configuration fails because it tries to call the internal function
instead of the public one.

This was needed some time ago to facilitate moving from qt_add_plugin
to qt_internal_add_plugin, so some compatibility code was added.

But we've now migrated to qt_internal_add_plugin across most repos,
so we should remove the compatibility code to allow examples to
configure successfully.

Amends 6fbeef4c6b

Fixes: QTBUG-86858
Change-Id: Ib15f50351a8742c44d7a8be84be4e576cb48bddb
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-10-16 13:53:04 +02:00
Volker Hilsheimer
f772b8e48c Document (some) Qt6 changes for QtWidgets
Change-Id: I8185e7c4d46f77fa80ad351e1e73d53ca30201a6
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2020-10-16 13:53:03 +02:00
Volker Hilsheimer
1d49dad22c Fix warning, make sure temporary is moved into return value
Seen on clang 12; might be a compiler bug, but doesn't hurt
either.

Change-Id: I4aba8406c99951106e57fe9e61c688e649963cd6
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-10-16 13:53:03 +02:00
Volker Hilsheimer
e2b3d42f94 Don't divide by zero when calculating number of items
Amends e74af68654.

If the model has children, then row 0 should have a non-zero size, but
it's not unthinkable that a delegate returns zero for size hint, so
protect against that case.

Task-number: QTBUG-87588
Pick-to: 5.15
Change-Id: Ia396f532d42ce5fad8757d629816c3cdc31d84ed
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
Reviewed-by: Doris Verria <doris.verria@qt.io>
Reviewed-by: Florian Bruhin <qt-project.org@the-compiler.org>
2020-10-16 13:53:03 +02:00
Volker Hilsheimer
0f1008a593 QAbstractItemView: don't lose items if model only allows MoveAction
If a model only allows MoveAction, then calls in the view/widget subclasses'
dropEvent implementation to set the event's drop action to CopyAction
will fail. QAbstractItemView will then remove the item when QDrag::exec
returns.

Instead of abusing the event actions for this, store explicitly that the
dropEvent implementation already moved the item. If the flag is set,
don't remove the item.

In QListView, which uses moveRow to move items in the dropEvent handler,
handle the case that the model might not implement moveRows. In that
case, or when dropping an item onto another item (to overwrite data),
fall back to the default implementation of QAbstractItemView. Sadly, it
is impossible to know whether a model doesn't implement moveRows, or
whether the move failed for other reasons, so this requires a bit of
extra special case handling. QListView in IconMode is particularly odd
in that it moves the item in the view, but not in the model.

This follows up on fd894fd68e and fixes
additional issues discovered during debugging. Extend the existing unit
test; since drag'n'drop runs a modal, native event loop on most systems,
it still only runs on the Xcb platform.

Change-Id: I6c5377e2b097c8080001afe904d6d3e4aed33df4
Pick-to: 5.15
Fixes: QTBUG-87057
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2020-10-16 13:53:03 +02:00
Giuseppe D'Angelo
aa442e9450 Q(E)SDP(V2): fill the API gap left by take()
take() returns a pointer to the shared data object *without*
decrementing the reference counter. The primary use case
is adopting the object from a Q(E)SDP into a different reference
counting mechanism. This is fine, but if we support the
"extraction" part, we shall also support the "adoption" part.
Also, the API for the shared data pointer classes should
match.

Add an adopting tag type and suitable constructors to the
shared data pointer classes, and add take() to the classes
lacking it.

Drive by, apply qExchange to take()'s implementation.

[ChangeLog][QtCore][QAdoptSharedDataTag] New class.
It is now possible to adopt pointers to shared data into
a QExplicitlySharedDataPointer or a QSharedDataPointer object
without incrementing the object's reference counter.

Change-Id: I62b8b005c1bfbe2add58566206fca27634bb7e70
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-16 13:53:03 +02:00
Ulf Hermann
7745b49b2d QMetaType: Silence float comparison warnings in QEqualityOperatorForType
We actually do want to invoke the original equality operator there. If
that is unsafe, we cannot do much about it at this point.

Change-Id: Iadb2eaba1156828d89022d282c41bda57b500b13
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-10-16 13:53:02 +02:00
Ulf Hermann
b3f3ebc2c0 Fix "variable set but unused" in qvariant.cpp
... how did that pass the CI?

Change-Id: I84baaf3632df0410d1fb25f24fd22f65daae13af
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-10-16 13:53:02 +02:00
Allan Sandfeld Jensen
382e3cb00f Add comparison operators to shared data pointers
To avoid they are compared as bools, or ambiguously.

Change-Id: I1495b3126a71c1379e72d4cf53b1a67590eb9f4b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-16 13:53:02 +02:00
Andrei Golubev
59359f6782 Remove redundant duplicate of EnableForNonVoid in QFutureWatcher
qfuturewatcher.h includes qfuture.h, which includes EnableForNonVoid
through qfuture_impl.h header. Thus, there is never a need to keep
the same alias in QFutureWatcher as it always can use one from QFuture

Change-Id: I293fd087aea1a21ef5bcfdf50cdefc176a9703d0
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2020-10-16 09:48:10 +02:00
Andrei Golubev
db3d097db2 Fix subtle SFINAE problem in QPromise::addResult
Accidentally found out that we enable/disable QPromise::addResult based
on type deduced from input argument, instead of using "value_type" of
QPromise itself, which is wrong

Simplified the checks to a single one -
EnableIfSameOrConvertible<InputType, StoredType> as this is sufficient
to account for both cases: QPromise<void> and QPromise<T> with input,
convertible to T

Change-Id: I657998c0e26241b0fc5e70988622984ece8871df
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2020-10-16 09:48:10 +02:00
Andrei Golubev
7332d3937d Rename QPromise starting and finishing methods to start and finish
Proposed during API review

Change-Id: I9c43e1915c50803ab69bfe07a91c05d2224b86c4
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2020-10-16 09:48:10 +02:00
Andrei Golubev
3ca600bd2d Make QPromise::addResult() return boolean status of operation
Changed QPromise::addResult() to return bool value. True is returned
when result is added and false is returned when e.g. promise is in final
state (canceled or finished) or when addResult() is called twice with
the same index as argument (in which case new value is rejected)

Updated QFutureInterface::reportFinished() that accepts optional result
as argument to align with other result adding methods. This function
is "internal" only (as of now), so no documentation update is needed

Change-Id: I2d63069246e5e5c8cf04529c22bb296faaaae53d
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2020-10-16 09:48:10 +02:00
Laszlo Agocs
696d94b132 Guard vulkan.h inclusion with __has_include
...and provide our dummy typedefs when vulkan.h is not available.

Originally this was there for qdoc, but from the qtdeclarative API
review it becomes clear that we need this also when an application
- that includes Qt Quick headers which in turn want to use VkImage
and co. for type safety - is built on a system without vulkan.h
against a Vulkan-enabled Qt build.

Also fix some of the typedefs which were technically incorrect. (not
that it matters much since the dummy typedefs still do not allow
calling exported Qt functions that use the real Vk* types since the
function signatures like won't match in some cases (would need to
replicate too much hocus pocus from vulkan.h for that), but that's fine
since our goal here is to keep application compilation going when it
encounters a Vk* type in a Qt header, not about enabling actually
calling those functions)

Task-number: QTBUG-87450
Change-Id: I855b4478c8707587b28db2408e282145129a0194
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2020-10-16 09:48:09 +02:00
Allan Sandfeld Jensen
ada6e4fbe9 Fix some bad uses of QSharedPointerData::operator T*
Avoid detaching where possible

Change-Id: I438d3e66689aeef05951af86a48af2a6910da7c2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2020-10-16 09:48:09 +02:00
Lars Knoll
b002c48cc7 Disallow promotion of bool and char in qMin and friends
Feedback on the API review. Make sure, qMin<true, 'a'> and similar
constructs don't compile.

Change-Id: I59a66348a4168fe306159ddaf2595838d4ed66d1
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-16 09:48:09 +02:00
Lars Knoll
4097653215 Fix signature of QDebug::toString()
We don't need two overloads here.

Change-Id: Ia6a3bcd93491843e07b0295fefe8da42ae9d6519
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-16 09:48:09 +02:00
Laszlo Agocs
0461c535fc rhi: Further reduce copying in the command buffer
Change-Id: I2e2ff5f4b8aa91d0accb01108a5199b98c371455
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
2020-10-16 09:48:09 +02:00
Laszlo Agocs
802d98d318 rhi: Unroll the res.binding factory functions
Trading typing in a few lines of straightforward code for a full
sizeof(QRhiShaderResourceBinding::Data) copy (with less fortunate
compilers that do not manage to optimize it away) is a bad deal.

Change-Id: If227320f8a9598508c1fe02c4f56e6d75f0a787b
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2020-10-16 09:48:09 +02:00
Timur Pocheptsov
aa6b865899 QSslCertificate (generic) fill the extension's variant map
When parsing subjectAltName extension to make it more like OpenSSL
counterpart.

Fixes: QTBUG-86830
Change-Id: If1a4e72ee0b19f2cf40aa53632f9ec1468178c3b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-10-16 05:21:49 +02:00
Timur Pocheptsov
1ccd99187c Remove misleading comment
NSSegmentedControl is not of much use for us, due to different problems
it shows when rendered.

Change-Id: I57be237b33c226d0a84d18c76a4bffb92cea5274
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-10-16 05:21:43 +02:00
Volker Hilsheimer
4de8eefa80 Remove default parameter from QUnifiedTimer::updateAnimationTimers
After adjustments in Qt Declarative, this parameter is no longer needed.

Change-Id: I4b398748277aa29edd06ac122cfa8984575abf97
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2020-10-16 04:46:07 +02:00
Volker Hilsheimer
56332031a5 Document noteworthy change in QProcess
Change-Id: I4d9769901aef8255fc111f33eb141e05398f0ee3
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-10-16 04:44:29 +02:00
Volker Hilsheimer
215594d664 Purge QDesktopWidget
It's no longer used; the only calls to QApplicationPrivate::desktop
pass the default nullptr for QScreen, so all we need is a Qt::Desktop
type toplevel widget.

Include changes documentation about both the class and QApplication::desktop
being gone in Qt 6.

Change-Id: I22d6e93cabc6aaaefffe5e96942886a2ef4e0609
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-10-16 04:44:13 +02:00
Giuseppe D'Angelo
ef1905aebc QMultiHash: fix operator==
An empty QMultiHash can still have an allocated dpointer, so we
can't desume that two hashes are different because one has a
dpointer and the other doesn't. Compares the sizes first, and
infer that equal size, and non-zero size, mean both have a dpointer.

Fixes: QTBUG-87575
Change-Id: I2e206bd071c02fb8970a4e77f8b0d29ad7e58bbe
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-16 01:08:00 +02:00
Giuseppe D'Angelo
9f1e1eb552 QHash: code tidies
Apply std::exchange. Remove a wrong comment about MultiNode
-- the compiler isn't generating any move operations, the
move constructor is user-provided and there isn't a move
assignment operator...

Change-Id: Idd69458c69cc93e4575c119daba564e0046452c1
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-10-16 01:07:57 +02:00
Giuseppe D'Angelo
9fa848dcaf QOverload helpers: further cleanups
constexpr inline means we can remove [[maybe_unused]].

Change-Id: I034b6e742ef750dc1ebeca1d9cc7a2463f8c7b70
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-10-16 01:07:55 +02:00
Giuseppe D'Angelo
1261f391cc Floating point function helpers: code tidies
Change-Id: Id87390734f4ccb28fb83d25788ca600747c2e2a8
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-10-16 01:07:53 +02:00
Giuseppe D'Angelo
b652f5a703 QtPrivate::Deprecated_t: code tidies
Change-Id: I08ae749b32aa9a302937691c76b7910175c8a71a
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-10-16 01:07:50 +02:00
Giuseppe D'Angelo
bc4bd3c1bc QESDP::take(): document that it doesn't deref
Change-Id: Iba6c1caf4a7681815559db7c06691d02108ae855
Pick-to: 5.15
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2020-10-16 01:07:48 +02:00
Giuseppe D'Angelo
56475926e6 Port QColorTransform to QESDP
Remove the hand-rolled refcount management code, and
cleanup the existing constructors.

Change-Id: I1b91dbf888feff25d67310637d42dcdc3acaac13
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2020-10-16 01:07:45 +02:00
Giuseppe D'Angelo
35c565e965 Port some more /*implicit*/-like comments to Q_IMPLICIT
Change-Id: Ib70ad3f29365153af647deea54fc45467c413cb9
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-10-16 01:07:31 +02:00
Giuseppe D'Angelo
2ded340d55 QTimeZone: drop an implicit conversion comment
The constructor isn't selected for conversions anyhow (it has
more than one argument), and in Qt we don't mark such constructors
as implicit (or explicit) anyways.

Change-Id: I4203b946b9c6934aef9eead2db96154f9851ab9a
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-16 01:07:23 +02:00
Fabian Kosmale
86d2f7f365 QVariant::compare: handle numerical values and pointers as documented
[ChangeLog][QtCore][QVariant] Comparing two QVariants containing
floating point numbers for equality no longer uses fuzzy comparisons.

Change-Id: Iaba40a66d8fa566a432547fa1a30d5ea191c7fc0
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-10-15 21:58:03 +02:00
Alex Trotsenko
53b4556332 QLocalSocket/Win: prevent writing to broken pipe
When a peer closes the connection, the device remains opened for reading
purposes. However, we should disable writing on disconnected socket.
Otherwise, if the user issues a write() call, a new pipe writer object
will be created and the write call occurs with invalid handle value.

Pick-to: 5.15
Change-Id: Id136798c7663df1fce7ed0aa4e3c6f5c65218a11
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2020-10-15 22:56:35 +03:00
Assam Boudjelthia
3d8447de59 Android: fix path issue with backslashes on Windows
The androiddeployqt tool wasn't handling dependencies with backslashes
properly, some dependencies like libplugins_platforms_qtforandroid was
written into libs.xml as
plugins\platforms\libplugins_platforms_qtforandroid_armeabi, the the app
won't be looking for the correct path of the lib to load.

Task-number: QTBUG-87574
Change-Id: Iad8c74d30d090adf69a17f2dafb455dff50b3d99
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2020-10-15 18:37:25 +03:00
Giuseppe D'Angelo
871392790e QOverload helpers: code tidies
Remove pre-C++14 code paths; and mark as `inline` the qOverload
helper objects (constexpr variables at namespace scope aren't
automatically inline).

Change-Id: Ieb2a9f06e39720d0c7215a3d1273c3a5996d0bc7
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-10-15 02:35:55 +02:00
Karsten Heimrich
79889a91a1 Doc: Migration Guide for QString related changes
Task-number: QTBUG-87097
Change-Id: Idcdeaea5a65e91b99a08c2af03c7e76bbe5913bb
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2020-10-15 00:57:50 +02:00
Volker Hilsheimer
2cc8d801aa Unwrap private QPalette data member
Following 556511f9f3, there is only one
data member in addition to the shared QPalettePrivate, so we don't need
a data struct anymore.

Change-Id: I8d7f33ed042e47464eb5f60a048956f8bf70e0b9
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-10-14 23:43:38 +02:00
Laszlo Agocs
63790184c7 rhi: Fix up vertex inputs with matrices
In order to prevent too much voodoo in backends like D3D11, the input
layout is expected to specify the slice index for vecX that are part of
an unrolled matrix.

Also deoptimize the instancing manual test to exercise a matrix too
instead of just vectors.

Change-Id: If2dcbcbc483645ce2420b2f87dda765b95da6e80
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2020-10-14 22:35:19 +02:00
Doris Verria
61dee37d66 Return false from canFetchMore for uninitialized QFileSystem models
Task-number: QTBUG-87273
Pick-to: 5.15
Change-Id: I1787e3dd26ec10cf161d8fa4e329972b6dd4aa6c
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-10-14 21:43:49 +02:00
Doris Verria
b84852670d Fix infinite loop triggered when displaying model with QTreeView
For some models like the QFileSystemModel canFetchMore() returns true even though fetchMore() doesn't return anything if setRootPath is false. To prevent an infinite loop, add a check to make sure the model's rowCount was updated during the loop.

Fixes: QTBUG-87273
Pick-to: 5.15
Change-Id: I16275fc2765fd77badc1c5d265e8ba5cd250163a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2020-10-14 21:43:45 +02:00
Lars Knoll
fa93f1aeb0 Fix compile time type normalization code
Use a simpler constexpr to generate type name on gcc This
works around an ICE on gcc in release mode when compiling
with PCH enabled. As the type we're getting from Q_FUNC_INFO is
already in a somewhat normalized form, this requires significanlty
less processing and esp. not a recursive constexpr method which
I suspect triggers the ICE.

Fix integer type conversions to also properly normalize long long
values (to q(u)longlong. Make sure the mapping also works on
MSVC, where long long types get mapped to __int64. Also, normalize
unsigned short and unsigned char to ushort and uchar, respectively, to
follow the convention set by uint and ulong.

Add some test cases to verify the mappings.

Change-Id: I3dec5764450bf22ab6f066597803c3f46c2cd5ac
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2020-10-14 21:37:39 +02:00
Sona Kurazyan
0599255fcf Simplify implementations of QtConcurrent::blocking* methods
Call non-blocking methods from the blocking ones.

Change-Id: Icf63637223533254b76826340334de35bca258b2
Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
2020-10-14 21:24:31 +02:00
Sona Kurazyan
9ded473914 Minor cleanups based on API review
- Be more more consistent when declaring type aliases.
- Re-group include directives

Change-Id: Ic521e9f7692e538cc98871bdeccd9644c9879089
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
2020-10-14 21:24:26 +02:00
Fabian Kosmale
e1926e5060 QMetaType: fix warning message
Change-Id: I93c8b0d6b490cfed944a2a6a2b64361258a50141
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-10-14 21:10:52 +02:00
Allan Sandfeld Jensen
0e85647ccf General cleanup of qshareddata.h
Update the code to something more modern and make the two types more
consistent.

Change-Id: I524d33fea158e2ba7079fe836164eec03c45649b
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2020-10-14 20:58:52 +02:00
Giuseppe D'Angelo
a095a999a3 Long live Q_IMPLICIT!
C++20 will give us explicit(bool). While we can't use it just yet
in its full potential, we can introduce a macro to start marking
our implicit conversions (aka `explicit(false)`), removing the need
for /* implicit */-like comments.

Port a few usages to it.

Change-Id: I336d5e4c8d51d8329627900d1059e59062c5cafd
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-10-14 20:58:51 +02:00
BogDan Vatra
a8dc2a5b6d Fix Qt6 renaming
Fixes sha: 1907599bfd

Change-Id: I20ece75c321835f13a605ae4d56fee1a034ca7c8
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2020-10-14 21:57:11 +03:00
Shawn Rutledge
b0cd3bcec4 Use QScroller in the Dir View example
We have never had enough examples that show how easy it is to install
a QScroller.  In this case, one line makes a QTreeView flickable.

Pick-to: 5.15
Task-number: QTBUG-86090
Change-Id: Idb8b4709617befb261f3b78d63ddbdaf5ad18d6b
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2020-10-14 18:29:00 +00:00
Volker Hilsheimer
eed5514eaf Mark QApplication::fontMetrics as obsolete
It returns the QFontMetrics of the desktop widget, so just for the
default screen. Any usage of it is probably wrong, esp since code should
use QFontMetricsF instead.

Change-Id: I0b4b85a74a2c9b6cc023ffda0b2b399f9fc3c1c4
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-10-14 18:10:19 +02:00
Volker Hilsheimer
a8dd18252c Remove QApplication::desktop
It's been replaced with QScreen-based APIs.

There's some internal code left
depending on a QWidget representing a screen, so move the API into
QApplicationPrivate until that's cleaned up as well.

Change-Id: I851e0901832f2747af3bf2c16a9c4d815598bd08
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-10-14 18:10:16 +02:00
Volker Hilsheimer
5c097f895d Add \since 6.0 to new function
Also fix general style of the documentation.

Task-number: QTBUG-86479
Change-Id: Ia46bb3ec02d6474dd79b8ac733e0c613abc5e0d8
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2020-10-14 18:10:01 +02:00
Mårten Nordheim
51faa0700d Schannel: TLS1.3 support
It's not possible to connect to microsoft.com with Schannel TLS 1.3 for
some reason (also tested with Internet Explorer), but other sites work
fine. Must be something they have to iron out for later.

In my experience this needs a preview release of Windows. One of my
machines is opted into the dev channel of Windows where they enabled TLS
1.3 by default, and it works well in my tests except for the part above.
On my other machine, after enabling TLS 1.3 through the registry, I fail
to complete the handshake with any site. So around March/April next year
is when this code would activate for most people.

MinGW apparently defines NTDDI_VERSION as the one for Windows Server
2003, so it currently doesn't build the new TLS 1.3 code. In Qt (as a
project) we could consider setting this higher, but that's out of scope
for this patch!

Fixes: QTBUG-81294
Change-Id: If329959c3a30ecbfbb8c0d335cc39ccb6d012890
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2020-10-14 15:58:16 +02:00
Volker Hilsheimer
1c76aa077e Get rid of all usage of QApplication:desktop
Use QScreen APIs instead.

Change-Id: Ie99af94fe4292223dbb165b3f5c1b74e8fe0498b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2020-10-14 06:38:43 +02:00
Giuseppe D'Angelo
772a10391e Drop qt_is_permutation
It was a workaround until we could depend on C++14's
std::is_permutation overload with 4 args. We now can, and the code
using it is gone anyhow, so drop it.

Change-Id: Ib9af71eeb767c83b1150c482441503288f1987d4
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-14 00:59:10 +02:00
Volker Hilsheimer
456ba431e6 Document QApplication::desktop as obsolete
There is no function equivalent in Qt 5.15, but the entire QDesktopWidget
class is already documented as obsolete, so this method should implicitly
no longer be used in new code.

Qt 6 lifts QScreen up to support the various QDesktopWidget use cases,
and a follow up will remove this method from Qt 6.0, or at least mark it
as deprecated API as well so that it
generates warnings when used.

Change-Id: I9b205e6d4a636c22a95728695088233c898cbfc4
Pick-to: 5.15
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2020-10-14 00:44:37 +02:00
Andrei Golubev
ba511b2fa4 Reject overwrites by the same index in QPromise::addResult()
One can call addResult(value, index) twice and consequently set the
value twice by the same index. This seems rather strange and probably
should not be allowed. This commit rejects setting results when there's
already a valid result by that index. Consequently, this fixes memory
leaks caused by N-times-called addResult(..., index)

Fixes: QTBUG-86828
Change-Id: I77494f2cb73ce727ffad721cfcdcaa420899eb25
Reviewed-by: Sona Kurazyan <sona.kurazyan@qt.io>
2020-10-13 17:04:16 +02:00
Andrei Golubev
1ae15edd7e Remove nodiscard in QPropertyObserverNodeProtector ctor
Produced error in my GCC 7.5 on Ubuntu 18:
error: ‘nodiscard’ attribute applied to ‘QPropertyObserverNodeProtector<<anonymous> >::QPropertyObserverNodeProtector(QPropertyObserver*&)’ with void return type [-Werror=attributes]
     Q_REQUIRED_RESULT QPropertyObserverNodeProtector(QPropertyObserver *&observer)

Change-Id: Ic1f6c4f502bb4d5c764686d5521b92f655592bb2
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-10-13 17:00:23 +02:00
Tor Arne Vestbø
705837771c Add a few missing Q_CLANG_QDOC for native interfaces
Change-Id: I5dbe2f7e7c03fb0a130b2da373f6f6a642d57575
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2020-10-13 16:39:32 +02:00
Assam Boudjelthia
13b4c332b4 Android: add missing new line to androidtestrunner help
Change-Id: Idba54c15af64b8dadcba9fa2125d6aae5e6c6bc9
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2020-10-13 15:32:33 +03:00
Timur Pocheptsov
4c251ac224 QSslSocket - replace NULL with nullptr
Change-Id: I3af7747f424ef7837c9c3d4af3e5cbd14922aeb6
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-10-13 11:34:04 +02:00
Tor Arne Vestbø
12ef5a7344 doc: Add brief and group for native type conversions
Change-Id: I74608619201bf77e487fb986bf213b349cc22f6a
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2020-10-13 10:44:02 +02:00
Giuseppe D'Angelo
f8076d6a5b QCborValue: streamline some code with qExchange
Change-Id: I79b68173a236ff1f28504a11ff182bdf48b2df0b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-13 10:28:54 +02:00
Lars Knoll
3e08154582 Mark the class QPropertyObserverNodeProtector as [[nodiscard]]
And not its constructor, as GCC at least doesn't like that.

Change-Id: I4aada7ca7135dd9c599980640588e7c98d398171
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-10-13 10:27:13 +02:00
Sona Kurazyan
d5c53554e5 Loosen the requirements on the container passed to QtConcurrent::map*
Using std::begin() and std::end() forces the user to have const begin()
and end() member functions being defined for the passed container. This
is because std::declval<T>() returns rvalue which forces the compiler
to select std::{begin, end}()(const Container &c) overloads and an test
for a presence of const {begin, end}() methods.

Change-Id: I9d96d9f73891ece53224f1741a1334500f7b35ad
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-10-13 09:49:51 +02:00
Fabian Kosmale
1918c689d7 QObject: simplify part of connection logic
We do not require anymore that the metatypes are declared beforehand,
but can instead simply use QMetaType::fromType<T>().id().
This allows us to remove the templates containing the "metatype is
declared" validation logic.

Change-Id: I0b74c72643a233335689074091a38648f3e4f853
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-10-13 08:49:43 +02:00
Volker Hilsheimer
044231c4d2 Remove timeStep parameter from QAnimationDrive::advanceAnimation
This reverts commit 7544c242cb, which
reverted the first removal of the parameter under the assumption
that it caused flakiness in tests.

The flakiness was instead caused by changes to the wait functions
in QTest, so remove the parameter again.

Change-Id: I98154d5d7268375aebbcb09de757e75d9b765c5f
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-10-13 08:44:42 +02:00
Allan Sandfeld Jensen
182760e84d Fix detach on bool check of QSharedDataPointer
We have a conversion to T* which would be triggered for a non negated
bool check.

Pick-to: 5.15
Change-Id: I543c66de6b4da64a3a63ee9a438fab6adcc58052
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-13 08:32:52 +02:00
Fabian Kosmale
b83225fcc3 qDebug: Avoid implicit QVariant conversion
This commit restricts operator<<(QDebug lhs, QVariant rhs) to only work
if rhs is actually of type QVariant (instead of any type convertible to
QVariant). This is especially important as
a) we check in QMetaType whether (slightly simplified) QDebug{} <<
   std::declval<T>() is valid, and if so, register a function which
   simply uses the operator.
b) In QVariant, we ask the metatype system for the contained types
   registered debug function and then use it.
If a type now does not have its own operator<< for QDebug, but is
implicitly convertible to QVariant containing itself, this would lead to
an infinite recursion, when trying to use qDebug with that type. The
registered function in a) would just convert the type to QVariant, and
then ask the QVariant to print itself.
Disallowing implicit conversions in qDebug in general was considered
(i.e. adding template<typename T> operator<<(T) = delete in QDebug ),
but discarded as it breaks too much code relying on conversions.

Fixes: QTBUG-87122
Change-Id: Ib709297670cbc6cc307efd0dfd8e5b0279df9414
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-13 08:06:18 +02:00
Alexandru Croitor
9aa2be236f CMake: Rename qt6_quick_compiler_process_resources to be internal
Task-number: QTBUG-86827
Change-Id: I9d97b53a8c85e0c488be312c8894a1d73397eb13
Reviewed-by: Simon Hausmann <hausmann@gmail.com>
2020-10-12 18:18:55 +02:00
Edward Welbourne
e2628b5f57 Minor refinements in QLocale
A loop's condition could be simplified.
Use std::size() rather than sizeof()/sizeof().
Clarify two comments.

Change-Id: Ideba2e0e1ba9c9656297aefb0a375cc122ee8626
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-12 16:54:01 +02:00
Edward Welbourne
57455543c5 Eliminate QLocaleId::fromIds() in favor of {...} construction
It's a value type, we don't need a pseudo-constructor to bypass constructors.

Change-Id: Ic4774c82e43ab7e2c54ac743026ce087e34c150f
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2020-10-12 16:53:45 +02:00
Edward Welbourne
8b0e068847 Mark QLocale's Language, Country and Script enums as ushort
The code pervasively presumes their values can be held in a ushort, so
make sure the compiler knows we expect that to work (and doesn't
complain about narrowing when we do convert them to ushort).

Change-Id: Idde7be6cceee8a6dae333c5b1d5a0120fec32e4a
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-10-12 16:53:40 +02:00
Tor Arne Vestbø
71ad83529e rhi: Add missing \internal doc commands
Pick-to: 5.15
Change-Id: I09a69a04c6fcd406602e797cbeec59216fecd5d8
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2020-10-12 15:27:46 +02:00
Tor Arne Vestbø
7e271686a7 Exclude all modifiers as candidates for shortcuts
If we're going to limit shortcuts to non-modifiers, we should
at least include all of the modifiers, otherwise we'll end up
passing through e.g. Key_CapsLock.

Change-Id: If11758f85d06f75e9b9c2d2a57d4a4915ff72317
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2020-10-12 15:23:15 +02:00
Lars Knoll
92b7122eda Remove dead code
This code has been deprecated in Qt 5.

Change-Id: Ia8e0bc791ac1f43df7124b4f30db3d0bb9966015
Reviewed-by: Alex Blasche <alexander.blasche@qt.io>
2020-10-12 14:49:50 +02:00
Lars Knoll
feab484b8d Enable the Android style plugin for the cmake build
Change-Id: Ie6a82c47c92067fb22270891bb81cd75ed3c9212
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2020-10-12 14:49:24 +02:00
Timur Pocheptsov
4cfea12cb8 QtNetwork: add documentation about porting from Qt 5 to Qt 6
Fixes: QTBUG-87098
Change-Id: I91e9d644c6491abaa3bdfe2735aff4a43b545da5
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-10-12 14:17:17 +02:00
Andy Shaw
bdc9d272ee Fallback to using the family when doing an exact match
If the difference between the families sizes is just 1 where one of them
is 0 in size then we can fallback to the family in that case.

Pick-to: 5.15
Fixes: QTBUG-87267
Change-Id: I62b25b06c88000b4d7defe91871c07873b1fc792
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2020-10-12 14:08:06 +02:00
Sona Kurazyan
605bbe2011 Make QtConcurrent docs more readable
- Replaced 'auto' keyword in function signatures by the actual return
  type.

- Fixed signatures to not include enable_if statements.

Change-Id: I7292e8e506fd50d22974a86448fa4e85e8f08dfb
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Andreas Buhr <andreas.buhr@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-10-12 13:52:01 +02:00
Sona Kurazyan
3069313492 Eliminate the extra copy in QtConcurrent's blocking methods
Use QFuture::takeResult() instead of QFuture::result() for returning the
resulting sequence from the blocking methods of QtConcurrent.

Change-Id: I0b623ee1ad8bda6789f329dcd63a46acda924539
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2020-10-12 13:51:49 +02:00
Sona Kurazyan
3d040267f4 Temporarily disable QFuture::takeResult() method
QFuture::takeResult() currently returns std::vector instead of QList,
because QList does not support move-only types. Disable this method
until QList is fixed to work with move-only types in Qt 6.1.

Also did minor doc-fixes.

Change-Id: I87feaf75d9433a3b540edd00039c3e21d6994985
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2020-10-12 13:51:34 +02:00
Mitch Curtis
4897aa8b5f Fix build when configuring with -sanitize thread on gcc
There is no <sanitizer/tsan_interface.h> header when building with gcc,
at least on Ubuntu 18.04.3.

Fixes: QTBUG-87317
Change-Id: Ie933f6fa478f11b5062c665007e91be68e31ebe3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-12 13:47:40 +02:00
Alexandru Croitor
28ed9e3e2d CMake: Set some additional info variables in Qt6CoreConfigExtras
Add info whether Qt was an infix built, and whether the reduce_exports
feature was enabled. These variable were set before in
Qt5CoreConfigExtras.cmake.

Change-Id: Id077763cfffd5ee6f1a7a28d04cf92dc46390c54
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
2020-10-12 13:35:50 +02:00
Alexandru Croitor
c6a5cdcee6 CMake: Introduce Qt6::Startup target
Add an abstraction over Qt::WinMain (aka qtmain.lib) and
iOS's runtime linker entry point (_qt_main_wrapper).

The Core target will now link against the Startup target on all
platforms, instead of just WinMain on Windows.

The creation and linkage interface definition of the Startup target
is done at find_package(Qt6Core) time via the private call of
_qt_internal_setup_startup_target().

This will add automatic linkage of WinMain to executables marked with
the WIN32_EXECUTABLE property on Windows.
As well as the addition of the '-Wl,-e,_qt_main_wrapper' linker flag
when linking iOS executables.

Qt users can opt out of this behavior by either setting the
QT_NO_LINK_QTMAIN property or variable. This is in line with
Qt 5 behavior.

Task-number: QTBUG-87060
Change-Id: I7d5e9f1be0e402cf8e67e6f55bfd285f9e6b04f4
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2020-10-12 13:35:48 +02:00
Kai Koehne
7c12c8d113 Fix copyright year of tinycbor
[ChangeLog][Third-Party Code] Fix aggregated copyright information of TinyCBOR
component to reflect the years in the individual source files. Note that this
is not same as the Copyright year in the upstream MIT license text.

Pick-to: 5.15 5.12
Change-Id: I238d973d937fbfc3a81627c4c65491fbb5cb3c30
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2020-10-12 13:20:12 +02:00
David Skoland
b683d8727f Fix "Runing" typo in CMake config
Change-Id: I77f2970d70ab221e5d7d5c5d389041ed1b6c49f5
Reviewed-by: Daniel Smith <Daniel.Smith@qt.io>
2020-10-12 13:05:34 +02:00
Ulf Hermann
d9f9bc9bad QMetaType: Avoid combination of extern and declspec(__dllexport) on MSVC
MSVC does strange things with this, and it actually tells us so via a
warning. We can, however, attach the dllexport to the definition, rather
than the declaration of the symbols in order to resolve the problem.

Change-Id: I9971e13afc6d8840c49ec20d21820a72c5407200
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2020-10-12 13:04:27 +02:00
Tor Arne Vestbø
b1e234b224 macOS: Always include non-GL native interfaces
Change-Id: Idc8e76b5cb7af8b8df54820a4150ac7d1e3d8944
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2020-10-12 13:03:59 +02:00
Tor Arne Vestbø
2b14556a96 Rename QtGui native interface implementation files
Follows the naming convention used by the plugins as well.

Change-Id: Icba62fc2aaa5acf0ab3c88599a63aab1f530a2ab
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
2020-10-12 13:03:56 +02:00
Fabian Kosmale
75b8c4d75e QPropertyBinding: compare QMetaType directly
Change-Id: I36fbc8ebed096aa6f7be48456005395b65229359
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-10-12 13:01:49 +02:00
Fabian Kosmale
ed460ba7e2 QPropertyObserver: mark as noexcecpt
Change-Id: I2df75b35e42fa923c6cbf71a15569dc37140ee55
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-10-12 13:01:45 +02:00
Fabian Kosmale
f2f5e962b6 QUntypedPropertyBinding::QUntypedPropertyBinding: use member initializer list
No need to default initialize the std::function and source location.

Change-Id: I7d840376b16e7257386a4787dd06b7956fe37576
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-10-12 13:01:44 +02:00
Fabian Kosmale
901b2975dd QProperty: avoid needless std::function copying
Change-Id: Iea6280b12e7146a9ac92f071a4c21b373e9d3ab0
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-10-12 13:01:43 +02:00
Fabian Kosmale
f912ad0a4d QProperty: make a few helpers constexpr
Change-Id: I1f3b2223530c311a7b40fd36c8162e32adbd9569
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2020-10-12 13:01:37 +02:00
Fabian Kosmale
2f3cd3b1a8 Handle notifier list modification during iteration
As propertyobservers can execute arbitrarily complex code, they can also
modify the obsever list in multiple ways. To protect against list
corruption resulting from this, we introduce a protection scheme which
makes the list resilient against modification.
A detailed description of the scheme can be found as a comment in
QPropertyObserverPointer::notify.

Task-number: QTBUG-87153
Change-Id: I9bb49e457165ddc1e4c8bbdf3d3c9fbf5ff27e94
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-10-12 13:01:29 +02:00
Sona Kurazyan
64c9db2259 Remove an unneeded include
Change-Id: Iba171012955e475f51d6319a69d8cd351aa6131b
Reviewed-by: Karsten Heimrich <karsten.heimrich@qt.io>
2020-10-12 13:00:43 +02:00
Allan Sandfeld Jensen
a0deaf42e2 Improve QRectF::toRect()
Implement the better rounding mechanism that was previously blocked
by requiring C++14 to be constexpr.

Change-Id: I4e5b179ce0703f5c0b41c3f0ea00d28dfe53740c
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-10-12 13:00:43 +02:00
Fabian Kosmale
927813fc95 QPropertyChangeHandler: mark as nodiscard
Change-Id: Ibf399b5aac732e8f80d0a37df711806c1c5550ac
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2020-10-12 13:00:43 +02:00
Mitch Curtis
98d65f2ff4 Add an example to the documentation of QImage::scanLine()
I couldn't find any examples in Qt's documentation of this when I was
trying to use it in a project.

Pick-to: 5.15 5.12
Change-Id: Ic7b7b71f219b2c1012829980866940b9a77bd11f
Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
2020-10-12 13:00:43 +02:00
Mitch Curtis
418389c3ed Link to qAlpha in qRgb() and qRgba() docs
Pick-to: 5.15 5.12
Change-Id: I5a3b8573123e82f4c8c92fa7a2e1af06e2e84eb2
Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
2020-10-12 13:00:43 +02:00
Mitch Curtis
8095829758 Improve QRgb documentation
- Add examples of how to create QRgb values
- Link to qRgba()

Pick-to: 5.15 5.12
Change-Id: I2a86b1c8e00137ba868426b8157a3aa0d924d7a6
Reviewed-by: Venugopal Shivashankar <Venugopal.Shivashankar@qt.io>
2020-10-12 13:00:43 +02:00
Allan Sandfeld Jensen
0aa8925f1a Protect QImage work on shutdown
If the thread pool was not created, or already deleted, make sure
the QImage routines can still run as they could before.

Fixes: QTBUG-87320
Pick-to: 5.15
Change-Id: I4105a68b6ae0637faf82cdda5f5ae44298759396
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2020-10-12 13:00:42 +02:00