Commit Graph

40099 Commits

Author SHA1 Message Date
Edward Welbourne
b67c367e0e Tidy up testlib's parsing of -callgrind parameter
Invert a condition to turn a nested if (that was missing one of its
layers of braces) into an else-if chain, split some long strings to
limit line length.

Change-Id: I10d90487a09affe981aa11c3588281aeb3666df5
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-09 20:54:25 +01:00
Alexandru Croitor
197753d8ae CMake: Mark the new deployment API as being in Technical Preview
Amends 22c92f3967

Task-number: QTBUG-98545
Change-Id: Ifaa7e4884f0eb1caa6d3d4906a2701f8fa5e43c2
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2021-12-09 19:59:55 +01:00
Alexandru Croitor
0a28c55a87 CMake: Fix some of the CMake commands not using the right doc group
Augments e0ecb0ded2

Pick-to: 6.2
Change-Id: I4eea51b66ffa5ffe45faa3c51a4b65a526dd73e7
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2021-12-09 19:59:55 +01:00
Marc Mutz
e297e80fd0 QVarLengthArray: make reallocation strongly exception safe
The old code had several bugs:

- it immediately clobbered *this with new state, before having copied
  over the elements from the old to the new buffer

- when buffer relocation threw, it would keep the new (partially-filled)
  buffer and throw away the old

- it unconditionally used std::move() for non-relocatable types, making
  it impossible to restore the original buffer when a move throws

Instead of clobbering *this with new state, do all the work on the
side and change *this only once the reallocation has happened
successfully.

Also use q_uninitialized_relocate_n() and unique_ptr in the
implementation to simplify the code. The former got the necessary
update to use std::move_if_noexcept() instead of an unconditional
std::move() for the non-relocatable case.

[ChangeLog][QtCore][QVarLengthArray] The append()-like functions are
now strongly exception safe. This means reallocation will now use
copies instead of moves, unless the value_type has a noexcept move
constructor.

Fixes: QTBUG-99039
Change-Id: I031251b8d14ac045592d01caed59d4638c3d9892
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-12-09 18:59:55 +00:00
Marc Mutz
c1f510b359 QVarLengthArray: implement append() via emplace_back()
Less code duplication, means less functions to move into the
upcoming QVLABase.

Change-Id: I67a817c971a4e5a81ae45ff30282878be1bde2aa
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-12-09 18:49:33 +01:00
Marc Mutz
7db44f60b1 QVarLengthArray: inline some trivial reallocate() wrappers
These functions don't deserve to be defined outside the class body,
as they're trivial wrappers around reallocate().

Cleans up the header somewhat, in preparation of the upcoming
QVLABase/QVLAStorage split.

Change-Id: Ib4062eca4214a67e67f472a7c1e4bf4d9813c8a4
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-12-09 18:49:33 +01:00
Marc Mutz
574be167fb QVarLengthArray: use C++14 4-arg std::equal()
Simplifies the code, since we now need neither the manual size check,
nor the warning fix (checked iterator macro) for MSVC.

Change-Id: Ic267c66eb4568d2db8d9c9ccad0ce7e1a5cc3373
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-12-09 18:25:49 +01:00
Friedemann Kleint
f6cbb1ae70 Re-enable parsing Qt code with LLVM (Qt for Python)
Exclude the check introduced by 0dc6cc0551
for clang compilers since there seems to be no equivalent option
-permissive- for the MSVC emulation.

Change-Id: I0468d8e2f2c988e604be6960f1b1f4760ea0c400
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
2021-12-09 07:00:02 +01:00
Ievgenii Meshcheriakov
4f53c703e4 QLocale: Extend support for language codes
This commit extends functionality for QLocale::codeToLanguage()
and QLocale::languageToCode() by adding an additional argument
that allows selection of the ISO 639 code-set to consider for
those operations.

The following ISO 639 codes are supported:
    * Part 1
    * Part 2 bibliographic
    * Part 2 terminological
    * Part 3

As a result of this change the codeToLanguage() overload without
the additional argument now returns a Language value if it matches
any know code. Previously a valid language was returned only if
the function argument matched the first code defined for that
language from the above list.

[ChangeLog][QtCore][QLocale] Added overloads for codeToLanguage()
and languageToCode() that support specifying which ISO 639 codes
to consider.

Fixes: QTBUG-98129
Change-Id: I4da8a89e2e68a673cf63a621359cded609873fa2
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-12-09 03:45:08 +01:00
Volker Hilsheimer
b886a7ca65 Add unit test for moving of opaque widgets
Expose QWidgetRepaintManager's data structures so that we can write
unit tests, and verify that they are correct after moving opaque
widgets (which triggers the accelerated move code path).

Improve the compareWidget logic to not rely on screen grabbing
(which requires permissions), but instead use QPlatformBackingStore's
toImage function, which is faster and more reliable, and also doesn't
require us to show the UI we want to grab full screen in order to
avoid issues with overlapping windows etc.

Change-Id: Iff2ea419f03a390ab6baca26814fef6ff45f7470
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-12-08 23:06:42 +00:00
Friedemann Kleint
9ad00e4b3f Windows QPA: Fix cursors getting out of sync after restoring override cursors on native windows
Introduce a flag to QWindowsWindow which forces the cursor to be applied
after restoring override cursors.

Fixes: QTBUG-98856
Pick-to: 6.2 5.15
Change-Id: Id62cdc2dd01f45324503a542446b1c11a1fe6f44
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Keith Kyzivat <keith.kyzivat@qt.io>
Reviewed-by: André de la Rocha <andre.rocha@qt.io>
2021-12-08 23:41:24 +01:00
Eskil Abrahamsen Blomfeldt
ee7573f61f Callbacks for begin/end of a frame on OpenGL
The background for this is that when running Wayland, the
Mesa driver has an issue which makes it crash if we call
eglDestroySurface() while we are rendering to it. This is
not according to the documentation, and it only seems to
happen on Mesa and only on Wayland, so it is probably
related to something in the Wayland implementation in the
driver.

Since this driver is very popular, we want to work around it,
which can easily be done using existing locking mechanisms
in the Qt Wayland QPA plugin. But in order to do so, we need
reliable callbacks for the start and end of a frame. The RHI
already has this, so we just need to channel the information
to the QPA plugin.

Having beginFrame/endFrame hooks in the QPlatformOpenGLContext
could be useful in other cases as well, especially knowing that
there are OpenGL implementations that require some extra thread
protection.

QPlatformSurface would be a more general location for these
hooks, but since the issue is only seen on OpenGL and
multi-threading is handled more explicitly in other APIs,
we don't want to expose this API in a more general location
than necessary.

Task-number: QTBUG-92249
Change-Id: I97ce7d4f744c4b28eec457e919d1c9652ff00079
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-12-08 21:08:04 +01:00
Volker Hilsheimer
b393370ebb Code tidies: improve variable naming and add const where possible
Remove obsolete check for valid sourceRect, we never get into the
accelerated code path if it's not.

Pick-to: 6.2
Change-Id: I872685fca8cba3a09ed856d727d5baafddee161b
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-12-08 21:04:43 +01:00
Craig Scott
5cdc82e364 Fall back to include() method for finalizers with CMake 3.17 or earlier
Functionality is being added in other repos which require finalizers
to be run for non-static builds. That means we now need to ensure
finalizers always run even with CMake versions before
cmake_language() was added. The fallback method of writing to a file
and including it is slower, but that's better than missing important
functionality altogether.

Task-number: QTBUG-98545
Pick-to: 6.2
Change-Id: Ic8668c91c26d0c30de084b1b803032088c10fcf4
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-08 19:50:21 +01:00
Craig Scott
22c92f3967 Add documentation for CMake deployment support
Task-number: QTBUG-98545
Change-Id: Ifd5c0f4ce278c683bb0d3ba6a259ec14a7f24181
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-12-08 19:50:21 +01:00
Craig Scott
3ee79be628 Add CMake deployment support
Task-number: QTBUG-98545
Change-Id: I581c1173cdfc92c09fd2cf0bbe7ec6bc8d52b868
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2021-12-08 19:50:21 +01:00
Tinja Paavoseppä
1e64b58c35 Recognize system apps also when apk has parent directory
When checking if the apk is being deployed from system partition,
account for possibility of the apk not being installed directly under
/system/app or /system/priv-app, but in a directory of its own.
Otherwise, system applications that are not directly under system app/
priv-app directories will not be recognized as system apps, meaning
they will not use the system library path to load their libraries.

Pick-to: 6.2
Change-Id: I1e778b18cae3c0406e087b8c78fd31d521f7be73
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2021-12-08 19:22:36 +02:00
Andreas Buhr
1f2f61d808 Fix typo in QAbstractItemModelTester
When recursively checking children in QAbstractItemModelTester,
the currentDepth of recursion was incorrectly increased.
This patch fixes it.

Pick-to: 6.2 5.15
Change-Id: Ia79508f358e2fcb6b90780a79baec053522e871c
Reviewed-by: David Faure <david.faure@kdab.com>
2021-12-08 17:39:27 +01:00
Marc Mutz
d4a88e4ea4 QVarLengthArray: fix size update on failed append()
If the in-place constructor throws, the old code had already updated
the container's size(). Fix by delaying the update to after the
in-place construction.

[ChangeLog][QtCore][QVarLengthArray] Fixed a bug whereby a failed
append() would leave the container with an inconsistent size().

Pick-to: 6.2 5.15
Change-Id: Ief1e668d945149bd8ba96c8af1398baaa7876880
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-12-08 16:39:27 +00:00
Yuhang Zhao
0f88e79ed8 QCoffParser: Replace windows.h with qt_windows.h
Change-Id: I9aeeb2cef4d068020e0c176a70ad86c9e28b0e68
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-09 00:35:09 +08:00
Liang Qi
493a85a9e4 Widgets: setTransientParent() when a QMenu is a window
On some platforms, such as X11 and Wayland with some compositors,
QMenu could be a popup window, which should be set a transient parent
to get relative position, which is requested by Wayland.

Added transientParentWindow() for QMenuPrivate like QDialogPrivate.

Fixes: QTBUG-68636
Pick-to: 6.2
Change-Id: I6d8880cb008ecf61a4c005898b38e3953379a13d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-12-08 13:45:36 +01:00
Laszlo Agocs
9c05fdac81 evdevkeyboard: Try opening as read-write first
switchLed writes to the device, and so O_RDONLY cannot be correct.

Change-Id: If79814804bcd3c6fb01617be9f1a73e54b9563bd
Pick-to: 6.2 5.15
Fixes: QTBUG-80653
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-12-08 13:45:34 +01:00
Joerg Bornemann
d8b943849f Revert "Compile: Work around false positive on gcc >= 900"
This reverts commit d62e9d3c5b.

Reason for revert: The -Wstringop-overread option was introduced in
gcc 11.  This fixes the build for gcc 9 and 10.

Change-Id: I96ab5f917d6200cb1681fe6236f1fd4630ef4f7d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-08 12:13:23 +00:00
Christian Ehrlicher
64449abe17 QTableWidget doc: remove wrong comment for itemExpanded()
Since Qt5.1 (80fa4b6c8e) expandAll() emits expanded() but within this
change, the comment in itemExpanded() was forgotten.

Pick-to: 6.2
Pick-to: 5.15
Change-Id: Ic487e5f8999d6af27a4747b861464058faf03889
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-12-08 10:33:55 +01:00
Karsten Heimrich
c7248a3879 Implement fetching physical QStorageInfo::blockSize() under Windows
This is implemented in two passes, first we try the older and
always available DeviceIoControl() function. This works most of
the time, though it might fail for example for storage devices
attached via USB. In this case, we try to dynamically load the
newer NtQueryVolumeInformationFile kernel function. Since this
is probably more expensive, we do this as fallback.

[ChangeLog][QtCore][QStorageInfo] The QStorageInfo::blockSize()
will now report the physical block size of a storage device under
Windows. Network mapped drives are not supported.

Fixes: QTBUG-93976
Change-Id: I08b5b879e5bf79c025e2e305196ec5c5fce8b20f
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-12-08 09:29:02 +01:00
Lorn Potter
f0be152896 wasm: improve clipboard support
Add support for Clipboard API
Add clipboard manual test

Also includes these fixes:

- improve clipboard use for chrome browser
- make QClipboard::setText work
- html copy and paste
- image copy/paste

Chrome browser supports text, html and png

To use the Clipboard API, apps need to be served from
a secure context (https). There is a fallback in the
case of non secure context (http)

- Firefox requires dom.events.asyncClipboard.read,
dom.events.asyncClipboard.clipboardItem and
dom.events.asyncClipboard.dataTransfer to be
set from about:config, in order to support the
Clipboard API.

Change-Id: Ie4cb1bbb1dfc77e9655090a30967632780d15dd9
Fixes: QTBUG-74504
Fixes: QTBUG-93619
Fixes: QTBUG-79365
Fixes: QTBUG-86169
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2021-12-08 13:39:58 +10:00
Volker Hilsheimer
3b24713098 Fix incorrect rendering when moving widget into screen
When the widget we are moving in was previously outside of its parent's
clip rect, then we cannot use the accelerated move code path, as there
are no pixels to bitBlt from the previous to the new area.

Pick-to: 6.2
Task-number: QTBUG-26269
Task-number: QTBUG-98151
Change-Id: I324c6111de27cdd14cf8de8632a980aa351cc123
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-12-08 00:40:21 +01:00
Volker Hilsheimer
30b0b72453 Test for nullptr before dereferencing the screen
Touch event processing might still be ongoing even after the screen
has been disconnected. If that screen was also the primary screen, we
would dereference nullptr.

Check for nullptr to avoid potential crashes during shutdown.

Fixes: QTBUG-95192
Pick-to: 6.2 5.15
Change-Id: I49ccd30c4126fe12cf5bb675e532e6e59b40b9c1
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-12-08 00:40:21 +01:00
Ivan Tkachenko
e65c29fffc Doc: Reword, fix typos and some formatting
Change-Id: I0929f7653cb07665842d0aa7bf18dc80471febdc
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2021-12-08 02:28:34 +03:00
Marc Mutz
adcc68fd59 QVarLengthArray: remove unneeded copy in replace()
QVarLengthArray is neither implicitly shared, nor does it feature a
magic resize() on out-of-bounds.

Therefore, data() doesn't detach(), so 't' remains stable.

The only reason for the copy, then, would be if T wasn't
self-assignment-safe, but we don't support such types.

Remove the copy.

Change-Id: I8dd12e1c9b8131ae17d641354fe362554062b78d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-12-07 22:53:14 +01:00
Marc Mutz
ac4c0e1f02 QVarLengthArray: don't mix iterator/const_iterator in offset calc
The functions aren't const so begin() will return a mutable
iterator. The function arguments, however, are const_iterators.

It doesn't matter for QVLA, which isn't implicitly shared, but code
hygiene suggests to use cbegin() instead, to compare const_iterators
to const_iterators.

Change-Id: I9bfa993780ee4b68d13f6b6410772b0f1ccedad3
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-07 22:53:14 +01:00
Marc Mutz
dbf836738a QVarLengthArray: port internal users from at() to op[]
In preparation of splitting the class into QVLABase and
QVLAStorage.

Task-number: QTBUG-84785
Change-Id: Ic0da6c2e110a5b979b78989616b9a2cb0f27463b
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-07 19:24:05 +01:00
Giuseppe D'Angelo
84fba93ebb QThread::create(): request interruption and join on destruction
If one destroys a running QThread, so far the behavior has been to crash
(à la std::thread) -- assuming the thread hasn't already signalled that
it has finished. This behavior is hostile to solutions such as using
QThread::create(), which always require a wait() before destroying the
thread object.

We can use the opportunity to change the behavior without breaking any
valid code. Instead of crashing, inside QThread's destructor we can ask
the new thread to quit, and then join it (à la std::jthread). This
simplifies the implementation of long-living runnables and the code that
manages them.

Deploying this solution for the whole QThread class may not be entirely
painless. While no correct code would work differently with the proposed
changes, incorrect code that deletes a running thread would no longer
crash "loudly" -- instead, it might deadlock "quietly", have memory
corruptions, etc.

Hence I'm limiting this approach to only the threads created by
QThread::create(), at least for the time being. This also side-steps
perhaps the biggest problem of generalizing the approach, which is that
placing such interrupt+join logic into~QThread's destructor would cause
it to be run _after_ a QThread subclass' own destructor has run,
destroying the subclass' data members too early. This might create
an antipattern if one chooses to subclass QThread. With create(), a
subclass in question exists, and it indeed has NSDMs, but it's entirely
under our control (in fact, I'm placing the logic just in its dtor).

[ChangeLog][QtCore][QThread] Destroying a QThread object created by
QThread::create() while the thread that it manages is still running will
now automatically ask that thread to quit, and will wait until the
thread has finished. Before, this resulted in a program crash. See the
documentation of QThread::~QThread() for more details.

Change-Id: Ib268b13da422e277ee3ed6f6c7b2ecc8cea5750c
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-12-07 16:56:49 +01:00
Friedemann Kleint
49a8ab50ba uic: Generate parameters for ambiguous signals
Fixes: PYSIDE-1720
Pick-to: 6.2
Change-Id: I71b77db73471bdec7826bf69c7df521d7686537e
Reviewed-by: Cristian Maureira-Fredes <cristian.maureira-fredes@qt.io>
Reviewed-by: Jarek Kobus <jaroslaw.kobus@qt.io>
2021-12-07 14:01:58 +01:00
Volker Hilsheimer
c001216eed Revert optimizations and fixes for moving/scrolling overlapped widgets
This reverts the QtWidgets changes made in commits
22634e0079 and
5b09346cf4 while keeping the auto tests
introduced in the former commit.

Both commits introduced rendering errors when moving widgets out of
or into areas in which they are obscured. Before we apply any further
optimizations to this code we need thorough auto test coverage.

Task-number: QTBUG-98151
Task-number: QTBUG-26269
Pick-to: 6.2
Change-Id: I9cb82b73776daed59ea0e9f51ff7ddef1c7265b6
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-12-07 14:01:58 +01:00
Marc Mutz
ab1180a2b0 QVarLengthArray: merge remove(idx [,n]) into one function
remove(i) is the same as remove(i, 1), and the extra 'n' argument is
of trivial type, so it's ok to default it instead of overloading.

Change-Id: Id926cd63fde518e002684a41e055edc1004247a4
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-12-07 09:06:19 +01:00
Marc Mutz
20ab12d181 QLogging: mark all warning() and critical() functions as cold
Previously, only the printf-style overloads were marked as such.

Saves ~7KB in QtCore text size on Linux AMD64 GCC 11 C++ 20 builds.

Change-Id: I4ed480e48060b87968f3d15bb5a84bdbcf70a647
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-07 09:06:18 +01:00
Marc Mutz
06ba067a34 QVarLengthArray: centralize index checking
Factor the assertions relating to sizes and indexes into an inline
function, verify(). This hopefully reduces the string data generated
for assertions to the bare minimum.

Change-Id: Iad5c2e587ad189e7e1a62b9ca61ada4282c44f51
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-07 05:33:40 +01:00
Mårten Nordheim
78df625510 QMultiHash: fix erase returning the wrong iterator
When deleting the last item in a chain, without it being the last item
in the chain, then we re-use the iterator which was passed in as an
argument. This is wrong if we detached earlier in the function, and
means we return an iterator to the previously shared data.

Pick-to: 6.2
Change-Id: I7da6309e23a32073da59e7da0cbfd1d16734f1ca
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2021-12-07 03:07:49 +01:00
Igor Kushnir
d797e3c88e Optimize QMimeDatabase::mimeTypeForFile(f, MatchDefault)
Open the file only if matching on content is needed.

Use QFileInfo::filePath() instead of QFileInfo::absoluteFilePath() in
QMimeDatabase::mimeTypeForFile(). filePath() does much less work, and so
is faster. Thiago Macieira helpfully explained in a review comment why
the absolute path is not useful for correctness here: "Nothing needs
absolute paths within the same application that would resolve the
relative path to absolute. You only need an absolute path if you're
communicating with another application that may be in a different
directory."

QMimeDatabase::mimeTypeForFile() checks fileInfo.isDir(), so the
fileName.endsWith(QLatin1Char('/')) check in
QMimeDatabasePrivate::mimeTypeForFileNameAndData() was redundant when
called from this function. The other two callers of that function now
check this condition before opening IO devices. This improves
performance of the two QMimeDatabase::mimeTypeForFileNameAndData()
overloads in the corner case.

Refactor and optimize QMimeDatabasePrivate::findByFileName() and its
usages. Previously each caller constructed a QFileInfo object and passed
QFileInfo::fileName() into this function. Now the callers simply pass an
absolute or relative path to a file into this function, which then uses
QFileSystemEntry::fileName() to exclude the path. Constructing QFileInfo
is relatively expensive, so this change slightly improves performance.

Optimize QMimeDatabasePrivate::loadProviders() by calling static
QFileInfo::exists() instead of constructing a QFileInfo object and
calling the non-static QFileInfo::exists() overload. Note that the
QFileInfo object was always created, even if QFileInfo::exists() under
an `if` and an `#if` was never called.

The following table contains the average results of the added benchmark
tst_QMimeDatabase::benchMimeTypeForFile() on my GNU/Linux system before
and at this commit. The numbers denote milliseconds per iteration.

        data row tag                        before  at
MatchDefault:
        archive                             0.029   0.016
        OpenDocument Text                   0.029   0.015
        existent archive with extension     0.039   0.025
        existent C with extension           0.033   0.020
        existent text file with extension   0.033   0.020
        existent C w/o extension            0.076   0.074
        existent patch w/o extension        0.11    0.105
        existent archive w/o extension      0.069   0.066
MatchExtension:
        archive                             0.012   0.0115
        OpenDocument Text                   0.0115  0.011
        existent archive with extension     0.017   0.016
        existent C with extension           0.011   0.011
        existent text file with extension   0.011   0.011
        existent C w/o extension            0.016   0.0155
        existent patch w/o extension        0.013   0.012
        existent archive w/o extension      0.013   0.012
MatchContent:
        archive                             0.019   0.012
        OpenDocument Text                   0.019   0.012
        existent archive with extension     0.053   0.051
        existent C with extension           0.056   0.0545
        existent text file with extension   0.058   0.056
        existent C w/o extension            0.0605  0.059
        existent patch w/o extension        0.10    0.099
        existent archive w/o extension      0.057   0.054

Change-Id: Idb541656e073a2c4822ace3f4da412f29f2351f8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: David Faure <david.faure@kdab.com>
2021-12-06 22:55:06 +02:00
Ulf Hermann
6d6fb7846c Add a const overload for QMetaType::iface()
Change-Id: I865dc51d466d90636e177556d95558ba66f466de
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-06 21:55:06 +01:00
Volker Hilsheimer
220510a885 Fix qtdeclarative baseline test failure for text tables
Amend 97cfd49401, which resulted in
incorrectly laid out tables in Text elements.

Reported by the baseline test for the scenegraph. Not reproducible using
a QtWidget text widget, so no unit-test added here.

Pick-to: 6.2 5.15
Task-number: QTBUG-86671
Task-number: QTBUG-97463
Change-Id: I607b1fea3fb5923f81f05a3646bafebec3dcf3b5
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2021-12-06 21:55:06 +01:00
Edward Welbourne
d69a4e95b1 Revert "Don't allocate an OCIDateTime object unless we're going to use it"
This reverts commit 064c3d35e6.

Reason for revert: Causes crashes on querying. Better to endure the non-NULL representations of null QDateTime values.

Change-Id: I33dd3b95ab35d8e3accb864aec13d21764b1270d
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2021-12-06 20:16:17 +00:00
Mårten Nordheim
6f542f19bf QFontDatabase (Windows): Sanitize font requests early
After the windows font engine was no longer marking everything as
scalable we started limiting the font size of requests to the maximum
of Courier when it was requested. This was a regression from 5.8 and not
in agreement with our documentation.

The problem is that we would only make the switch from Courier to
Courier New after having already gone through the foundry-lookup and
found a closest-available font size for Courier.

With this sanitization step in the backend we can make these changes
early enough that we haven't yet adjusted e.g. the font size.

Pick-to: 6.2 5.15
Fixes: QTBUG-58995
Change-Id: I319e93e6b78c7c3c5539964ac5ab4e05f8902ab6
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-12-06 20:06:06 +01:00
Tatiana Borisova
eba9196304 Fix tst_qfloat16 runtime failure for INTEGRITY
- GHS compiler is not fully compliant with iec559. Therefore we need
to update is_iec559 checking for GHS case.

Pick-to: 6.2
Change-Id: Ia094509d26bf5f0109f2937547a056267019cffb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Janne Koskinen <janne.p.koskinen@qt.io>
2021-12-06 18:53:50 +00:00
Edward Welbourne
be63c3011b Suppress test set-up and tear-down in callgrind parent process
When running a test using -callgrind, we recurse into a child process,
run under valgrind, to which we pass -callgrindchild; and we only want
the output from the child process, since the parent won't actually be
running any tests. We also won't be using the global data table for
the test in the parent process. So bypass the set-up and tear-down of
both logging and the global data table in the parent process.

Prior to commit 3ee6d8d336, these parts
of the set-up and tear-down were skipped in the callgrind parent
process, but that refactoring split qExec() up into qInit(), qRun()
and qCleanup() to enable QtQuick to recombine them to implement an
equivalent of qExec(), calling qRun() once for each built-in style. It
needs these pieces of set-up to happen in qInit(), and of tear-down in
qCleanup(), to avoid repeating them for each style. Leave a comment in
qExec() that might help future readers to understand why it's done the
way it is.

Change-Id: Ieaca9a125c713b8fcf8dec8f9be0c024a798d504
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-12-06 19:06:30 +01:00
Marc Mutz
d5c605b148 QMetaType: port the BC fix for id() to new QT_REMOVED_SINCE
The allows qmetatype.cpp compilation to enjoy PCH again.

Change-Id: I47c5af33a5dbc930ee4c120b254e732c52bc2369
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-06 19:06:30 +01:00
Gatis Paeglis
9ef69efb3b qxkbcommon: UCS-4-encode surrogate characters in QKeyEvent::key()
Fixes: QTBUG-72776
Pick-to: 6.2 5.15
Done-with: Liang Qi <liang.qi@qt.io>
Change-Id: I9d1f4e34527079c3bc460016fe9b953636b4d6cb
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Liang Qi <liang.qi@qt.io>
2021-12-06 15:41:33 +01:00
Morten Johan Sørvig
fd0ef140cf wasm: make the compositor draw the window icon
Currently the compositor draws the Qt logo by default;
check if the window has an icon and draw that instead
if set.

Fixes: QTBUG-86052
Pick-to: 6.2
Change-Id: Ia4f9c03562c15993c86cb8717f27e47ab669353d





Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2021-12-06 14:42:45 +01:00
Giuseppe D'Angelo
ad5c5bb541 qBound: add an assert on !(upper < lower)
It's a precondition and we might just as well check it, given that
people have actually got the order of the arguments wrong (cf.
QTBUG-69330).

Unfortunately, Q_ASSERT is defined below qBound in qglobal.h, so I had
to reshuffle some code around.

Change-Id: I82e52bcb863ff8c96594817e0cd5d7d2abe2e57e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-12-06 12:28:41 +01:00
Giuseppe D'Angelo
19072a177b QPageLayout: do not calculate an invalid margin
A default constructed QPageLayout has an invalid QPageSize. When
asking for its size, an invalid QSize is returned (-1, -1). This
size is then used to calculate the maximum margins the page layout
can have, resulting in negative margins.

I'm not sure if that makes sense for QPageLayout (in principle, a
negative margin is acceptable, meaning to "grow" the size), but then
this margin is passed as an upper bound to a series of qBound calls in
QPageLayoutPrivate::clampMargins.

To fix this, change the calculations of the maximum margins by using
a lower bound of 0.

Change-Id: I429104acfb2296d9eb1ee54c113e9d7e22d9b6ab
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-12-06 12:28:41 +01:00
Giuseppe D'Angelo
212b7614e1 QListView: fix a broken qBound
If a QListView's model is reset to an empty one, its columnCount()
below the root is going to be 0. Therefore, the code was doing a

  qBound(0, d->column, -1)

which is meaningless (high < low). Instead, do the two logical
operations explicitly: first do an upper bound on d->column
(using qMin) and then lower bound the result by 0 (using qMax).

The code worked by chance, because 0 was eventually the correct
number to use as a bound for d->column.

Change-Id: Ic32077cdab01eaa715137c05ed1f9d66c8eb2f67
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-12-06 12:28:41 +01:00
Kai Köhne
251e848007 Remove .prev_CMakeLists.txt
These are left-overs from the initial qmake2cmake conversion.

Pick-to: 6.2
Change-Id: Ie15c9ff022ea4566d10c1ba74599de9af83d29a7
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-12-06 11:23:26 +00:00
Shawn Rutledge
af987c1bde doc: Add details about what to use instead of QMouseEvent::source()
Pick-to: 6.2
Fixes: QTBUG-98875
Change-Id: I2678edccf68d754d191b9eb6cdfe09bba327e85a
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-12-04 12:23:51 +00:00
Tor Arne Vestbø
b89608dcf8 Document which header to include for the various native interfaces
Fixes: QTBUG-98654
Pick-to: 6.2
Change-Id: Ic5ea3cc7d90ed336a5b6e827d1523bdd58fabc13
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-12-04 12:41:46 +01:00
Mårten Nordheim
cdc3de6c84 QStringBuilder: Add support for QByteArrayView
[ChangeLog][QtCore][QStringBuilder] Added support for QByteArrayView.

Change-Id: If2c23549d533dd31c320f3ee455fcd01ea5b460a
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2021-12-04 08:21:22 +00:00
Mårten Nordheim
9909ec0bc6 QNAM: Reintroduce h2c with an attribute
[ChangeLog][QtNetwork][QNetworkRequest] Added
QNetworkRequest::Http2CleartextAllowedAttribute which controls whether
HTTP/2 cleartext (h2c) is allowed or not. The default is false. This
replaces the QT_NETWORK_H2C_ALLOWED environment variable.

Task-number: QTBUG-98642
Change-Id: I43ae1cc671788f6d2559cd316f6667b412c8e75e
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-12-04 08:20:52 +00:00
Ievgenii Meshcheriakov
83f2f27bb6 QFile: Add open() overload that accepts permissions argument
The new overload allows creation of files with non-default permissions.
This is useful when files need to be created with more restrictive
permissions than the default ones, and removes the time window when
such files are available with less restrictive permissions.

[ChangeLog][QtCore][QFile] Added QDir::open() overload that
accepts permissions argument.

Fixes: QTBUG-79750
Change-Id: Iddfced3c324e03f2c53f421c9b31c76dee82df58
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-12-04 01:27:11 +01:00
Ievgenii Meshcheriakov
56e13acf4e QAbstractFileEngine: Add permission argument to open()
The new argument allows atomic creation of files with non-default
permissions.

Task-number: QTBUG-79750
Change-Id: I4c49455b41f924ba87148302c8d0f77f5de0832b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-12-04 01:27:08 +01:00
Volker Hilsheimer
56bd1b76d2 Don't change resolve mask when setting brush doesn't change palette
After 556511f9f3, which moved the resolve
mask storage into the palette's d-pointer, modifying the resolve mask
requires a detach. As of now, we only detached when setting a different
brush, but always modified the resolve mask, which broke palettes that
shared the d-pointer (likely the global default palette).

However, detaching has negative side effects when styles set brushes on
temporary palette objects and then use that palette object's cache key
to build a cache of pixmaps. As each drawing would detach the palette
(even if the palette doesn't change, which is likely), the cache key
changes with each detach, and the cache would quickly increase in size.
This was addressed in changes d7bcdc3a44
and 1e75dcf251.

We can either detach and find other ways to address the issues from
QTBUG-65475, or we can not change the resolve mask when the brush doesn't
change and completely ignore the call.

Since QFont ignores the setting of any attribute to a value that is
identical to the current value, and since it's possible to force that
the resolve-bit is set by calling setBrush twice with different brushes,
ignoring the call seems like the better solution.

[ChangeLog][QtGui][QPalette] Setting a brush on a palette that is
identical to the current brush no longer sets the resolve mask bit for
that particular role, so items using the palette will continue to
inherit changes from parent items.

Fixes: QTBUG-98762
Task-number: QTBUG-65475
Pick-to: 6.2
Change-Id: Ife0f934b6a066858408ef75b7bb7ab61193ceb47
Reviewed-by: Simon Hausmann <hausmann@gmail.com>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-12-03 21:07:09 +01:00
Albert Astals Cid
98c2260c3b Add QFontComboBox::setDisplayFont
Allows changing the font used to display a font family

[ChangeLog][QtWidgets][QFontComboBox] Added the setDisplayFont() function, in order to be able to control the font used to render the font name and sample text (when previewing the fonts).

Change-Id: I94bfef43142c5346237e3069449bd19dbacb7420
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-12-03 20:35:33 +01:00
Albert Astals Cid
63c0a1bd23 Add QFontComboBox::setSampleText
Allows setting the sample text to be used

[ChangeLog][QtWidgets][QFontComboBox] Added the setSampleText() function, in order to be able to control the sample text displayed by the combobox (when previewing the fonts).

Change-Id: Iedcd3bb72bc6aec9a178f14f7fbbe324ba0223ef
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-12-03 20:35:33 +01:00
Kai Köhne
6598a26a13 androiddeployqt: Fix signing of paths with spaces
Only use shellQuote() if the path is actually passed to a native API.
For QFile API, use the unquoted path.

Fixes: QTBUG-97649
Pick-to: 5.15 6.2
Change-Id: I9d8131819010bbd2faa8a81eef367245d90a767f
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2021-12-03 15:09:26 +00:00
Andrei Golubev
08b0a63a0f QFontDatabase: unify relevant documentation pieces
addApplicationFont and addApplicationFontFromData basically do the same
thing (with one reading the data from a file and another reading
it directly from QByteArray)

The documentation is not quite identical, so fix that by using \include
magic of qdoc

As a drive-by, remove outdated \note within addApplicationFont() description

Fixes: QTBUG-98752
Pick-to: 5.15 6.2
Change-Id: I29738e7411d241c26a4b2e1dd91d0af867fcc111
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-12-03 12:57:39 +00:00
Marc Mutz
020191d2ef QLayoutPolicy: fix annoying -Wdeprecated-enum-enum-conversion
Says GCC -std=c++20:

    src/gui/util/qlayoutpolicy_p.h:127:30: warning: bitwise operation between different enumeration types ‘QLayoutPolicy::Policy’ and ‘QLayoutPolicy::PolicyFlag’ is deprecated [-Wdeprecated-enum-enum-conversion]
      127 |         if (verticalPolicy() & ExpandFlag)
          |             ~~~~~~~~~~~~~~~~~^~~~~~~~~~~~

Fix by making Policy a QFlags<PolicyFlag>, which we can do because the
class is private. In QSizePolicy, this would break BC.

Since a QFlags cannot be opened for constants like an enum, we need to
define the ex-Policy-enumerators as static inline constexpr objects
instead.

Pick-to: 6.2
Change-Id: I29bc938f86508deed3f99ad9d1c1892547206c05
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-12-03 12:57:39 +00:00
Marc Mutz
2d2104da7c QSizePolicy: make qHash() a hidden friend
Less noisy compiler error messages.

[ChangeLog][Potentially Source-Incompatible Changes][QSizePolicy]
qHash() is now a hidden friend and can only be called by unqualified
(qHash(sp)), not by qualified lookup (as in, say, ::qHash(sp) or
QT_PREPEND_NAMESPACE(qHash)(sp)).

Task-number: QTBUG-98863
Change-Id: I37d26c661c2d8bb74350eb9378bd19fa426678d2
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-12-03 12:57:39 +00:00
Assam Boudjelthia
f1c2b6f5f9 Android: add methods to get the FileDescriptor for a Uri
This can be useful for some cases when the Android APIs have calls
that expects a FileDescriptor instead of a Uri or an int file
descriptor (like a case in Qt Multimedia with MediaRecorder).

Pick-to: 6.2
Task-number: QTBUG-96081
Task-number: QTBUG-96957
Change-Id: I0ab8d37a43b7cb94f6ebb5d48014e5a7903aadc7
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
2021-12-03 14:19:21 +02:00
Assam Boudjelthia
be55118bd3 Android: simplifications to exception messages for content file handling
The method getUriWithValidPermission() now returns null only if the
Uri couldn't be parsed, otherwise, returns the parsed Uri and fail later
when used if it doesn't have permissions for example.

Also, Don't use use hardcoded strings for method names, and print the
exception message instead of the whole stack.

Pick-to: 6.2
Task-number: QTBUG-96081
Task-number: QTBUG-96957
Change-Id: If7ba88265c9683e6660cb483cfee6c22016f2976
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
2021-12-03 12:19:21 +00:00
Volker Hilsheimer
c034ad03ac QPA: Set focus reason when window activation changes focus
QApplication hides the fact that the reason is never set by several
QPA plugins, but Quick items don't receive the correct reason on
Windows, Android, the offscreen plugin, and other platforms.

Add relevant scenario to the QFocusEvent test case, and fix the
plugins to always set the focus reason when handling window activation
changes. Exclude the minimal plugin from the test, it seems largely
unmaintained anyway.

Task-number: QTBUG-75862
Change-Id: I5404a225b387fc9a3851b6968d0777c687127ed1
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-12-03 08:15:29 +01:00
ChunLin Wang
8e465c75fe Repair parameter type
Fix the parameter types corresponding to the sample code and subclasses

Fixes: QTBUG-98578
Pick-to: 6.2
Change-Id: I06e342ae1210ed53c5deec3e2711457cf2ac5b15
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-03 11:52:21 +08:00
Marc Mutz
d06a686cad Remove unused Q_DECLARE_SHARED_NOT_MOVABLE_UNTIL_QT6
There are no users left in the tree.

Change-Id: I336f4e15c0ec1f5933c1fcfa661bad85bd38ed35
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-03 03:42:01 +01:00
Inho Lee
ac2f4bd9db Remove XCB_EVENT_MASK_RESIZE_REDIRECT for Qt:WindowTransparentForInput
In xcb plugin, XCB_EVENT_MASK_RESIZE_REDIRECT is set but it is not
necessary. Mouse events are disabled by setTransparentForMouseEvents
and there is no reason to have this event mask.

Fixes: QTBUG-86372
Pick-to: 6.2 5.15
Change-Id: I2124b0684a0847d6705344bb5850bac178a292b6
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-12-03 00:22:49 +01:00
Shawn Rutledge
dbb9579566 Text editing: smart block and char format after newline
When you are editing in a QTextEdit and press enter to start a new line,
calling insertBlock() with no arguments tries to preserve the current
charFormat and blockFormat. That is often OK:
- if you hit enter at the end of a list item, you probably want another
  item in the same list
- if you are writing code inside a code block, you're probably just
  writing the next statement on the next line: stay in the same block
- margins, indents, tab positions should stay the same (but hopefully
  your editor has UI to manually reset the block format to default
  in case you are not continuing in the same style)
But there are some exceptions we can apply to be helpful:
- nobody ever wants to follow an <hr/> with another one (but
  hopefully the application has an action to insert one manually)
- a heading is more likely to be followed by a paragraph, or perhaps
  a smaller heading; another heading at the same level is unlikely.
  We need to reset the char format, not only the block format, because
  the large font and heavy font weight are stored there.
- when adding to a todo list, hitting enter at the end of the last task,
  let's assume the next task is not yet done, so it will be unchecked
  by default (else, why are you writing a todo list at all)
To achieve that, we need to customize the formats and call the
insertBlock() overload that takes them. The no-argument insertBlock()
will continue to preserve the formats, because it's an old API that is
used for much more than interactive editing.

Additionally, word processors tend to let you end a list (for example)
by hitting enter twice. In that case, you stay in the same paragraph
that you created the first time you hit enter, but now the formats are
reset to default, so that you can go on typing an ordinary paragraph,
rather than having to mouse up to the toolbar to select the paragraph
style in a combobox, or something like that. So we now do that: reset
both block and char formats after you hit enter on a blank line; but if
you then hit enter again, after the block format has been reset, then
you will get the actual blank line (empty block) inserted.

[ChangeLog][QtWidgets][QTextEdit] Hitting enter at the end of a line
with a special block format (horizontal rule, heading, checklist item)
now makes some "smart" adjustments to avoid retaining properties that
are unlikely to be continued on the next line. Hitting enter twice now
resets block and char formats to default.

Fixes: QTBUG-48815
Task-number: QTBUG-80473
Fixes: QTBUG-97459
Change-Id: I3dfdd5b4c0d9ffb4673acc861cb7b5c22291df25
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-12-02 22:22:59 +01:00
Mårten Nordheim
a6744bc9f9 OpenSSL: handle renegotiate errors by comparing certs
If the certificate didn't change then our trust in it didn't either.
Sadly, cannot have an autotest because we don't have any way
to facilitate a renegotiation at the moment and with TLS 1.3
not having them at all it's unlikely we ever will.

Pick-to: 6.2 5.15
Task-number: QTBUG-92231
Change-Id: Ibaa9b2f627daca05021c574e69526710aacdadae
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-12-02 19:29:58 +00:00
Michał Cieślak
02955a10fa Use Android's View.generateViewId() for generating ids for views/surfaces
Qt Android was using consecutive numbers starting from 1 as ids for View.setId(int). The ids are used internally with an assumption that they are unique. It was potentially leading to collisions and unexpected behavior when adding custom views with id generated by View.generateViewId().

Task-number: QTBUG-98649
Pick-to: 5.15 6.2
Change-Id: I5bf2fe1d196c7adafeec544d8d945ebd82ba5cb6
Reviewed-by: Rami Potinkara <rami.potinkara@qt.io>
Reviewed-by: Ville Voutilainen <ville.voutilainen@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2021-12-02 19:09:40 +01:00
Edward Welbourne
24e4370414 Close leak of QOCIDateTime object
Noticed while reviewing usage of this type. The code has a whole
TempStorage class to take care of keeping allocated memory live until
we're done with it, explicitly including date-time objects as a
special case, but neglected to use it in one place.

Pick-to: 6.2 5.15
Change-Id: Ic94c56d67dda6dc3ee36a025a2e0149f6b2a1837
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2021-12-02 17:38:33 +01:00
Edward Welbourne
4ef8e9427c Reduce scope of a hack using volatile in favor of viewAt()
We can now get qt_configure_strs to tell us the size of the string, as
well as its start, bypassing the strlen()-calling branch of
fromLocal8Bit() that caused the need for a hack using a volatile
variable. However, QT_CONFIGURE_SETTINGS_PATH still needs the volatile
hack.

Change-Id: I0181abf512123e6355acdd506d6845c3fb75c0e3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-02 17:38:33 +01:00
Edward Welbourne
4d4aa6e21c Restrict clang warning disabler to affected versions
Apparently -Wdeprecated-copy got added between clang 9 and 11.
Versions without it warn about the attempt to suppress this option's
warnings.

This follows-up on commit 8662fbdd7e

Change-Id: I7fe9258cfe8a79d24c1f8b331a56468415b25cdb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-12-02 17:38:33 +01:00
Jonas Kvinge
a817490335 qnx: Fix typos in source code comments
Change-Id: I6420e14e3de9c7efc7d5073f44ccfd7ee9b88ea6
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2021-12-02 18:38:33 +02:00
Jonas Kvinge
5d08806adf android: Fix typo in source code comment
Change-Id: Ieeab35d51588cf247c3d9626d0291e2983720873
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2021-12-02 18:38:33 +02:00
Marc Mutz
ecc307ff41 QString et al: fix lastIndexOf() API asymmetry
Commit 6cee204d56 introduced overloads
of lastIndexOf() which drop the 'from' argument, inadvertently fixing
QTBUG-80694, but failed to provide the new overloads for all existing
lastIndexOf() overloads, making the fix for QTBUG-80694 incomplete.

This patch completes the fix, by adding the missing overloads (for
char-likes) and also adds the missing (non-regex) tests to
tst_qstringapisymmetry.

Also amends 1c164ec7f2.

Fixes: QTBUG-80694
Change-Id: Ib4b3d597d658ce2edf01a2bce0d711ecea593d6e
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-02 16:05:33 +00:00
Elvis Lee
093a62a69a Support to get timing from pagefilp
Handle the timing from drmEvent when page flip finished.
The information can be used to optimize rendering timing.

Change-Id: I14612ca48a8fea5208aa74949d7543787e860c5f
Reviewed-by: Elvis Lee <kwangwoong.lee@lge.com>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2021-12-03 01:05:33 +09:00
Alexey Edelev
63b8840380 Fix dependency chain that collects the metatype json files
cmake_automoc_parser has the logic preventing the run of moc with the
--collect-json parameter if metatype json files are not changed.
This logic only verify if the file list is changed but not their
content. This change adds a timestamp file that contains the last
metatype json file timestamp that was modified during the last
cmake_automoc_parser run. The logic still prevents of running
'moc --collect-json' when the list of metatype json files is not
changed, but also checks if their content is no changed.

Another approach it to generate the depfile that can be utilized by
CMake in add_custom_command as DEPFILE argument. But this concept only
works from the second build attempt because of an issue related to
dyndep.

Pick-to: 6.2
Fixes: QTBUG-98532
Change-Id: I713f8bfa9ae769cefe0beac0b7fa19750b00a765
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-12-02 16:34:23 +01:00
Alexey Edelev
7a6dd6084c Replace BUILD_OPTIONS_LIST variable by the getter function
Encapsulate configuration options in a function and use it instead of
a globally defined variable.

Pick-to: 6.2
Change-Id: I5c69c207788fe069fdd046b68a6bc58aa16e71b4
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-12-02 16:34:22 +01:00
Volker Hilsheimer
d22bafe355 QTableView: correctly toggle column selection when scrolled
We need to check whether the horizontal header's selection includes the
index for the row at the top, rather than for row 0, as the index we
check is based on the scrolled position of the header, so would never be
included in the top row when the view is scrolled. This is correctly
done in selectRow already.

Add a test case that simulates selection of rows and columns by clicking
on the header.

Fixes: QTBUG-98444
Pick-to: 6.2
Change-Id: I2fa1b32bf75dc96225b40145b713bf7e2ffc29dd
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-12-02 14:16:49 +00:00
Volker Hilsheimer
97cfd49401 Don't let text table cells shrink below their minimum width
We calculate the minimum width, but then use it only to make sure that
the maximum width is at least as large as it. Without setting the layout
struct's minimumWidth as well, table cells can be smaller.

Add a test case.

Fixes: QTBUG-86671
Fixes: QTBUG-97463
Pick-to: 6.2 5.15
Change-Id: Idf4ad015938abb8d3e599e9a58e002f29c0067be
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2021-12-02 15:16:49 +01:00
Alexey Edelev
6b025f9b27 Use depfile to control ABI-specific builds of executable targets
qt_internal_${target}_copy_apk_dependencies should use CMake DEPFILE
approach when it's possible. Since we don't have any specific
artifact that androiddeployqt can produce when collecting dependencies
this change adds simple timestamp file that is touched each time when
androiddeployqt is running. The timestamp is used then as a file-level
dependency for the qt_internal_${target}_copy_apk_dependencies target.

Task-number: QTBUG-88841
Change-Id: I985535c7b6e471cb4cfbf90128628087dadc72d0
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-12-02 14:28:09 +01:00
Alexey Edelev
87db26bdfe Change the external projects approach for multi-abi builds
Instead of generating external projects that build the project tree
for each target, this creates a single project for each ABI that have
the common for all targets configure steps. Each executable target
then adds additional build step to each ABI-specific external project,
that builds and copies dependencies to the "main" project build tree.

To resolve dependencies from the build tree, when building multi-abi
apk instead of scanning the build directories of external projects for
dependencies, it makes sense to run androiddeployqt for each
ABI-specific external project to copy all necessary libraries. This
is done by adding --copy-dependencies-only flag to androiddeployqt
that only copies the apk dependencies, but avoids creating apk and all
the essential steps. The ABI-specific external project now handles the
deploying of the build artifacts to the end-point apk deployment
directory and the "main" project assembles the apk using collected
artifacts. The ABI-specific external project uses the
qt_internal_${target}_copy_apk_dependencies target to run androiddeployqt
with the introduced --copy-dependencies-only flag.

TODO: Build steps that build and copy the ABI-specific apk
dependencies are non-skipable and will run each time top-level build
is triggered. This behavior should be fixed by adding dependencies to
the generated by androiddeployqt DEPFILES for each ABI in the
top-level build.

Task-number: QTBUG-88841
Tash-number: QTBUG-94714
Change-Id: Id442a9fbd589f58b70f4204c5215645056b379a2
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-12-02 14:28:09 +01:00
Mårten Nordheim
0062f5a208 Freetype: adjust underlinePosition to match our expectations
We expect underlinePosition() to be the topleft corner of where we
start drawing the underline but freetype reports the _center_ of the
underline:

"underline_position: [...]. It is the center of the underlining stem."
- https://freetype.org/freetype2/docs/reference/ft2-base_interface.html

Pick-to: 6.2 5.15
Fixes: QTBUG-62602
Change-Id: I96808816f50f3f37b18f579adf285502c88e6ea5
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-12-02 12:53:34 +01:00
Sona Kurazyan
022891bcd8 Document the example showing the benefits of using bindable properties
And mention the example in the bindable properties docs.

Pick-to: 6.2
Task-number: QTBUG-97655
Change-Id: I676e90dbda66c2e718c7f6c2240fac608a8653df
Reviewed-by: Leena Miettinen <riitta-leena.miettinen@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-12-02 12:53:34 +01:00
Eskil Abrahamsen Blomfeldt
6b02473e1e Fix overlapping text for Osaka font on macOS
The Osaka font on macOS has all zeroes in the OS/2 table, probably
because it is not intended to be cross-platform. In Qt 6 (since
f761ad3cd9) we are trying using the
same vertical metrics on all platforms, but this only works if
they are valid.

To work around this issue, we detect the case when ascent/descent
values are both 0, since this is very unlikely to be intentional,
so we fall back to the system-provided ascent and descent in these
cases.

Adding the test also revealed that we had missed the check for
a macOS-specific bitmap font format when skipping the check for
bitmap fonts in 7a18b7e2c2.

[ChangeLog][macOS][Text] Fixed a problem where using the Osaka
font would lead to overlapping text.

Pick-to: 6.2
Fixes: QTBUG-96880
Change-Id: Ifea7918641a68829e8f5ef20a4fb61c0a7e5b757
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-12-02 07:54:39 +01:00
Zhang Yu
c6c039167c Fix fail to activate first sub window with QMdiArea::TabbedView
The first sub window added will activate itself automatically, and
isActive is set to true. Therefore the call to setActiveSubWindow to
activate the first sub window will be ignored.

When showing the mdiarea, all sub windows will be activated in the order
in which they were added, so the active window will always be the last
sub window added.

Fix this by setting isActive to false so that setActiveSubWindow
activates the first sub window when the mdiarea becomes active.

Fixes: QTBUG-92037
Pick-to: 6.2
Change-Id: Id4a793e2059803c1a4ada916fdae2d3cc02cdf06
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-12-02 09:08:40 +08:00
Marc Mutz
f814241abe QVarLengthArray: make static if's constexpr
Cleaner. Probably also more efficient at compile time, who knows?

Also more consistent, since _some_ static if's were already
constexpr'ed.

Change-Id: I9657f7cf2166975f562db52e9f90630aaf412986
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-12-02 01:01:56 +01:00
Eskil Abrahamsen Blomfeldt
bda75c81f5 Fix missing characters or assert with certain font sizes
The alphaMapBoundingBox() only exists to prefetch the size
of rendered alpha maps, to reserve space in the glyph cache.
Since 104e6d0f54 we have not
used the QPainterPath fallback code path when actually
rendering the glyphs, but that patch neglected to update the
code that retrieved the bounding box.

This could in some cases cause a mismatch, and if the alpha
map we ended up with in the end was larger than the reserved
space, this could trigger an assert or an empty spot in the
cache.

[ChangeLog][Text][Freetype] Fixed an issue where characters
would in some rare cases be missing from text, depending on
font metrics, font size and system scale factor.

Pick-to: 5.15 6.2
Fixes: QTBUG-86633
Change-Id: Ic8ade168115e4f51bac71539325936bbae993120
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-12-01 21:48:49 +01:00
Volker Hilsheimer
9538c7ca73 Don't shrink a column when it spans multiple columns
If a cell spans multiple columns, then the merged cells' starting
column's maximum width should never become smaller than what was
calculated from previous rows.

Otherwise, we'd distribute the space of the column that has a span
across all merged columns, resulting in unnecessary line breaks esp if
WrapAnywhere is enabled.

Add a test case.

Fixes: QTBUG-91691
Fixes: QTBUG-95240
Pick-to: 6.2 5.15
Change-Id: Ic27dbdb128071e50fba049de85c9f23ba2f059b3
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2021-12-01 21:23:05 +01:00
Marc Mutz
147093edd9 QVarLengthArray: More Self-Encapsulate Field
Two more instances where we can use public API instead of accessing the data members directly.

Amends 9d79e5f26c.

Task-number: QTBUG-84785
Change-Id: I2037339383836b0d292b3362fe1d6b056638e81a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-12-01 15:03:34 +01:00
Giuseppe D'Angelo
e977b55346 QTabBar: clamp maxScrollOffset before using it in qBound
QTabBar's test reveals that maxScrollOffset can be negative, so
using it in a call like

  qBound(0, x, maxScrollOffset)

is wrong. Clamp it to 0.

Change-Id: Idd635343bf14c904dbcc4d141f10bd0161d2cfb4
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-12-01 15:03:34 +01:00
Tor Arne Vestbø
d281274c3f Don't overwrite flipped textureTransform with unflipped on next blit
The logic introduced in 60d9509cb0 didn't
account for the fact that repeated blits with OriginTopLeft would only
hit the code path that modified the source transform to flip it if the
uniform state wasn't already IdentityFlipped.

As a result, we would end up setting the unflipped texture transform
on the next blit, even though the origin was still OriginTopLeft.

Fixes: QTBUG-98803
Change-Id: Ib19e80e026acaa43981077b98ff942a7fa060378
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-12-01 15:03:34 +01:00
Alexey Edelev
a88b53f713 Use config from the main ABI when building ABI-specific external project
ABI-specific external projects should use the same config as the one is
used by the "main" ABI.

Task-number: QTBUG-88841
Change-Id: If7a1834d9a3f238f6dadd05323ccc0cf8552128c
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-12-01 07:28:58 +01:00
Lorn Potter
9a31dada02 wasm: Fix assert/crash when tooltip window is closed and mouse moved
Fixes: QTBUG-92521
Pick-to: 5.15 6.2
Change-Id: I627fdcf3064321a3c1cb1140473038571ec78b9e
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2021-12-01 12:28:27 +10:00
Sona Kurazyan
3be72253a6 Fix QFuture continuations/handlers to work with move-only callables
std::function, which is used to store the type-erased continuation
lambdas, requires the passed callable to be copy-constructible. This
makes impossible to use move-only callables with continuations/handlers.
In particular, it makes impossible passing lambdas that are capturing
move-only objects. The workaround is to store the continuation lambda
inside a wrapper for the callable, which stores the move-only lambda in
a QSharedPtr and can be stored in std::function, since it's copyable.

Pick-to: 6.2
Fixes: QTBUG-98493
Change-Id: I8b7a22fcf68dc132b3c533216a7a1665e9f9fb0a
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-12-01 01:58:18 +01:00
Marc Mutz
1a61b85a2c QVarLengthArray: simplify default ctor
Instead of calling the QVLA(qsizetype) ctor and letting the optimizer
and inliner have a field day on them, simply set the trivial values
for a, s, and ptr manually.

Mark it as noexcept.

Task-number: QTBUG-84785
Change-Id: I011826eacdaf63a4c37b21465e5fe4a6e70a1ab7
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-12-01 00:20:25 +01:00
Mårten Nordheim
c891382900 Openssl backend: reinsert a missing C in qCDebug
Pick-to: 6.2 5.15
Change-Id: I2b13d2f88517abea7e015bfba4fe71dcbada86c0
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2021-12-01 00:20:25 +01:00
Alexey Edelev
34fc4770e7 Fix the path to the build dir when creating an androiddeployqt depfile
According to the CMake documentation any relative paths in DEPFILE
should be relative to the CMAKE_CURRENT_BINARY_DIR if the CMP0116
is set to NEW. This also forces CMP0116 to NEW if the policy exists.

Pick-to: 6.2
Change-Id: I3d697b008ea06effb2247bc204da9bcc4e9046b4
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-11-30 20:16:13 +01:00
Alexey Edelev
d162ce3732 Add _make_aab target
Add target triggering AAB creation. Since the _make_aab target is
not added to the ALL set, we may avoid dependency check for it and
admit that the target is "always out of date".

[ChangeLog][Android][Platform Specific Changes] Add the extra
_make_aab targets for each executable target, that can be used
to generate android app bundles. Also add aab metatarget to build
all _make_aab targets that are created in the project.

Pick-to: 6.2
Fixes: QTBUG-96710
Change-Id: I3b0c7fbb5a7dd493ca7a124c4e4b91fd857386bd
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-11-30 20:16:13 +01:00
Giuseppe D'Angelo
54536bb5ae QString::arg: deprecate use of arbitrary Unicode digits as replacements
The only documented replacements for Q*String*::arg() are sequences like
%1, %2, %3 -- where the n-th number is expressed using a sequence of
ASCII digits [1].

The code parsing the replacements however used the QChar::digitValue()
function. That function simply checks if a QChar has a *Unicode digit
value* (no matter what its block/category is), and if so, returns the
corresponding digit value as an int (otherwise returns -1).

The result of this is that a sequence like "%¹" or "%१" actually
triggered substitutions (both count as "1"). Similarly, QChars with
a digit value would be parsed as part of longer sequences like "%1²"
(counting as "12" (!)).

This behavior is weird, undocumented, and extremely likely the usual
backstabbing by Unicode by using "convenience" QChar methods -- that is,
never *intended* by the implementation.

This commit deprecates (via warnings) such usages, which for the time
being are left working as before (in the name of backwards
compatibility). At the same time: given it's extremely unlikely that
someone would be deliberately relying on this behavior, it implements
the desired change of behavior (only accept sequences of ASCII digits)
starting from Qt 6.6, that is, after the next LTS.

Throughout Qt 6's lifetime users will still be able to control arg()'s
behavior by setting an env variable, but that variable (and the support
for Unicode digits) will disappear in Qt 7.

To summarize:

* Qt 6.3->6.5: default is Unicode digits, env var to control
* Qt 6.6->6.x: default is ASCII digits, env var to control
* Qt 7: only ASCII digits, no env var

[1] That's the name Unicode gives to them, cf. https://www.unicode.org/charts/PDF/U0000.pdf

[ChangeLog][QtCore][Deprecation Notices] The arg() functions
featured in Qt string classes have always been documented to require
replacements tokens to be sequences of ASCII digits (like %1, %2, %34,
and so on). A coding oversight made it accept sequences of arbitrary
characters with a Unicode digit value instead. For instance, "%2੩" is
interpreted as the 23rd substitution; and "%1²" is interpreted as the
12th substitution. This behavior is deprecated, and will result in
runtime warnings. Starting from Qt 6.6, arg()'s behavior will be changed
to accept only ASCII digits by default. That means that "%1²" is going
to be interpreted as substitution number 1 followed by the "²" character
(which does not get substituted, so it gets left as-is in the result).
Users can restore the previous semantics (accept Unicode digits) by
setting the QT_USE_UNICODE_DIGIT_VALUES_IN_STRING_ARG environment
variable to a non-zero value. In Qt 7, arg() will only support sequences
of ASCII digits. Note that from Qt 6.3 users can also set
QT_USE_UNICODE_DIGIT_VALUES_IN_STRING_ARG to zero; this will make arg()
use ASCII digits only, in preparation for the future change of defaults.

Change-Id: I8a044b629bcca6996e76018c9faf7c6748ae04e8
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-11-30 19:33:34 +02:00
Edward Welbourne
064c3d35e6 Don't allocate an OCIDateTime object unless we're going to use it
The QOCIDateTime destructor carefully checks that dateTime is non-null
before tidying it away, but the constructor allocated it independently
of whether it was used, leaving it in a still-not-constructed state if
the date-time it was to represent was invalid.

Only allocate if the date-time is valid; and check against null when
an OCIDateTime is being converted back to QDateTime. Add warnings if
either allocation or construction fails. Incidentally use
static_cast<> instead of C-casting (and split a long line) in the
other place that allocates an OCIDateTime descriptor.

Pick-to: 6.2 5.15
Task-number: QTBUG-98471
Change-Id: Idd5531d9f7101878802cb9a3a016d3fd80903543
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-11-30 16:34:01 +01:00
Alexey Edelev
bcac7d9433 Use config-specific suffix of android deployment settings for multi-config only
QtCreator doesn't expect any config-specific suffixes in the android
deployment settings file, when running androiddeployqt. This avoids
adding the config-specific suffix in the single-config builds and
for the first config in the multi-config builds.

Amends a41d9bcac9

Change-Id: I606509c9bfd2e75cac144aca37b4568639aae74f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-11-30 16:32:10 +01:00
Janne Juntunen
2bfa4b9960 QNX: check and use elf.h from alternative location
In QNX, instead of #include <elf.h>, we have to use #include <sys/elf.h>
since that file is placed in a subdirectory.

Also removed the previous workaround.

Fixes: QTBUG-97833
Change-Id: Id932a5eeb618a42c8778459cdfd8bb5bf903523c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-30 14:37:52 +02:00
Edward Welbourne
b9f7add531 Verify returns from QXmlTestLogger's xmlQuote() and xmlCdata()
Using partially-converted text would lead to invalid XML, so don't use
the buffer contents if the return is zero. As a result,
QTestJUnitStreamer::formatEnd() needs to return some indication of
whether *it* succeeded, so change it to forward their int returns;
and, as it's in fact only used internally by the streamer, make it
private.

Make these functions [[nodiscard]] so that further uses of them will
be discouraged from ignoring the possibility of failure. Make the
public versions return bool so that they can correctly succeed on
empty input. Assert various conditions we can infer to save work we
don't need to do.

Change-Id: I899bad23d1dfbd05fc725de269def4ce213dbc5a
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-11-30 12:26:08 +01:00
Marc Mutz
0265b923ac QVarLengthArray: simplify copy ctor implementation
std::tie(a, s, ptr) = {Prealloc, 0, (T*)array} is exactly the effects
of the default ctor, so just delegate to it, before calling
copyAppend().

Also clean up the copy ctor declaration (superfluous inline keyword,
and template arguments).

Change-Id: Iefc758a47996382fee10b1e081e44f008b146287
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-30 06:38:40 +01:00
Thiago Macieira
6855b80eae QList::count(T): remove the &* hack on iterators
Use data() and data() + size() instead.

This solves an UB when the list is in its default-constructed state,
for which constData() == nullptr.

Pick-to: 6.2
Fixes: QTBUG-98770
Change-Id: I2cffe62afda945079b63fffd16bc165978c769f6
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2021-11-30 01:42:50 +00:00
Tor Arne Vestbø
60d9509cb0 Teach QOpenGLTextureBlitter about GL_TEXTURE_RECTANGLE textures
Change-Id: Ie577bda046f60ce23dfb8cdd6164bb3de4b54358
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2021-11-30 02:36:29 +01:00
Lorn Potter
0fa98a26fd wasm: add Blob and File type
Convenience getters for mime type associated with the object.

Change-Id: I7e3530459e50ac4740d533db59c46e838c94dbcd
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2021-11-30 09:06:54 +10:00
Marc Mutz
be84b033dc QRegularExpression: don't detach() a pattern QStringLiteral
... just to pass it to pcre2_compile_16().

The QString::utf16() function guarantees a NUL-terminated result, so
it detach()es from QStringLiteral (Qt 6) and/or QString::fromRawData()
(Qt 5 + 6).

This user doesn't require the NUL-termination, though, since
pcre2_compile_16() takes an explicit length, so the detach() is
completely unneccesary, yet common, since regex pattern strings are
often QStringLiteral()s.

Task-number: QTBUG-98763
Change-Id: I1d08ae1a1ec4281ff44a68c5ba5c56584b71d24e
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2021-11-30 00:04:38 +01:00
Mårten Nordheim
4c930e9d13 QNAM: Disable h2c by default
And since it's relatively unlikely to be used, just leave it
behind a environment variable for now.

[ChangeLog][QtNetwork][Potentially Source-Incompatible] Support for
clear-text http/2 was disabled due to incompatibility with certain
servers. If you were relying on this feature you must re-enable it by
setting the QT_NETWORK_ALLOW_H2C environment variable. For a later
version of Qt it will get a dedicated attribute.

Pick-to: 6.2
Task-number: QTBUG-98642
Change-Id: Id3e360726e285b3128e3e3f4bce9440404c9ad6e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Maximilian Goldstein <max.goldstein@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2021-11-30 00:04:38 +01:00
Marc Mutz
ccaeffe565 QT_SPECIALIZE_STD_HASH_TO_CALL_QHASH: use unqualified qHash() lookup
... instead of QT_PREPEND_NAMESPACE(qHash), which is qualified (prepends at least '::'), and therefore disables ADL.

This is not a problem as long as we wrote our qHash() overloads as free functions (incl. non-hidden friends), but it should™ fail for hidden friends, so use the old using-std::swap() trick to bring QT_PREPEND_NAMESPACE(qHash) into scope, proceeding with an unqualified lookup.

Pick-to: 6.2
Change-Id: I00860b2313699849f86bfe3dd9f41db4ce993cd3
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-29 18:55:10 +00:00
Eskil Abrahamsen Blomfeldt
793417ce75 Fix gaps between lines of selection
When a font has fractional metrics, we could get visible gaps
between lines in a multi-line selection, if the bottom of the
rect was not aligned to the pixel grid. In Qt 5, this was
primarily an issue on macOS, but since making vertical metrics
consistent in f761ad3cd9, we
could also get this on other platforms, causing a regression
on these platforms.

The fix is to align the rect to the pixel grid.

[ChangeLog][Text] Fixed an issue where there would sometimes be
visible gaps in selections spanning multiple lines.

Pick-to: 6.2
Fixes: QTBUG-98372
Change-Id: I03cb1465602b6d78c60a0c764d920f7f092418a8
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2021-11-29 16:25:38 +01:00
Volker Hilsheimer
56da533b45 Never handle scrollbars styled with box or border changes as transient
If scrollbars are styled with a style sheet that includes a box or
removes off the native border, then we never treat them as transient or
overlapping. Otherwise, the layout logic in QAbstractScrollArea will
show them on top of the viewport, overlapping the content.

Add case to the style sheet test baseline test. It's a test for
scrollbars in a scroll area, rather than a test for the styling of the
scrollbars themselves.

Fixes: QTBUG-98289
Pick-to: 6.2
Change-Id: Ic53ad248b3eedd54722ac7b2fe5256a27092dbc1
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2021-11-29 16:02:28 +01:00
Eirik Aavitsland
8fbedf2196 QTextDocument: fix an off-by-one in the changed signal for lists
When blocks are added or removed in block groups, i.e. items added or
removed from text lists, the whole group is marked as changed, but the
calculation of the before/after group length would be one off. That
was reflected in the contentsChange signal.

Add unit test. Since the whole group changes when list items are
added, text is removed and the change-begin is not where the cursor
was when the change was made.

Fixes: QTBUG-82455
Pick-to: 6.2 5.15
Change-Id: I99ee2cfef4944fcac8aca492741fd0f3b0de4920
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2021-11-29 13:25:31 +01:00
Liang Qi
143f20692e gui: add QInputDevice::seatNames()
Change-Id: Ie6cedd62dcd684a8fd9adbc2409e5aa1f3490ede
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-11-28 13:15:00 +02:00
Thiago Macieira
0e72a846d3 QObject: Q_ASSERT the object type before calling a PMF
The old-syle signal-slot syntax had the advantage of not delivering
signals to slots in derived classes after that derived class's
destructor had finished running (because we called via the virtual
qt_metacall). The new syntax made no checks, so a conversion from the
old to the new syntax may introduce crashes or other data corruptions at
runtime if the destructor had completed.

This commit introduces a Q_ASSERT to print the class name that the
object is not any more. Since this is in inline code, this should get
enabled for users' debug modes and does not therefore depend on Qt being
built in debug mode.

It required some Private classes to be adapted to the new form, by
exposing the public q_func() in the public: part.

Pick-to: 6.2
Fixes: QTBUG-33908
Change-Id: Iccb47e5527544b6fbd75fffd16b874cdc08c1f3e
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2021-11-27 21:38:22 -08:00
Thiago Macieira
b41356658e QLocale: suppress annoying GCC warning in the bootstrap lib
Happens on line:
        return QList<QLocale>() << QLocale(QLocale::C);

QLocale's constructor taking the C "language" calls findLocalePrivate()
that returns indeed the non-heap object c_locale in the c_private()
function. But it also sets the refcount to 1, meaning it can never drop
to 0 under proper refcounting and will thus never be deleted.

Therefore, the compiler is wrong. I don't have time to figure out how to
teach it that the deletion can never happen. I just want the warning to
go away. It wsa probably introduced by commit
d4242b8af3.

In destructor ‘QSharedDataPointer<T>::~QSharedDataPointer() [with T = QLocalePrivate]’,
    inlined from ‘QLocale::~QLocale()’ at /home/tjmaciei/src/qt/qt6/qtbase/src/corelib/text/qlocale.cpp:1035:1,
    inlined from ‘void QtPrivate::QMovableArrayOps<T>::emplace(qsizetype, Args&& ...) [with Args = {QLocale}; T = QLocale]’ at /home/tjmaciei/obj/qt/qt6/qtbase/include/QtCore/../../../../../../src/qt/qt6/qtbase/src/corelib/tools/qarraydataops.h:829:5,
    inlined from ‘T& QList<T>::emplaceBack(Args&& ...) [with Args = {QLocale}; T = QLocale]’ at /home/tjmaciei/obj/qt/qt6/qtbase/include/QtCore/../../../../../../src/qt/qt6/qtbase/src/corelib/tools/qlist.h:891:15,
    inlined from ‘void QList<T>::append(QList<T>::rvalue_ref) [with T = QLocale]’ at /home/tjmaciei/obj/qt/qt6/qtbase/include/QtCore/../../../../../../src/qt/qt6/qtbase/src/corelib/tools/qlist.h:479:24,
    inlined from ‘QList<T>& QList<T>::operator<<(QList<T>::rvalue_ref) [with T = QLocale]’ at /home/tjmaciei/obj/qt/qt6/qtbase/include/QtCore/../../../../../../src/qt/qt6/qtbase/src/corelib/tools/qlist.h:726:13,
    inlined from ‘static QList<QLocale> QLocale::matchingLocales(QLocale::Language, QLocale::Script, QLocale::Territory)’ at /home/tjmaciei/src/qt/qt6/qtbase/src/corelib/text/qlocale.cpp:2684:54:
/home/tjmaciei/obj/qt/qt6/qtbase/include/QtCore/../../../../../../src/qt/qt6/qtbase/src/corelib/tools/qshareddata.h:91:55: warning: ‘void operator delete(void*, std::size_t)’ called on unallocated object ‘c_locale’ [-Wfree-nonheap-object]
   91 |     ~QSharedDataPointer() { if (d && !d->ref.deref()) delete d; }
      |                                                       ^~~~~~~~

Pick-to: 6.2
Change-Id: Iccb47e5527544b6fbd75fffd16b8d078987b812b
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-11-27 19:10:52 -08:00
Marc Mutz
df663625af QLayoutPolicy: un-export the class
The class is almost completely inline. Don't export it wholesale, only
export the few out-of-line members.

Also acts as a test-case for the new Q_GADGET_EXPORT feature.

Task-number: QTBUG-55458
Change-Id: I699a774614183960d7ac4e0afcdb57cfef76db15
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-11-27 17:22:57 +01:00
Lorn Potter
820a6d4117 wasm: fix mouse move and right click
Emscripten has no concept of 'no mouse button', so when there
is no button down, it was sending left mouse.

Also we were hiding mousepress for only leftmouse downs.

Fixes: QTBUG-97431
Pick-to: 6.2
Change-Id: Ibf078705c343944e45551830b7fee94ed5aa7333
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2021-11-27 14:17:37 +10:00
Jarkko Koivikko
625cfb6b40 QGraphicsItem: Update input context after InputMethod event
Without updating the input context, the input method goes out of sync
with the text control.

Fix by updating the input context after InputMethod event.

Fixes: QTBUG-98544
Pick-to: 6.2 5.15
Change-Id: Idfb99bb0f886249cdab923b8dbed96277800c064
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-11-27 04:14:15 +02:00
Marc Mutz
23f980799d QSharedPointer: fix counter-productive QT_PREPEND_NAMESPACE use in qHash() impl
The qHash(QSharedPointer) implementation is already in QT_NAMESPACE,
if any, so explicitly qualifying the call adds no functions to the
overload set, but actually removes functions that would be found by ADL
(which is only enabled for unqualified calls).

Fix by using an unqualified call.

[ChangeLog][QtCore][QSharedPointer] The qHash(QSharedPointer<X>)
overload can now use qHash(X*) overloads found (only) through ADL
(was: ADL was disabled due to qualified lookup of qHash(X*)).

Pick-to: 6.2 5.15
Change-Id: Ic6cc47103142d48b6cdefa2cd6552a65cf1cb222
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-27 01:37:06 +00:00
Morten Johan Sørvig
24134d5193 wasm: Move Blob creation code to qstdweb
Add Uint8Array::copyFrom() and Blob::copyFrom(), which
constructs JS data containers with content copied from
the C heap.

These should not be confused with e.g. the Uint8Array(buffer, size)
constructor, which creates a Uint8Array which references
content on the heap, without making a copy.

Change-Id: Id7d25d8044ee3914d74698e5a15c93226568eaf3
Reviewed-by: David Skoland <david.skoland@qt.io>
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2021-11-27 01:13:12 +00:00
Marc Mutz
a0f9aef11b Long live Q_GADGET_EXPORT!
Like Q_NAMESPACE_EXPORT for Q_NAMESPACE, this variant of Q_GADGET
allows passing an export macro. This is useful to avoid exporting the
whole class just to get the staticMetaObject hidden therein exported.

Before anyone asks: No, we don't need Q_OBJECT_EXPORT, because QObject
subclasses, being polymorphic, always need to have a class-level
export macro (to export their vtable), but while that technique also
works for value classes (the Q_GADGET audience), it is not desirable
for them, because it makes inline functions exported in Windows debug
builds, which is not what we want, because it needlessly restricts
what you can to with the inline functions (e.g. remove).

[ChangeLog][QtCore] Added the Q_GADGET_EXPORT macro, which is like
Q_GADGET, but allows passing an export macro (like Q_NAMESPACE_EXPORT
for Q_NAMESPACE).

Fixes: QTBUG-55458
Change-Id: I546297de1e8aa45d83381991bcd3fbca61e1eef0
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-11-27 01:25:10 +01:00
Marc Mutz
cf2336ae6e QTest: fix grammar in static_assert()
Change-Id: I6fd408702bb43e37434b382cb6cb9057ca192064
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-27 01:25:09 +01:00
Fabian Kosmale
733bd81328 QThread::wait: Clarify documentation for unsigned long overload
It is not immediately clear from the signature that the time parameter's
unit is miliseconds.

Pick-to: 6.2
Change-Id: Ifee3c6410b6b2352e75571cc53578a660aabb32d
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-27 00:19:28 +01:00
Sona Kurazyan
722df970e8 Remove leftovers for supporting SAX-based implenentation of QDomDocument
QXmlDocumentLocator was introduced, so that QDomBuilder can work with
both QXmlStreamReader and QXmlInputSource. It had two subclasses -
QDomDocumentLocator and QSAXDocumentLocator, to allow getting line and
column numbers while parsing, depending on the implementation.
QSAXDocumentLocator was removed when removing SAX-based implementation
(79e0374143), and now it doesn't make
sense to keep QXmlDocumentLocator/QDomDocumentLocator, we can get line
and column numbers form QXmlStreamReader directly.

Change-Id: I75f4a776472ee31ddc3685a999f356be9bf47ac5
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-11-26 22:42:40 +01:00
Sona Kurazyan
086a08dcf9 Mention QtFuture::when* functions in QFuture's docs
Also fix an unrelated minor issue in QtFuture::whenAll docs.

Task-number: QTBUG-86714
Change-Id: I45f06b17db0508be10215e6d260ef76ede3077fb
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-26 22:40:54 +01:00
Marc Mutz
fd1a42490d QVarLengthArray: fix insert() type/alias mismatch between decl and impl
The declaration of insert(it, n, t) used qsizetype for n, while the
definition used size_type. That works by chance, because the size_type
typedef comes only after the insert(it, n, t) declaration. It was
detected when size_type became a typedef in a base class of
QVarLengthArray in my local branch.

Just use the same type name in the implementation as in the
declaration.

In 5.15, the same issue exists (with s/qsizetype/int/).

Pick-to: 6.2 5.15
Change-Id: I64235eeaeaed3d43f4c070ca536474fae94c1b5d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-26 19:51:12 +00:00
Friedemann Kleint
fac5b084a9 uic: Refactor CustomWidgetsInfo::extends() to use QAnyStringView
Task-number: PYSIDE-1720
Pick-to: 6.2
Change-Id: I2db4ee9586a87c70db08298e311d692e20a93af0
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2021-11-26 18:19:07 +00:00
Alexey Edelev
271ea6cd3e Simplify apk build procedure when using DEPFILE
In qt6_android_add_apk_target we require that ${target} is already
defined. So to add custom command that runs androiddeployqt we may
simply read BINARY_DIR property of the target and use it as path to
generated apk file as OUTPUT argument. This avoids the use any
intermediate paths when producing apk and related artifacts.

Change-Id: I8bb4174f6f9696e7a2a6b5d6399bb410419495fc
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-11-26 18:28:50 +01:00
Marc Mutz
ed343669f7 Long live QVERIFY_THROWS_NO_EXCEPTION!
Counter-part to QVERIFY_THROWS_EXCEPTION.

[ChangeLog][QTest] Added QVERIFY_THROWS_NO_EXCEPTION macro.

Change-Id: Ib6a80c8e810d5e2298ff00d608dae04e7a0c3e8f
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-11-26 18:28:50 +01:00
Luca Beldi
c27d2a57a4 Make QAbstractProxyModel itemData() behave like data()
QAbstractProxyModel::itemData/setItemData should behave
just like data()/setData() instead of calling the
QAbstractItemModel implementation.
Before this change the QAbstractProxyModel implementation
calls its the QAbstractItemModel implementation,
which ends up calling data()/setData() in a loop
bypassing the convenience of itemData/setItemData.

[ChangeLog][QtCore][QAbstractProxyModel] The itemData()
and setItemData() functions will now call the respective
implementations in the source model (after mapping the
index to a source index), matching what data() and
setData() already did.
Before, the proxy model simply called the default
implementations of itemData()/setItemData() in its own
base class (QAbstractItemModel).

Change-Id: I9e680d355f44fa130660dd7e1c8ac37484c1566e
Reviewed-by: David Faure <david.faure@kdab.com>
2021-11-26 17:12:07 +00:00
Laszlo Agocs
99644a9e94 rhi: metal: Ignore baseInstance if not supported
A previous patch already introduced calling the correct
variant of drawIndexedPrimitives, but it was not done
for drawPrimitives.

When base vertex and instance is not supported (e.g. on the iOS
simulator), it does not mean that the value cannot be other than
0, but rather that the version of the function taking this
arguments must not be called at all, otherwise a Metal failure
occurs. The docs and logic is all in place, just add it to
draw() as well.

Amends 213755a866 which fixed this
for indexed draw calls. Now we also prevent aborting Qt Quick
applications that trigger non-indexed draw calls.

Change-Id: Icb4313ffd2d3a77a73f7b5f49d7ce63c935254d3
Pick-to: 6.2
Task-number: QTBUG-95795
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-11-26 14:22:05 +01:00
Laszlo Agocs
c1899ca310 rhi: gl: Optimize context/surface changes
When there is a context with a surface current, keep on using
that whenever ensureContext() is called without specifying a
QWindow.

Consider the following sequence:
    <component A>
      beginOffscreenFrame
      render to texture 1
      endOffscreenFrame
    <component B>
      beginOffscreenFrame
      render to texture 2
      endOffscreenFrame
    <component C>
      beginFrame (with swapchain)
      render something using texture 1 and 2
      endFrame
    repeat all over again, continuously

(in practice this is what a top level widget with QOpenGLWidgets
and/or QQuickWidgets in it would lead to with the QRhi migration
in place)

Besides being more readable, the new version recognizes that resource
and offscreen operations do not need one specific surface (like the
one QOffscreenSurface every GL backend of QRhi has), but are functional
with any surface (or with surfaceless even) as long as the context is
correct. Thus with the above example we can work with only ever making
the one QWindow current.

Change-Id: I633071cae88f02e1d45e445ee55c8a58f9ec5a8c
Pick-to: 6.2
Fixes: QTBUG-96405
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2021-11-26 14:22:05 +01:00
Joerg Bornemann
20783c4170 CMake: Fix cross-compilation to Windows
...and potentially to macOS.

This amends 3f56950862.

Change-Id: Idf2acded37b59994459bc80ecda5733232f721f6
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-11-26 13:13:09 +01:00
Liang Qi
27c25fc909 xcb: stablilize xkb state when keymap updated
QXcbKeyboard only deals with core_device_id. With the reporter's test
case: using xdotool to send a string, the deviceID is not changed,
then we assume xkb_state_new() is more stable(or correct) than
xkb_x11_state_new_from_device() in this case.

See also https://www.x.org/releases/current/doc/man/man3/xcb_xkb_new_keyboard_notify_event_t.3.xhtml .

Fixes: QTBUG-95933
Pick-to: 6.2 5.15
Change-Id: Ic595e1f1424fbc6814871a85ac159907f1aeb12a
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Zhang Hao <zhanghao@uniontech.com>
Reviewed-by: Liang Qi <liang.qi@qt.io>
2021-11-26 12:00:06 +01:00
Morten Johan Sørvig
f92d4ffead wasm: Move streamFile() to qstdweb
This function is useful also outside of local file access,
for example when reading clipboard (file) content.

Change-Id: I132546deb6df2969467051c348c05d9331d2cfd2
Reviewed-by: David Skoland <david.skoland@qt.io>
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2021-11-26 10:04:31 +01:00
Marc Mutz
59600a514b QTest: de-inline QVERIFY_THROWS_EXCEPTION message formatting
Extract Method QTest::qCaught() to take the string handling out of the
header. This should help a bit in speeding up compilation of large
unit test files (provided they use QVERIFY_THROWS_EXCEPTION), although
I have no data to support that.

Since we changed the error message, update the selftest accordingly.

Change-Id: Id4a3c8c34d5df8d0c7a861106d269097f4a6de5c
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-11-26 09:57:59 +01:00
Volker Hilsheimer
77de4a9bb4 Fix and complete style sheet support for QToolButton
Amends 2b2e7b2ac5, which rewrote the
rendering to remove the conflation of menu arrows and arrow icons, but
introduced double rendering of the arrow icons if only the border was
styled.

Add a baseline test for style sheets, with a test function for
QToolButton configured in various ways and styled with different style
sheets.
The new test case includes a Qt 5 build system so that we can compare Qt
5.15 with Qt 6.

Fixes: QTBUG-98286
Pick-to: 6.2 6.2.2
Change-Id: I09cdc829c1a7e7913df4c3768dbe44b6dba4778b
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2021-11-26 09:36:07 +01:00
Yuhang Zhao
00ea6f58da d3d11rhi: remove leftover of pre-win10 code
Amends commit 1e085b9e15

Task-number: QTBUG-84432
Pick-to: 6.2
Change-Id: Id48fb6c2a9c7d24f1525975c6c154dbc323bbc25
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2021-11-26 13:06:24 +08:00
Mitch Curtis
efb283fb7f Add QTest::failOnWarning
This solves the long-standing problem of not being able to easily
fail a test when a certain warning is output.

[ChangeLog][QtTest] Added QTest::failOnWarning. When called in a test
function, any warning that matches the given pattern will cause a test
failure. The test will continue execution when a failure is added.
All patterns are cleared at the end of each test function.

Fixes: QTBUG-70029
Change-Id: I5763f8d4acf1cee8178be43a503619fbfb0f4f36
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-11-26 04:47:24 +01:00
Marc Mutz
1edf153a6b Long live QVERIFY_THROWS_EXCEPTION!
Use variable args macros to swallow any extra commas in the
expression. To use this, the type of the exception has to be first.
Use Eddy's suggestion for a new name to avoid breaking the old macro.

[ChangeLog][QtTest] Added QVERIFY_THROWS_EXCEPTION, replacing
QVERIFY_EXCEPTION_THROWN, which has therefore been deprecated.

Change-Id: I16825c35bae0631c5fad5a9a3ace4d6edc067f83
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-11-26 04:44:26 +01:00
Ievgenii Meshcheriakov
b9be035c62 QTemporaryDir: Set directory permissions at the time of creation
Use new QDir::mkdir() method to set directory permissions at the time
of its creation on systems that support this feature. This removes the
time window when the created directory is potentially accessible to
everybody.

Task-number: QTBUG-79750
Change-Id: I82afee7f0708bfdcc9b3b3978af9a2aef1b8672d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-26 03:39:33 +01:00
Ievgenii Meshcheriakov
174af05400 QDir: Add support for setting directory permissions to mkdir()
This patch adds an overload of the QDir::mkdir() method that
accepts permissions. This allows setting of the directory
permissions at the time of its creation.

[ChangeLog][QtCore][QDir] Added QDir::mdkir() overload that
accepts permissions argument.

Task-number: QTBUG-79750
Change-Id: Ic9db723b94ff0d2da6e0b819ac2e5d1f9a4e2049
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-26 03:39:33 +01:00
Giuseppe D'Angelo
8c9875893b Q(Multi)Map: prevent dangling key/value after detach()
Q(Multi)Map mutating functions that take reference to a key and/or a
value (e.g. insert(), take(), etc.) must make sure that those references
are still valid -- that is, that the referred objects are still alive --
after the detach() call done inside those functions.

In fact, if the key/value are references into *this, one must take extra
steps in order to preserve them across the detach().

Consider the scenario where one has two shallow copies of QMap, each
accessed by a different thread, and each thread calls a mutating
function on its copy, using a reference into the map (e.g.
map.take(map.firstKey())). Let's call the shared payload of this QMap
SP, with its refcount of 2; it's important to note that the argument
(call it A) passed to the mutating function belongs to SP.

Each thread may then find the reference count to be different than 1 and
therefore do a detach() from inside the mutating function. Then this
could happen:

Thread 1:                         Thread 2:

detach()                          detach()
  SP refcount != 1 => true          SP refcount != 1 => true
    deep copy from SP                 deep copy from SP
    ref() the new copy                ref() the new copy
  SP.deref() => 1 => don't dealloc SP
  set the new copy as payload
                                    SP.deref() => 0 => dealloc SP
                                    set the new copy as payload

  use A to access the new copy      use A to access the new copy

The order of ref()/deref() SP and the new copy in each thread doesn't
really matter here. What really matters is that SP has been destroyed
and that means A is a danging reference.

Fix this by keeping SP alive in the mutating functions before doing a
detach(). This can simply be realized by taking a local copy of the map
from within such functions.

remove() doesn't suffer from this because its implementation doesn't do
a bare detach() but something slightly smarter.

Change-Id: Iad974a1ad1bd5ee5d1e9378ae90947bef737b6bb
Pick-to: 6.2
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-26 02:14:52 +01:00
Edward Welbourne
297f9aa6c8 Add some missing entries to QTest::qExec()'s \sa line
Change-Id: I45300d5f9df519c5edb68d24232830bd0850915a
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-11-26 02:14:51 +01:00
Rami Potinkara
1a87f06916 Android: Set sem_wait m_terminateSemaphore behind an atomic flag
Prevents QML app using QtActivity never calling
AndroidJniMain::startQt..'s to jam as ANR

Pick-to: 6.2 5.15
Task-number: QTBUG-97115
Change-Id: Ibfe8579dbb701068f4896b6d826ff487094bdf56
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2021-11-26 02:27:49 +02:00
Marc Mutz
9baf1d5256 QAndroidActivityResultReceiver: make uniqueActivityRequestCode() lock- and UB-free
The old code attempted to detect the overflow of the requestCode
variable, but because it didn't do anything about it except warn, it
still ran into the overflow, and, since the variable is signed, into
UB. That means that a clever compiler will just eliminate the warning
as dead code because it can backtrack and see that the condition
guarding it is never true, because otherwise UB happens.

Fix that problem by using a uint counter (unsigned overflow is defined
to wrap) and only convert to int after the check.

Also fix two inefficiencies with the old code:

1. We don't need a mutex just to up a counter in a thread-safe
   way. Upping a shared counter is the prototypical use-case for
   relaxed atomics, so use that. That also solves the problem of the
   non-POD static object at function scope (QMutex) that forced
   compilers to emit thread-safe static initialization code.

2. We had a static variable whose initial value isn't 0, which means
   it can't be in stored in the BSS, but only in the DATA segment. Do
   the trivial transformation of subtracting the offset so the
   variable starts at 0. The offset can be added afterwards.

Pick-to: 6.2
Change-Id: I3560df21d6b4e4201cb6772237780cc8b400631d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-11-25 13:16:06 +01:00
Marc Mutz
f4e89d58da QVERIFY_EXCEPTION_THROWN: re-throw unknown exceptions
Swallowing unknown exceptions is dangerous business, as the exception
might be a pthread cancellation token, the swallowing of which would
terminate the program.

Instead of returning from the catch-all-clause, therefore, re-throw
the unknown exception.

Fix tst_verifyexceptionthrown failure cases that use
non-std::exception-derived true negative exceptions to not let the
exception escape from the test function.

As a drive-by, pretty up the macro's docs.

[ChangeLog][QtTest][QVERIFY_EXCEPTION_THROWN] Now re-throws unknown
exceptions (= not derived from std::exception) (was: swallowed them
and returned from the test function), in order to play nice with
pthread cancellation.

Pick-to: 6.2 5.15
Change-Id: Ic036d4a9ed4b7683fa67e27af8bcbae0eefdd0da
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-11-25 13:00:55 +01:00
Luca Di Sera
c880696f06 Doc: Replace use of \oldcode-\newcode
The command-pair was recently deprecated.

The replacement code should produce an output that is equal to the
previous one.

Task-number: QTBUG-98499
Change-Id: If26e0d85a174ebc3858b638c34d7f43637eab46d
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-11-25 09:55:48 +01:00
Mårten Nordheim
8f8775adf3 QHash: fix thread race around references and detaching
If we detach from a shared hash while holding a reference to a key from
said shared hash then there is no guarantee for how long the reference
is valid (given a multi-thread environment).

Pick-to: 6.2
Change-Id: Ifb610753d24faca63e2c0eb8836c78d55a229001
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2021-11-25 08:52:39 +00:00
Mårten Nordheim
a92619d950 QAuthenticator: Filter out algorithms we don't support
Which is anything other than MD5

Pick-to: 6.2 5.15
Fixes: QTBUG-98280
Change-Id: Ifbf143f233ee5602fed1594e3316e6b2adec1461
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-11-25 08:52:33 +00:00
Yuhang Zhao
e75b1dfe38 Windows QPA: Further cleanup of pre-Win10 code
Mostly a removal of dynamically loaded Win32 APIs.
Since Qt 6's minimum supported platform is Win10 1809
(10.0.17763, code name RS5), all these functions will
be available and no need to resolve them at run-time.

Things not remove:
WinTab functions in "qwindowstabletsupport.cpp".
Not my familiar area, so not touch it.

Pick-to: 6.2
Task-number: QTBUG-84432
Change-Id: I7ad6c3bc8376f6c0e3ac90f34e22f7628efeb694
Reviewed-by: André de la Rocha <andre.rocha@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2021-11-24 09:16:38 +08:00
Marc Mutz
f5f7f78766 QObject: don't #include qproperty.h
The qobject.h header needs QBindingStorage in-size and QBindable
in-name-only. The former was moved to its own header in a previous
commit, which we include now, while the latter can just be
forward-declared. This allows dropping the qproperty.h include from
qobject.h.

[ChangeLog][Potentially Source-Incompatible Changes] The qobject.h
header no longer implicitly includes qproperty.h. If your code depends
on the transitive include, explicitly include <QProperty> where
needed.

Task-number: QTBUG-97601
Pick-to: 6.2
Change-Id: I8d6320f5978e20dfc394d2b1e49f626b99529c37
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-11-23 21:23:44 +01:00
Marc Mutz
0347b4ee5e QTest: mark qFail() as cold
Unit tests should not fail, so a call to qFail() is by definition
exceptional. Therefore, mark the function as cold. It probably doesn't
matter in the grand scheme of things, but it also doesn't cost much.

Change-Id: I0cafcfa65ff285812155d0687deded8d26cf4efd
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-11-23 21:23:41 +01:00
Joerg Bornemann
3f56950862 Move macdeployqt and windeployqt from qttools to qtbase
Having all *deployqt tools in qtbase will allow us to couple deployment
support more tightly with the build system.

Change-Id: I299efdacfa6b66a303bb3996ff3ff84e723210a5
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2021-11-23 21:11:45 +01:00
Yuhang Zhao
1e9f9a4b7d QOperatingSystemVersion: cache the retrieved version
It won't change during runtime, so make it a static
variable to avoid fetching the information repeatedly.

Change-Id: I430ceba218f9f3515558736238d1d5a74cf59419
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2021-11-23 09:59:55 +00:00
Timur Pocheptsov
3fcdb6cb6e QCocoaMenuBar: set the app's 'Window' menu
To enable a list of windows the app has open in the Dock's menu.
Not to surprise existing applications with a 'Window' menu where
they did not have it before, make the item hidden.

Fixes: QTBUG-59433
Change-Id: I1ac3d3de69f4313f39c4631dc4b68bf6e096532a
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-11-23 08:35:22 +00:00
Yuhang Zhao
e01c25e859 QtBase: replace windows.h with qt_windows.h
We have some special handling in qt_windows.h,
use it instead of the original windows.h

Change-Id: I12fa45b09d3f2aad355573dce45861d7d28e1d77
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-11-23 12:53:46 +08:00
Marc Mutz
4c7759cae2 Restore src/tools/moc/util/generate_keywords.pro
The file was inadvertently removed in
ad2da2d27a.

Pick-to: 6.2
Change-Id: Iaaf74d7ae382b0c9487fb25a58632dfc5be6538d
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-11-23 00:36:34 +00:00
Marc Mutz
0fc2cde89b qapplicationstatic.h: fix syncqt warning
Warning was:
  "QtCore: WARNING: src/corelib/kernel/qapplicationstatic.h includes QMutex when it should include QtCore/QMutex"

Comply.

Change-Id: Ifc74b4f8052b7e95f86cab9a01a7e91bcbc3022d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-23 01:36:34 +01:00
Marc Mutz
9d79e5f26c QVLA: Self-Encapsulate Fields
Use member functions to access some (combinations of) fields in
preparation of moving said fields to base classes:

   s + ptr  → end()
   s        → size()
   ptr      → data() (or begin(), depending on context)
   a        → capacity()

Fixed a const-incorrectness issue detected by the change.

Task-number: QTBUG-84785
Change-Id: I2218d57559208c9d77b8860d419979e92f140e13
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-22 21:20:54 +01:00
Eirik Aavitsland
8ce3693856 QImageReader: check allocation limit for minimum 32 bpp
Also, as a driveby, add an environment variable so the limit can be
changed at runtime.

[ChangeLog][QtGui][QImageReader] When checking allocation limit during
image reading, the memory requirements are now calculated for a
minimum of 32 bits per pixel, since Qt will typically convert an image
to that depth when it is used in GUI. This means that the effective
allocation limit is significantly smaller when reading 1 bpp and 8 bpp
images.

Pick-to: 6.2 6.2.2
Change-Id: If1b204d413973b0975eea531e29c260fdcec931d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-22 14:29:20 +01:00
Sona Kurazyan
102f7d31c4 Add support for combining multiple QFutures
[ChangeLog][QtCore] Added QtFuture::whenAll() and QtFuture::whenAny()
functions, returning a QFuture that becomes ready when all or any of the
supplied futures complete.

Task-number: QTBUG-86714
Change-Id: I2bb7dbb4cdc4f79a7a4fd494142df6a0f93a2b39
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-20 10:28:29 +01:00
Thiago Macieira
3b49aa72fe Q{CoffPe,Elf,MachO}Parser: check that the magic string is present
Commit 2549a88ba2 changed the ELF and
Mach-O parsers to return an offset to the actual data header, not the
magic string, which we stopped searching for anyway. This commit brings
such a validity check back and adds it to the new COFF PE parser.

Change-Id: Iccb47e5527544b6fbd75fffd16b8b2252a76f179
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-19 22:51:04 -08:00
Thiago Macieira
892d5607d0 QPluginLoader: add COFF PE file parser
Fixes: QTBUG-67461
Docs: https://docs.microsoft.com/en-us/windows/win32/debug/pe-format
Change-Id: I5e52dc5b093c43a3b678fffd16b77bf9a8f2b17e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-19 22:51:03 -08:00
Thiago Macieira
235173175b CMake: reorganize the QT_FEATURE_library portion of CMakeLists.txt
No need to attempt to compile both qelfparser and qmachoparser in all
systems.

Change-Id: Iccb47e5527544b6fbd75fffd16b7ee5a1555a7a8
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-11-19 22:51:02 -08:00
Thiago Macieira
09c58614db QString::fromUtf16: use qustrlen
We have it.

Pick-to: 6.2
Change-Id: Iccb47e5527544b6fbd75fffd16b901fe4d2920a7
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-19 18:33:07 -08:00
Marc Mutz
fd8f81f385 Re-apply "QReadWriteLock: replace (QWaitCondition, QMutex) with std::(condition_variable, mutex)"
This reverts commit 1283ee3245.

We now have wrappers around std::mutex and std::condition_variable
that fall back to QMutex and QWaitCondition on the broken Integrity
toolchain. Use them.

Change-Id: I881aa931167b845b489713048b57ccc5f79d4237
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2021-11-20 02:38:41 +01:00
Marc Mutz
229f356cef Short live q20::ssize()!
Extract the definition of q20::ssize() from tst_qanystringview.cpp,
where it had to be placed for its backport to 6.2.

Change-Id: I3f758c98a4b1efd453f4fc044b8d3f1a89de62d1
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-11-20 01:38:41 +00:00
Marc Mutz
2fbe460245 QAndroidActivityResultReceiver: avoid double(triple)-lookup
The code used the if (!contains()) { insert() } anti-pattern,
necessitated by Qt's deviation from the STL of allowing insert() to
overwrite an existing entry, causing two lookups of the same key.

Fix by recording the size prior to the execution of the indexing
operator and taking a size increase as the cue to populate the (new)
entry. This way, we look up the key only once.

Also fix two instances of double lookup caused by the if (contains())
{ value() } anti-pattern.

Change-Id: I961fe45ec571aa94aff5dd578f2276e7b74d800d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-20 02:38:40 +01:00
Ievgenii Meshcheriakov
07034b765e Use Authz API to query permissions info in Windows filesystem backend
Microsoft documentation for GetEffectiveRightsFromAclW function that
was used previously has this at the top of the page:

> GetEffectiveRightsFromAcl is available for use in the operating
> systems specified in the Requirements section. It may be altered
> or unavailable in subsequent versions. Instead, use the method
> demonstrated in the example below.

This says to me that the function is deprecated. In addition to
that, it is not able to handle ACLs that are not in "canonical"
order, returning ERROR_INVALID_ACL. Such ACLs are useful to
represent POSIX permissions in Windows, and are produced by
Cygwin for example.

This patch uses Authz API referenced by the message quoted above.
The used API is available starting from Windows XP/Windows Server
2003. This API also allowe to perform access checks given access
token, and so allows to use similar code all permission checks.

Task-number: QTBUG-79750
Change-Id: I8b11ff3cc83cd9ed5bfb2ce9432a375a122cdbbf
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-19 23:35:48 +01:00
Tor Arne Vestbø
db780c4ca5 xcb: Return standalone image from QXcbBackingStore::toImage()
Otherwise the original backingstore image will detach from the
m_xcb_image data on the next backingstore paint or scroll.

Pick-to: 6.2
Change-Id: I73f68d9c2e7c106951541831a5df8b97695f2001
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2021-11-19 21:55:45 +01:00
Alexander Volkov
185c8d5adf Skip disabled proxy widgets when (back)tabbing
Fixes: QTBUG-98137
Pick-to: 6.2 5.15
Change-Id: If52053dce361b130ef7dcfaf747710d8ceb9bbcd
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-11-19 23:55:44 +03:00
Joerg Bornemann
610123b1c8 Move the 'qmake' feature to src/tools/configure.cmake
This allows us to present 'qmake' in the tool-related section of the
configure summary.

Change-Id: I897dec23cb0608706ec01d9b91283dbce92b293f
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-11-19 20:44:51 +01:00
Joerg Bornemann
d29f76f5e5 Add configure feature 'androiddeployqt'
This makes it possible to turn off the build of the Android deployment
tool.

A new src/tools/configure.cmake is added that will be the place for all
tool-related features in qtbase.

Change-Id: Ic9264c93ee96de06c97d21d2f27f73256f48ffda
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-11-19 20:44:51 +01:00
Øystein Heskestad
18aff2b424 Add more verification when parsing http headers and add tests
Adding tests from QtWebSockets that will reuse QHttpHeaderParser

Task-number: QTBUG-80700
Change-Id: I76294a9156173314a3cf09160d0ca4e0d7c6ef3a
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-19 19:31:34 +01:00
Morten Johan Sørvig
d62e9d3c5b Compile: Work around false positive on gcc >= 900
Change-Id: Id9d2c968322963af6a2e31f0d9e4195120d0b5ea
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-19 19:26:49 +01:00
Morten Johan Sørvig
0d12c9f354 wasm: remove unused variable
Change-Id: I442e3dc4534193709c3510c43a484e5d3c2eb4af
Reviewed-by: David Skoland <david.skoland@qt.io>
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2021-11-19 19:26:48 +01:00
Joerg Bornemann
68600869cd Link printer plugins into user projects when using a static Qt
When building a user project against a static Qt on Windows or macOS the
static printer support plugins were not linked.  Move the
Q_IMPORT_PLUGIN statements to qplatformprintplugin.cpp, which is a
translation unit that is guaranteed to be linked into the user project.

Pick-to: 6.2
Fixes: QTBUG-97490
Change-Id: Ic35c6483a664a06461304c7e8a2b7b06ce651ed6
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-11-19 18:48:07 +01:00
Alexey Edelev
a41d9bcac9 Fix generating of Android deployment config in Multi-Config build
Add the config-specific suffix to the generated Android deployment
config file.

Amends d20f4ae706

Change-Id: If1755baf5548adb4d95733477d8b5af85e1fd2dd
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-11-19 18:48:07 +01:00
Joerg Bornemann
04ec14105e Change qt.conf key Qml2Imports to QmlImports
[ChangeLog][qt.conf] The key Paths/Qml2Imports has been renamed to
Paths/QmlImports. For backwards-compatibility, Paths/Qml2Imports is
still accepted and acts as default value for when Paths/QmlImports is
not present.

Fixes: QTBUG-98335
Change-Id: If7ffedd281eb8a87e8ab1a2b69a823e615c33541
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2021-11-19 16:44:32 +01:00
Marc Mutz
a3303aceeb QLoggingRegistry: avoid double-lookup
The code used the if (!contains()) { insert() } anti-pattern,
necessitated by Qt's deviation from the STL of allowing insert() to
overwrite an existing entry, causing two lookups of the same key.

Fix by recording the size prior to the execution of the indexing
operator and taking a size increase as the cue to populate the (new)
entry. This way, we look up the key only once.

Change-Id: Ica039035fe9ea4b88c20184784c324c9fac33d49
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2021-11-19 16:28:45 +01:00
Marc Mutz
7fe5611365 QHash: optimize value(key) and key(value) callers
... by not injecting potentially-expensive temporary objects into the
caller's stack frame.

Default arguments are a convenient way to avoid overloads, but if the
defaulted argument isn't a Trivial Type, and the common use case is
not to pass the extra argument explicitly, the construction of the
temporary can dominate the call's runtime.

Since QHash is generic code, we don't know whether T or Key are
expensive or cheap to construct, so use overloading instead of default
arguments to avoid injecting needless code into call sites.

[ChangeLog][QtCore][Potentially Source-Incompatible
Changes][QHash/QMultiHash] The value(key) and key(value) functions are
now overloaded on presence of the defaultValue (was: defaulted
argument) to avoid injecting temporary objects into the caller's stack
frame.

Task-number: QTBUG-98117
Change-Id: I80fdd5436f3de3e4bbe20242fe45916aef62ff0c
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
2021-11-19 16:28:44 +01:00
Edward Welbourne
14b0e2fb1e Prefer QBAV over raw char * form of qt_configure_strs
Passing the QByteArrayView to QString::fromLocal8Bit() ensures we tell
it the size and saves a strlen(). Quite apart from avoiding some
misguided grumbles from compilers, this save searching for a '\0' when
we already know where it is.

Change-Id: I2e3f2edfb4d3bdf488374570567d1dd30641ebc3
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-19 16:28:44 +01:00
Nicholas Bennett
a4dca9936d Docs: Move manifest and androiddeployqt docs to where code lives
Removed content describing androiddeployqt from deployment-android.html
to androiddeployqt.html,the qdoc source now living in qtbase.
Docs src locations added to the qtcore.qdocconf.

Task-number: QTBUG-97842
Pick-to: 6.2
Change-Id: I94783520280098ce1ab35f335a644bea70b8131a
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2021-11-19 12:18:50 +00:00
Kai Köhne
426b2cae7c Remove unneeded int conversions in qmetatype.h
They were added in Qt 5, where QByteArray::reserve() was an int
argument, and qstrlen() was returning an int. In Qt 6, both
accept and return qsizetype/size_t.

As a side effect, this fixes various informational messages when
loading a Qt project into Visual Studio 2022:

  lnt-arithmetic-overflow: A sub-expression may overflow before being assigned to a wider type.

Pick-to: 6.2
Change-Id: Ifc9a1f7046a78bcfb97fe241d697c1bf91c6ba4f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-19 12:18:50 +00:00
Eirik Aavitsland
4f69a1e1d2 Clean up line clipping code in rasterizer
Replace old code with the line clipper from qcosmeticstroker.

Also avoids tripping some issue with the current clang 13 that would
cause paint errors on macOS.

Fixes: QTBUG-98403
Fixes: QTBUG-98388
Pick-to: 6.2 6.2.2
Change-Id: I257eeec6f71153ec51b4176df3be8c443938484c
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2021-11-19 12:40:10 +01:00
Mårten Nordheim
919f5bd459 QOperatingSystemVersion: Add Windows11
Change-Id: Ieb7674bbbbc78689f1e2a1e5a06dfd4d0ce25ac1
Reviewed-by: Yuhang Zhao <2546789017@qq.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-19 09:14:34 +01:00
Marc Mutz
b7f4041669 QAnyStringView: fix broken implicit conversion from QStringBuilder
Need to use QConcatenable<>::ConvertTo for SFINAE, the forwarded type
alias in QStringBuilder itself doesn't work.

[ChangeLog][QtCore][QAnyStringView/QStringBuilder] Implicit conversion
from QStringBuilder to QAnyStringView now works as advertised.

Pick-to: 6.2
Fixes: QTBUG-98138
Change-Id: I1c300675cf43b13017bc56398ae5d8c1c51e64fe
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-11-19 03:32:20 +01:00
André de la Rocha
8283df4d8c Windows QPA: Fix multi-touch support in some devices
Some multi-touch devices send touch information for each finger using
different WM_POINTER messages/frames, instead of a single one with
a list of touches, like most devices. This would result in the generation
of multiple touch events, which can cause unexpected behavior in
applications (the QTouchEvent documentation specifies that it should
contain all simultaneous touches). This patch adds a workaround to
ensure all simultaneous touches are included in the events, to comply
with the expected behavior.

Pick-to: 6.2 5.15
Change-Id: I12a2f84b35a6bdd49ee53d25de580c0941a9aea6
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
Reviewed-by: Oliver Wolff <oliver.wolff@qt.io>
2021-11-18 23:41:02 +01:00
Tor Arne Vestbø
3cc1a32f97 Clarify validity of image returned from QPlatformBackingStore::toImage()
The backingstore may reconfigure the internal data, so clients should
not assume that the image is valid beyond any new operations on the
backingstore.

Pick-to: 6.2
Change-Id: I137ad4f2adb45ec8bb78a989fbb5bac1e72965ce
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2021-11-18 23:41:02 +01:00
Tor Arne Vestbø
71f75bf6c5 xcb: Don't mark scrolled area as flushed when doing client side scroll
The m_pendingFlush variable is used to track what is missing in the
server side backingstore. If we're doing a client side scroll the
pending area is still the same.

If we were to always discard the scrolled area from m_pendingFlush
we would get in trouble on the next non-client side scroll, as
we think the content exists server-side.

Pick-to: 6.2
Change-Id: Ie50a99a8e5d8a83d1299c53534a1c83c6bfb47bd
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2021-11-18 23:41:02 +01:00
Tor Arne Vestbø
12af9ce6db xcb: Ensure we have pixmap GC before trying to flush to it during scroll
Pick-to: 6.2
Change-Id: Icc85b1eb830d8d9b1b2bfb8b9998470388522832
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2021-11-18 23:41:02 +01:00
Tor Arne Vestbø
709a932d7b xcb: Prepare correct area when doing client side backingstore scroll
The area we're going to fill is the one after applying the scroll delta.

Pick-to: 6.2
Change-Id: I254830a15e5f4c93ba28ed8f0a9b35c40f1d1af2
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2021-11-18 23:41:02 +01:00
Eskil Abrahamsen Blomfeldt
7102aa6b15 Fix assert in QFontComboBox when setting empty font
Don't crash if the font does not have any families set.

Pick-to: 6.2
Task-number: QTBUG-97995
Change-Id: I8dc2f2fc00309b6fff6d4a661ec6d659f30808af
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
2021-11-18 23:41:02 +01:00
Eskil Abrahamsen Blomfeldt
71faedc5b4 Fix deserializing Qt 5.x fonts through QDataStream
In Qt 5, fonts had both singular family and plural families properties,
and both were stored separately when streaming through QDataStream. The
families list was treated as an extension of family in this case, and
the primary font family was always the singular family property.

In Qt 6, it has been merged into one and family() is now just a
convenience for families().at(0).

But when reading files generated with Qt 5, we would ignore the fact
that these were previously separated. We would first read the family
entry into the families list, and then we would later overwrite this
with  an empty families list.

Instead, we detect streams created with Qt 5.15 or lower and make sure
we append the families list instead of overwriting it in this case. In
addition, we need to make sure we split up the list again when
outputting to Qt 5.x.

This adds a file generated with QDataStream in Qt 5.15 to the test to
verify.

[ChangeLog][Fonts] Fixed a problem deserializing the family of fonts
that had been serialized using QDataStream in Qt 5.

Pick-to: 6.2
Fixes: QTBUG-97995
Change-Id: Id3c6e13fc2375685643caee5f8e3009c00918ccb
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Shaw <andy.shaw@qt.io>
2021-11-18 23:41:02 +01:00
Volker Hilsheimer
4bee9cdc0a macOS: Fix QSlider's knob positioning on Monterey
QMacStyle has a single NSSlider that is used to render any QSlider. For
each QStyle API operating on a slider, the style sets the slider up with
respecive properties. On macOS 12, the NSSlider maintains some states
that make QSlider instances influence each other's knob position when
rendering, resulting in uncontrollable jumping of the slider.

This can be fixed by not using startTrackingAt/stopTracking APIs, which
are however the only way we have to make the slider knob get rendered
pressed - there is no property in NSSlider(Cell), and none of the NSCell
attributes have any effect. So we need to use startTrackingAt, and work
around the side effect by reinitializing the NSSlider by calling
initWithFrame.

This fixes the positioning error, but also causes flickering of the knob
when dragging. To fix the flickering, we have to always call
startTrackingAt for a slider that is pressed, even for calls to
setupSlider that are made in QStyle APIs that are not drawing anything.

Also tried with no complete success (either positiong bug or flicker):
* call prepareForReuse on the NSView
* always call stopTracking on the NSSlider

Fixes: QTBUG-98093
Pick-to: 6.2 6.2.2
Change-Id: I3423b9f7cb125a59831c6722509ab3b74742b6ae
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2021-11-18 22:06:21 +00:00
Volker Hilsheimer
b3dc0fec2b Add operating system version for macOS 12 "Monterey"
With pre-11 SDKs, macOS reports version 10.16, which already matches
BigSur, so we only match Monterey if version 12 is reported.

Change-Id: I37fee43756310370444981212750cdfe7fad64b8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-11-18 22:53:21 +01:00
Mike Achtelik
f7fd57075b Introduce Q_APPLICATION_STATIC
QObjects must be deleted if the QCoreApplication is being destroyed.
This was previously done by implementing custom code in qtbase and
other modules. So unify it and introduce a Q_APPLICATION_STATIC,
based on the Q_GLOBAL_STATIC, which centralises the logic.

Since we still have a few remaining living QObjects,
this comes in handy to fix those as well.

Task-number: QTBUG-84234
Change-Id: I3040a2280ff56291f2b1c39948c06a23597865c4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-18 20:53:27 +01:00
Allan Sandfeld Jensen
1a8b7eb1d4 Increment reference count when restoring reference
Otherwise the count will be wrong after an out of memory failure in
reinterpretAsFormat.

Pick-to: 6.2 5.15
Fixes: QTBUG-98377
Change-Id: Ice51d47a6db9277126a5c7337e14aaf5ddee3a10
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2021-11-18 20:46:41 +01:00
Lucie Gérard
fb33e2a8e8 Add missing QT_TRID_N_NOOP definition
Amends c74bd2b93, properly following up on qttools/bc47b5190.

[ChangeLog][QtCore] Added missing QT_TRID_N_NOOP() macro. Lupdate
actually recognizes it since Qt 5.12.

Fixes: QTBUG-98277
Fixes: QTBUG-3945
Change-Id: I0ea15ceb49b2ead5c8bb40d2a55a0ae8577e8850
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Kai Koehne <kai.koehne@qt.io>
2021-11-18 18:13:21 +01:00
Edward Welbourne
4515c5e4fc Use a QVarLengthArray for FatalSignalHandler's alternate stack
The stack needs to be at least SIGSTKSZ, which isn't constexpr, so we
can't allocate it at compile time. However, we can resize(SIGSTKSZ) a
QVarLengthArray that's probably big enough anyway. At the same time,
increase the compile-time size to 32k, to match what our Catch2
harness for the self-test uses.

Change-Id: I3a34ece73901dd402672cd6fe4da66923f1932c8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-18 18:13:20 +01:00
Edward Welbourne
2ad5fd36fb Rework FatalSignalHandler to use ranged-for loops over signals
Shrinks the const array by one zero-terminator and makes the code
accessing it read more gracefully.

Change-Id: I4034116a83ff3cd05ea0feb0ce8a4340c54a9faa
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-18 18:13:20 +01:00
Edward Welbourne
771657e55f Test the return from sigaction()
If we fail to install our own action, the contents of oldact are noise
anyway, so we can't use them to decide anything; and, in any case, we
didn't replace the prior action, so have no duty to restore it.

In the process, restructure and comment the code to make it easier to
follow what's going on and why. Package a conditional in a lambda to
make the #if-ery less problematic. This should also make it easier to
hack any other complications into the condition, should they arise.

Change-Id: I712335ee27f68a8594dc2fe6441a91f686967da2
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-18 18:13:20 +01:00
Edward Welbourne
f75d36fd18 Fix macOS system locale's formatting of negative years
It leaves off the minus sign.

Change-Id: Iad72349368d8849330524144033453cbd79e9e7c
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2021-11-18 18:13:20 +01:00
Edward Welbourne
8926eb86c6 Fix formatting of dates before 1601 in MS system locale
The relevant MS system calls (say they) don't support date formatting
for years < 1601 (but apparently do in fact) and the year field of the
data structure is unsigned, so can't support years < 0. As a result,
the windows back-end for QSystemLocale failed for negative years.
So replace year < 1601 with a place-holder and substitute after
formatting.

Added new tests (based loosely on one in qtdeclarative that failed) to
verify that this actually works. These reveal that macOS also fails to
handle negative years; marked as expected failure there pending a fix.

Change-Id: I9b63cefd5f0b77a39cf1238549412de3e26ca1bd
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-18 18:13:20 +01:00
Edward Welbourne
2bf5a60bfa Remove some spurious prefixes in declarations
The parameter-list of a method is already in its class's context, so
doesn't need it made explicit on the other class members involved.

Change-Id: I253b098ad1f2d2db80d49d8f484b7f95d14acec1
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
2021-11-18 18:13:20 +01:00
Edward Welbourne
8dea25d501 Add a note on the sign of daylight-saving offsets
Given that at least one zone has a negative offset (so that it's in
standard time for most of the year, including summer, and
daylight-saving time relatively briefly during winter), QTimeZone's
docs should explain what that means.

Change-Id: I6649b4cdefbd685dc97bf85d957960da44d07aed
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-11-18 18:13:20 +01:00
Edward Welbourne
b9021ed1f7 Eliminate a constant from qtimezoneprivate_win.cpp
Its MIN_YEAR was duplicating what's now provided by
QDateTime::YearRange::First, so use that instead.
In the process, tidy up an over-long line.

Change-Id: I109f5435f63cb5cc97d54529a172b640f919dec0
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-18 18:13:20 +01:00
Edward Welbourne
28088a3d74 Remove some unused constants from qtimezoneprivate_win.cpp
Recent commit 6845c444d0 elicits
warnings about two unused constants. Remove an unused macro at the
same time, and add missing LL suffix to remaining qint64 constants.

Change-Id: I4c84e10b512030e0e4f860d434382e62e6c936f5
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-18 18:13:19 +01:00
Marc Mutz
dca63b6ef6 QIODeviceBase: make dtor protected
Base class dtors should be virtual and public or else protected and
non-virtual. This one was neither of these.

[ChangeLog][Potentially Source-Incompatible Changes][QtCore] The
QIODeviceBase destructor is now protected to avoid deleting objects of
classes derived from it through a QIODeviceBase pointer, which would
be undefined behavior.

Change-Id: Id390ace75d5b64f746d9b1865b8800c9f0590977
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-18 17:13:19 +00:00
Ievgenii Meshcheriakov
0fa6e6b0ab QFileSystemEngine: Fix permissions query in Windows backend
Make fillPermissions() correctly set OtherExecutePermission
instead of OwnerExecutePermission.

Pick-to: 6.2
Change-Id: I77ef3c5bc59ac6110c5a461a599d03029c70493c
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-18 17:12:27 +01:00
David Schulz
35263fffea Always check keyboard modifiers when generating mouse events
This is basically a revert of: 634ce491e8

The cached keyboard modifier can get out of sync when switching to
another application while a modifier is pressed. In this case we get a
key press event but we might not get the key release event, which is
expected to reset the cached modifier. Switching back to the Qt
application after the modifier was released now still has the old
modifier cached.

Most prominent example is triggering alt + tab to switch to another
application and use the mouse to get back to it. In this case the alt
modifier is still cached.

Task-number: QTCREATORBUG-26581
Pick-to: 6.2
Change-Id: I9d64b7d730af089778bd1a4b3f1296bcccd5d16d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-11-18 06:44:26 +01:00
Yuhang Zhao
16aa4eaa82 QOperatingSystemVersion: Add Win10 sub-versions
Change-Id: Icce32a17f285f0a0416ad8a7838a7424cda2bc2b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-18 13:34:49 +08:00
Edward Welbourne
3b84187cd1 Fix leak in date and time formatting on macOS
CFDateFormatterCreateStringWithDate() creates a CFStringRef that we
need to tidy up once we're done with it, so use the QCFType template
to take care of that.

Change-Id: Ibc3751426cc4496bce25307918fdb11722cde3b2
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2021-11-18 04:36:24 +01:00
Tor Arne Vestbø
a8a003aba2 Build ODBC driver as universal binary on macOS
Task-number: QTBUG-93204
Pick-to: 6.2
Change-Id: Ia373f41dbf247c8a5844ae365701bc457cfba79d
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-11-18 04:36:24 +01:00
Povilas Kanapickas
b00fe3c9aa CMake: Enable -bundled-xcb-xinput by default
This is done by disabling system-xcb-xinput feature by default. It will
require user to pass -no-bundled-xcb-xinput to the configure script to
override this.

The reason for the change is that touchpad gesture implementation
requires new code from libxcb, yet this new code is not even released
yet. Even if it was released today, at least several years will pass
until the new version is common enough.

[ChangeLog][Third-Party Code][X11] The xcb plugin is now compiled with
the bundled xcb-xinput library by default, in order to enable support
for touchpad gestures.

Change-Id: Iebb27ecee7facf070ef23f37a55aab0578698f16
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-11-18 02:32:58 +02:00
Marc Mutz
536471106d QAbstractFileEngine: fix UB (data race) on qt_file_engine_handlers_in_use
While all writers of the variable hold fileEngineHandlerMutex for
writing, the qt_custom_file_engine_handler_create() function checks
the value before entering a fileEngineHandlerMutex read-side critical
section, thereby causing a C++11 data race.

Fix by making the variable atomic. Interestingly enough, relaxed
atomic operations suffice here, since the actual synchronization
happens in read- and write-side critical sections, and if
qt_file_engine_handlers_in_use is wrong w.r.t. to the actual list, the
critical sections will still work. We just mustn't cause UB by reading
and writing to a simple bool without proper synchronization.

Pick-to: 6.2 5.15
Change-Id: I30469504cdbc90e2ab27125181e53d74305f13fd
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-11-16 21:16:28 +01:00
Marc Mutz
06dfbdf081 QItemSelection: fix (some) O(n²) behavior in merge()
Instead of taking a copy of the incoming data, followed by a quadratic
modifying algorithm (single-element erase loop), guaranteeing a
deep-copy detach of the original, just iterate over the incoming data,
building the new dataset by appending only valid items.

Also port to ranged for loop.

There's more quadratic behavior in that function, later on, but that's
for another patch.

Change-Id: I284f3b7c9694c8eb226a198f6f97538765113b19
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-16 20:37:32 +01:00
Eirik Aavitsland
997c052db9 Reject truncated and corrupt ascii pnm images
In contrast to the binary decoder code, the ascii decoder would not
abort and fail on premature end of file.

Pick-to: 6.2 6.2.2 5.15 5.12 5.12.12
Change-Id: If27bce0afa8d1de6c4dbeb2bc0e623c1dcc2f1e0
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-11-16 18:54:32 +00:00
Tor Arne Vestbø
99bb78f6c2 macOS: Clear NSOpenGLContext drawable when QNSView is about to go away
Calling doneCurrent() on a QCocoaGLContext only clears the current
context, but doesns't reset the drawable (view) of the context. In
most cases this is fine, but it has been observed to cause issues
when using the software GL renderer on Big Sur and above.

To be a good citizen we clear the drawable of any of our contexts
that are tied to the NSView this about to be go away.

Pick-to: 6.2 6.2.2
Change-Id: I8c845727c50871f30fbebc2ed62a7d0485651ecf
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2021-11-16 18:54:32 +00:00
Kai Köhne
550e02b809 Make missing xmlstarlet command just a status message
We don't list xmlstarlet in the install documentation, also
because the affect on code size is not too big. We therefore
also don't print a CMake warning then.

Pick-to: 6.2
Change-Id: Ifad3ef0106d09640a7c7d1736f4d5382bcf18e35
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-16 18:37:38 +01:00
Kai Köhne
b99adf7a81 Do not include qloggingcategory.h in public headers
Reduce overhead for including qguiapplication.h by splitting
up qnativeinterface.h into a public and a private part.

[ChangeLog][Potentially Source-Incompatible Changes] The
qguiapplication.h header no longer implicitly includes
qloggingcategory.h. If your code depends on the transitive
include, explicitly include <QLoggingCategory> where needed.

Pick-to: 6.2
Task-number: QTBUG-97601
Change-Id: Ic02327a1c3092e21730160af5c59a9d58dc1239c
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2021-11-16 17:26:04 +00:00
Zhang Hao
9a131b59ee QFontComboBox don't response qApp fontDatabaseChanged()
If QFontComboBox is instantiated in the form of new and call
QFontDatabase::addApplicationFont, QFontComboBoxPrivate::_q_updateModel()
will be called when the program exits, at this time qApp will crash.
Fix this by when program exiting, QFontComboBoxPrivate don't need
call _q_updateModel().

Fixes: QTBUG-98099
Done-With: Konstantin Ritt <ritt.ks@gmail.com>
Pick-to: 5.15 6.2
Change-Id: I3df3d19c3d1971288d60f2eef386262befbf396b
Reviewed-by: Konstantin Ritt <ritt.ks@gmail.com>
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2021-11-16 17:21:56 +08:00
Giuseppe D'Angelo
78a8e561b2 QRegularExpression: do not mark as dirty on no-op setters
Quite some code in Qt takes a copy of a QRegularExpression and then
changes something on it (e.g. the case sensitivity) based on some
other criteria:

  QRegularExpression copy = orig;
  if (cond)
    copy.setPatternOptions(copy.patternOptions() | CaseInsensitive);
  use(copy);

This pattern can be found in QAIM, QString-related classes, and so on.
The "problem" is that if the attempted modification is a no-op, we'd
still invalidate the copy object (by detaching). Even if no detaches
are involved, setting the same pattern or options on a QRE object
shouldn't require a relatively expensive pattern recompile.

In summary: don't detach/mark a QRE object as dirty if a setter didn't
actually do a modification.

Change-Id: Iae0ab4a5e443e7285a83d3d7e0f1dcfd66e8d51d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-16 10:21:09 +01:00
Marc Mutz
0b3f4f8f5a QReadWriteLock: replace a QHash with a QVarLengthArray<., 16>
The QHash was used to track the recursion level of concurrent
readers. But it makes no sense to optimize this data structure
for O(1) lookup speed, since once you go beyond a few threads,
a mutex-based solution falls apart, anyway.

So use an unordered QVarLengthArray with preallocated capacity
16 instead. Lookup and erasure are now O(N), but tracking the
first 16 threads that concurrently lock this shared mutex for
reading no longer allocates memory (except for the Private
class that contains the data structure).

Results on my machine (recursive only):

  thread count: 16
  ********* Start testing of tst_QReadWriteLock *********
  Config: Using QtTest library 6.3.0, Qt 6.3.0 (x86_64-little_endian-lp64 shared (dynamic) release build; by GCC 11.2.1 20211101), ubuntu 20.04
  [...]
   PASS   : tst_QReadWriteLock::uncontended(QReadWriteLock, read, recursive: 1)
   RESULT : tst_QReadWriteLock::uncontended():"QReadWriteLock, read, recursive: 1":
  -     51 msecs per iteration (total: 51, iterations: 1)
  +     38 msecs per iteration (total: 77, iterations: 2)
   PASS   : tst_QReadWriteLock::uncontended(QReadWriteLock, write, recursive: 1)
   RESULT : tst_QReadWriteLock::uncontended():"QReadWriteLock, write, recursive: 1":
  -     31 msecs per iteration (total: 62, iterations: 2)
  +     29 msecs per iteration (total: 58, iterations: 2)
   PASS   : tst_QReadWriteLock::uncontended(QReadWriteLock, read, recursive: 2)
   RESULT : tst_QReadWriteLock::uncontended():"QReadWriteLock, read, recursive: 2":
  -     89 msecs per iteration (total: 89, iterations: 1)
  +     75 msecs per iteration (total: 75, iterations: 1)
   PASS   : tst_QReadWriteLock::uncontended(QReadWriteLock, write, recursive: 2)
   RESULT : tst_QReadWriteLock::uncontended():"QReadWriteLock, write, recursive: 2":
  -     62 msecs per iteration (total: 62, iterations: 1)
  +     56 msecs per iteration (total: 56, iterations: 1)
   PASS   : tst_QReadWriteLock::uncontended(QReadWriteLock, read, recursive: 32)
   RESULT : tst_QReadWriteLock::uncontended():"QReadWriteLock, read, recursive: 32":
  -     1,357 msecs per iteration (total: 1,357, iterations: 1)
  +     1,154 msecs per iteration (total: 1,154, iterations: 1)
   PASS   : tst_QReadWriteLock::uncontended(QReadWriteLock, write, recursive: 32)
   RESULT : tst_QReadWriteLock::uncontended():"QReadWriteLock, write, recursive: 32":
  -     1,067 msecs per iteration (total: 1,067, iterations: 1)
  +     984 msecs per iteration (total: 984, iterations: 1)
  [...]
   PASS   : tst_QReadWriteLock::readOnly(QReadWriteLock, recursive: 1)
   RESULT : tst_QReadWriteLock::readOnly():"QReadWriteLock, recursive: 1":
  -     11,561 msecs per iteration (total: 11,561, iterations: 1)
  +     6,704 msecs per iteration (total: 6,704, iterations: 1)
   PASS   : tst_QReadWriteLock::readOnly(QReadWriteLock, recursive: 2)
   RESULT : tst_QReadWriteLock::readOnly():"QReadWriteLock, recursive: 2":
  -     16,173 msecs per iteration (total: 16,173, iterations: 1)
  +     13,053 msecs per iteration (total: 13,053, iterations: 1)
   PASS   : tst_QReadWriteLock::readOnly(QReadWriteLock, recursive: 32)
   RESULT : tst_QReadWriteLock::readOnly():"QReadWriteLock, recursive: 32":
  -     178,597 msecs per iteration (total: 178,597, iterations: 1)
  +     146,008 msecs per iteration (total: 146,008, iterations: 1)
  [...]
   PASS   : tst_QReadWriteLock::writeOnly(QReadWriteLock, recursive: 1)
   RESULT : tst_QReadWriteLock::writeOnly():"QReadWriteLock, recursive: 1":
  -     65,165 msecs per iteration (total: 65,165, iterations: 1)
  +     64,503 msecs per iteration (total: 64,503, iterations: 1)
   PASS   : tst_QReadWriteLock::writeOnly(QReadWriteLock, recursive: 2)
   RESULT : tst_QReadWriteLock::writeOnly():"QReadWriteLock, recursive: 2":
  -     70,665 msecs per iteration (total: 70,665, iterations: 1)
  +     69,812 msecs per iteration (total: 69,812, iterations: 1)
   PASS   : tst_QReadWriteLock::writeOnly(QReadWriteLock, recursive: 32)
   RESULT : tst_QReadWriteLock::writeOnly():"QReadWriteLock, recursive: 32":
  -     50,811 msecs per iteration (total: 50,811, iterations: 1)
  +     57,659 msecs per iteration (total: 57,659, iterations: 1)

Recursive mode is really, really expensive, even with this patch applied.

Change-Id: I36a164cf09462b69dce7e553f96afcebb49e3dbf
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-16 06:46:48 +01:00
Marc Mutz
98bb6d23a1 QString: prefer sliced() over mid() in split-like functions
These algorithms never call mid() with funky values, so they don't
need the mid() side-cases, and associated 7-branch deep conditionals.

Just use sliced().

Change-Id: I05b6a0e47da90f09b34a92211f7e783a2db709f7
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-15 23:37:31 +01:00
Ulf Hermann
1ea1e0d7f3 Document QLibraryInfo::Qml2ImportsPath as deprecated
Also, add a TODO for migrating to QmlImportsPath in qt.conf.

Task-number: QTBUG-98335
Change-Id: I3c321c99c6286ba64eef643876f5b56d5a8ca695
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-15 21:41:43 +01:00
Assam Boudjelthia
dfb4b7856a Android: check if objectClass() is not null in registerNativeMethods()
In case the class doens't have a default constructor, checking for
object.isValid() will give false because the object won't be created,
however, the class could still be loaded and we could have a valid
jclass.

Pick-to: 6.2
Fixes: QTBUG-96069
Change-Id: I8d59e26d9d7c0e8e363ce443937091a374a24473
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2021-11-15 19:00:21 +00:00
Edward Welbourne
f3e2689106 Revise (recently-added) yearSharingWeekDays() to take a QDate
This lets it avoid a two-digit year that would clash with month or day.
That shall make fixing up system locale date formatting run cleaner.

Add a test for QGregorianCalendar's two extensions.

Change-Id: I77083ff9d5e4035763250904a59fcf416286545b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-15 20:00:21 +01:00
Tor Arne Vestbø
e6364f9c9c Build PostgreSQL driver as universal binary on macOS
Task-number: QTBUG-93204
Pick-to: 6.2
Change-Id: I3e7c76411a7bebee9105a9d97b6ca2c4128a8ddc
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2021-11-15 19:02:07 +01:00
Volker Hilsheimer
22634e0079 Make sure we paint overlapped children and siblings when moving far
In paintAndFlush, QWidgetRepaintManager subtracts opaque children if
the target isn't overlapped and isMoved is set to true. So in moveRect,
set isMoved to true after the blitting of movable areas, and reset it to
false if we have overlapped sibling or child regions. Otherwise, moving
so far that sourceRect is invalid (none of the original pixels are
visible after the move) we end up in a code path that sets isMoved to
true even with overlapping children or siblings, which then breaks
paintAndFlush's assumptions.

Reuse the test case written by Sergiy Korobov <tiamatenko@gmail.com> in
earlier attempts to fix this bug.

Fixes: QTBUG-26269
Pick-to: 6.2
Change-Id: If7443863f5eee79a80220cd587522122f42a21e4
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2021-11-15 18:25:50 +01:00
Povilas Kanapickas
9879d41d05 xcb: Implement support for touchpad gestures
They map to the data exposed by libinput exactly the same way as
touchpad gestures on Wayland. The implementation is functionally the
same and follows the same patterns to preserve similar behavior across
X11 and Wayland.

For example, we use the last known pointer position as the position for
gestures, even though on X11 this data is available as part of events.

The new implementation is only enabled if the used xcb supports the
required APIs.

[ChangeLog][Platform Specific Changes][X11] Touchpads can now detect
multi-finger gestures and send RotateNativeGesture, ZoomNativeGesture
and PanNativeGesture events, since XInput 2.4 and X Server 21.1.

Change-Id: If404dcf8385210deadeb7e7c6d29171e9abc9e50
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-11-15 15:51:14 +00:00
Li Xi
a0e7fbd4d5 Test result of qobject_cast before dereferencing
Since QMainWindow::setMenuWidget accepts a QWidget (allowing users to
implement their own menu widget), we need to use qobject_cast on the
stored widget to see if it is a QMenuBar before calling QMenuBar APIs.

This qobject_cast may return nullptr.

Pick-to: 6.2
Fixes: QTBUG-98247
Change-Id: Iff1dbd24fa7ca09098fe49c179770356c966251d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2021-11-15 16:51:14 +01:00
Volker Hilsheimer
61aa482241 QTabBar: Support scrolling with a kinetic wheel
QTabBar implements wheelEvent to move the current index up or down. This
is useful for clicky mouse wheels, but a bad user experience when using
a kinetic wheel or touch pad, as every pixel movement will change the
current index.

Instead, scroll the entire tab bar when the wheel event comes from a
device that supports scroll phases, without changing the current index.

As drive-by's, fix the test introduced in aa09bea00c to
not leak memory or leave a test-specific style set on the QApplication
instance, which can break other tests.
Also, make relevant layout code in QTabBar respect the usesScrollButtons
property, const'ify local variables, and return an accepted QWheelEvent
if the event resulted in a change.

[ChangeLog][QtWidgets][QTabBar] Scrolling with a kinetic wheel or touch
pad scrolls the entire tab bar, without changing the current index.

Change-Id: I990e51466dd25c741877bbf0e197449f897a9efb
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-11-15 16:23:42 +01:00
hjk
2fa29b00ca Fix return type documentation of QFileSystemModel::fileName()
Pick-to: 6.2
Pick-to: 5.15
Change-Id: I5de4214766eccd5b0086d1230b4267fb49e1b58f
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
2021-11-15 13:46:46 +00:00
Sona Kurazyan
65d553ce52 QFuture: extend the docs to explain how to cancel continuation chain
Task-number: QTBUG-97582
Change-Id: Ib31d0dfb7a74bb88802a21c5875edd789e412529
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-15 13:24:24 +01:00
Sona Kurazyan
76a551588c Update documentation of QFuture continuations
Mention that the futures returned by continuations will stay
uninitialized, until the corresponding continuation/handler starts
executing and do some general improvments to make the docs more
readable.

Task-number: QTBUG-97582
Pick-to: 6.2
Change-Id: I141ff1630b22ec7a856a457a41a69efec980d44b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-15 13:24:24 +01:00
Volker Hilsheimer
6ff07ec23b macOS: make the slider knob big enough for BigSur and Monterey
The slider is very touch friendly from macOS 11 on, and the knob is quite
large. Give it some extra pixels, and adjust the test accordingly.

Pick-to: 6.2
Task-number: QTBUG-98093
Change-Id: Iedf6db1081cdd4013ca29ce760aea1e0361b1123
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2021-11-15 09:30:25 +01:00
Sona Kurazyan
eab40726be QFuture: support cancellation of continuation chain through parent
This change allows canceling the chain of continuations attached to a
future through canceling the future itself at any point of execution of
the chain.

[ChangeLog][QtCore][Important Behavior Changes] The chain of
continuations attached to a future now can be cancelled through
cancelling the future itself at any point of the execution of the chain,
as it was documented. Previously canceling the future would cancel the
chain only if it was done before the chain starts executing, otherwise
the cancellation would be ignored. Now the part of the chain that wasn't
started at the moment of cancellation will be canceled.

Task-number: QTBUG-97582
Change-Id: I4c3b3c68e34d3a044243ac9a7a9ed3c38b7cb02e
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2021-11-13 18:13:08 +01:00
Povilas Kanapickas
746644a5a9 3rdparty: Add touchpad gestures support to bundled xinput xcb module
This feature can easily be backported to our bundled version of libxcb
because the feature is pretty much self-contained (just a couple of new
events and parsing support) and does not depend on newer features of
libxcb that have appeared since our bundled version of 1.13.

Change-Id: If965e3de8b898286cd61c7fddbf335894f3a3ff5
Reviewed-by: Shawn Rutledge <shawn.rutledge@qt.io>
2021-11-13 17:58:45 +03:00
Andrei Golubev
2a2fb306b8 QStack: simplify the class (even more)
Most methods just do the same thing that is implemented in QList,
so just use QList methods

The QStack::pop() implementation should no longer go through the
resize which is likely slower, expands to more-code (unless optimized
away neatly) than erasure of single element through QList API (which
we optimized at some point to be fast)

It is also meaningless (afair) to have `inline` keyword when a method
is both declared and defined within the class' body, so we can drop
that as well

Change-Id: If9de3429be7418ed0ae13c571e28556a358eab05
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-12 22:25:35 +01:00
Mårten Nordheim
3446313c7a Teach QOperatingSystemVersion to handle new OS entries in patch releases
Adding new entries to QOperatingSystemVersion in patch releases
was previously breaking our BC guarantees because the entries are
exported, thus users cannot freely switch between different
patch-releases without a recompile if they adopted the new entries.

Move the data itself to a base class so that the entries can be
constructed inline.

Task-number: QTBUG-97808
Change-Id: Ic44f07488af8a04a3bedc10bebb740c4d68f43f3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2021-11-12 18:06:44 +01:00