Commit Graph

66177 Commits (07c8cece056f5b628cfedcaad3cafe930abbcd29)

Author SHA1 Message Date
Thiago Macieira 07c8cece05 QHash: merge the two equal_range() overloads
They were literally identical (as in, they used exactly the same letters
in the exact same order), but changed on whether *this was const or not.
So pass *this as a parameter so we can have just one implementation.

QMultiHash doesn't need this change because its non-const equal_range()
calls the const version after making a copy.

Change-Id: I6818d78a57394e37857bfffd17ba06aee2e7db0b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-03-12 17:23:05 -08:00
Thiago Macieira ba24125cbf QHash/QMultiHash: further simplify the key() and value() overloads
Complements commit 7fe5611365 by moving
the default value selection into a lambda that is passed to the Impl
function. This makes the two pairs of overloads in each of the classes
be a single line.

Change-Id: I6818d78a57394e37857bfffd17ba067beb3a42fa
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-03-12 17:23:03 -08:00
Thiago Macieira 21dfb0ebcc QString/QByteArray: add explicit constructors for Q{String,ByteArray}View
std::string has them too, see constructor 10 in [1]. There, they are
StringViewLike, something we may want to do here too, which would also
lower the precedence of the constructor in the overload resolution.

This will be needed for the non-const heterogeneous QHash::operator[].

[ChangeLog][QtCore][QByteArray] Added a constructor to create a
QByteArray from QByteArrayView.

[ChangeLog][QtCore][QString] Added a constructor to create a QString
from QStringView.

[1] https://en.cppreference.com/w/cpp/string/basic_string/basic_string

Change-Id: I6818d78a57394e37857bfffd17b9ab03bd0253e6
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2024-03-12 17:23:03 -08:00
Thiago Macieira 025c45d628 tst_QStorageInfo: try harder to make the free space change
This merges the tempFile and caching tests, which had been updated in
commit ae03ffaffd to attempt other
filesystems than APFS and btrfs.

Instead of adding yet another item to the list (xfs), let's insist by
writing more and flushing the OS buffers. Local testing says that btrfs
usually updates after the first write(), no later than the second, and
that APFS and XFS "just works" now (without the fsync() even).

Pick-to: 6.7
Fixes: QTBUG-123151
Change-Id: I6818d78a57394e37857bfffd17bbe7427307efc4
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2024-03-12 14:34:32 -07:00
Ahmad Samir d7340d5c31 tst_qfile: fix GCC 13.2.1 compiler warning [-Wenum-compare]
By using "wt" for all OS's; according to Thiago the 't' is ignored
everywhere except on Windows.

tests/auto/corelib/io/qfile/tst_qfile.cpp:2846:70: warning: comparison
between ‘enum QOperatingSystemVersionBase::OSType’ and ‘enum
QOperatingSystemVersion::OSType’ [-Wenum-compare]
2846 |     const char *openMode = QOperatingSystemVersion::current().type() != QOperatingSystemVersion::Windows
|                            ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Amends 3446313c7a

Pick-to: 6.7 6.6 6.5 6.2
Change-Id: I310d7d6ce3833756ffdc47b000e052ef3afdfdef
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-03-12 23:28:34 +02:00
Dennis Oberst dea548ef04 qstringalgorithms: include <iterator> in favor of <string.h>
The switch from <string> to <string.h> dropped the definition of
std::size. Include <iterator> since <string.h> is no longer used to
pull in std::size.

Amends: dc2ae08e02.

Pick-to: 6.7
Change-Id: Ib742538eb5d21c77fcae7ee9abb6d5329bbcfd63
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2024-03-12 22:27:21 +01:00
Ivan Solovev 285a2a75b4 QVariant: use comparison helper macros
The relational operators were removed in
8652c79df0 with the argument that they
do not have a total order. Back than it was a valid argument, because Qt
did not support any of the C++20 ordering types.

Now Qt has its own implementation for all three ordering types, so we
could technically add relational operators and claim that QVariant
provides partial ordering.

However, that could potentially lead to many bugs and/or unexpected
results, if people start using QVariant as a key in std::map/QMap
containers.

We do not want that to happen, so we only use the helper macros to
implement (in)equality operators.

This commit also extends the unit tests, providing more extensive
testing of (in)equality operators and the pre-existing
QVariant::compare() method.

Fixes: QTBUG-113234
Change-Id: I783f3b5df552da782627f4ed0a5bb1b577753a23
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-03-12 21:51:43 +01:00
Thiago Macieira 33159f5e0f QDataStream: make the public-ish private members smaller in Qt 7
pahole says:
  class QScopedPointer<QDataStreamPrivate> d;      /*     0     8 */
  class QIODevice *          dev;                  /*     8     8 */
  bool                       owndev;               /*    16     1 */
  bool                       noswap;               /*    17     1 */
  quint8                     fpPrecision;          /*    18     1 */
  quint8                     q_status;             /*    19     1 */
  enum ByteOrder             byteorder;            /*    20     4 */
  int                        ver;                  /*    24     4 */
  quint16                    transactionDepth;     /*    28     2 */
  /* size: 32, cachelines: 1, members: 10 */

Which is unnecessary overhead. The previous commit took care of
byteorder for Qt 7; this one reduces the size a bit more, to 16 bytes on
32-bit systems and 24 on 64-bit ones.

After this, pahole says for the bootstrap library:
  class QScopedPointer<QDataStreamPrivate> d;      /*     0     8 */
  class QIODevice *          dev;                  /*     8     8 */
  bool                       owndev;               /*    16     1 */
  bool                       noswap;               /*    17     1 */
  quint8                     fpPrecision;          /*    18     1 */
  quint8                     q_status;             /*    19     1 */
  enum Version               ver;                  /*    20     1 */
  /* XXX 1 byte hole, try to pack */
  quint16                    transactionDepth;     /*    22     2 */
  /* size: 24, cachelines: 1, members: 9 */

Further packing isn't possible, because of the alignment at 64-bit for
this class.

Change-Id: I50e2158aeade4256ad1dfffd17b29b80237a8c5b
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2024-03-12 12:51:43 -08:00
Thiago Macieira b18ba91c67 QDataStream: don't store the byteorder member in Qt 7
It's redundant with the noswap member: we swap if the stream byte order
is the opposite of the CPU's and don't swap if it is the same. That the
default is to swap is another reason why people should stop using
QDataStream (though CBOR also stores numbers in big-endian).

Change-Id: I50e2158aeade4256ad1dfffd17b29adc2b698ead
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2024-03-12 12:51:43 -08:00
Thiago Macieira 6dfc92abe8 QDataStream: use NSDMI
Just a little clean-up to avoid repetition.

Change-Id: I50e2158aeade4256ad1dfffd17b29a5b36c71ddc
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-03-12 12:51:43 -08:00
Thiago Macieira 9b2835e464 QDataStream: Move trasactionDepth to the main class
The q_status member has too much space dedicated to it: 32 bits. So we
can shrink it to a mere 8 bits and move it up to the 1-byte padding hole
and repurpose the space it used to use. This only works because the
q_status member was not accessed by any inline function before Qt 6.8
(see commit fc23fa459c).

After this, pahole says:
  class QScopedPointer<QDataStreamPrivate> d;      /*     0     8 */
  class QIODevice *          dev;                  /*     8     8 */
  bool                       owndev;               /*    16     1 */
  bool                       noswap;               /*    17     1 */
  quint8                     fpPrecision;          /*    18     1 */
  quint8                     q_status;             /*    19     1 */
  enum ByteOrder             byteorder;            /*    20     4 */
  int                        ver;                  /*    24     4 */
  quint16                    transactionDepth;     /*    28     2 */
  /* size: 32, cachelines: 1, members: 10 */

That leaves 16 bits of tail padding unused, so reduces the maximum
number of nested transactions to 65536. That is to support a Qt 7 layout
in an upcoming commit.

Change-Id: I50e2158aeade4256ad1dfffd17b29d75fd13f472
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2024-03-12 12:51:43 -08:00
Thiago Macieira 4aa0eab263 QDataStream: inline floatingPointPrecision()
There is a 2-byte padding in all architectures between the noswap member
and byteorder, because the latter requires a 32-bit alignment. So we can
use this space to store this little-used field and avoid one more reason
for QDataStreamPrivate.

Now:
  class QScopedPointer<QDataStreamPrivate> d;      /*     0     8 */
  class QIODevice *          dev;                  /*     8     8 */
  bool                       owndev;               /*    16     1 */
  bool                       noswap;               /*    17     1 */
  quint8                     fpPrecision;          /*    18     1 */
  /* XXX 1 byte hole, try to pack */
  enum ByteOrder             byteorder;            /*    20     4 */
  int                        ver;                  /*    24     4 */
  enum Status                q_status;             /*    28     4 */
  /* size: 32, cachelines: 1, members: 9 */

Change-Id: I50e2158aeade4256ad1dfffd17b29c2c5db02c12
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2024-03-12 12:51:42 -08:00
Alexandru Croitor 566b726b84 CMake: Create alias targets for plugin init targets
When building tests in-tree targeting iOS, we run
_qt_internal_finalize_executable via
qt_internal_add_test_finalizers.
This in turn calls __qt_internal_apply_plugin_imports_finalizer_mode
which tries to link to versioned plugin int targets.

Because the linked plugin init target is built in-tree as well, and
did not have versioned alias targets created, configuration fails
with:
 Target "tst_baseline_qsvgrenderer" links to:

    Qt6::QSvgIconPlugin_init
 but the target was not found.

Make sure to create versioned alias targets for the plugin init
targets.

Amends 6c9f4f5ebc

Pick-to: 6.7
Fixes: QTBUG-123186
Task-number: QTBUG-122181
Change-Id: I0048b724d465dc3c176d238d144feb072262d76e
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-03-12 21:51:42 +01:00
Laszlo Agocs bce2522ad0 rhi: Add basic support for specifying a view format for a texture
We have to be able to strip the _SRGB nonsense from the render target
view formats when rendering into textures that are provided from an
external engine (e.g. OpenXR) and are forced onto us with formats such
as VK_FORMAT_R8G8B8A8_SRGB.

This highlights some limitation of the current system, which has very
limited handling of sRGB stuff since proper renderers such as Qt Quick
3D have first class support for linearization and converting to sRGB
at the end of their shading pipeline, so _SRGB format textures are
never used in practice.

OpenGL has an issue which is different from everything else, namely
that we do not correctly do the glEnable/Disable on GL_FRAMEBUFFER_SRGB.
The QOpenGLExtensions flag is not what we need. We need to know if the
sRGB-conversion-on-write is supported or not, not that some framebuffer
is sRGB-capable. So do our own query based on the desktop and the ES
extension (GL_EXT_sRGB_write_control is something we never checked for,
but that is the appropriate GLES extension, supported on the Quest 3
for instance) This is now corrected in the gl backend. This means that
the colors will no longer be "too bright" with OpenGL ES and multiview
on the Quest 3 for example.

Unlike OpenGL, Vulkan and D3D automatically convert in shader reads and
writes when the shader resource view or the render target view has a
_SRGB format. (which we get by default since we pass on the texture
format) Getting a second linear->sRGB conversion on the already sRGB
data generated by e.g. Qt Quick 3D is just wrong.

Allow solving this by a new function that can be optionally called to
say we want (RGBA8, srgb=false), i.e. VK_FORMAT_R8G8B8A8_UNORM, for
the views.

Of course, reality is more complicated. D3D11 for instance does not
allow "casting" a fully typed texture, we'd need to use a _TYPELESS
format for that (possibly with other consequences), so skip D3D11.
For D3D12 this should work from Windows 1703 on.

Implementing for Metal is also left as a future exercise - it is neither
needed at the moment within Qt, nor is it trivial, because view textures
have to be created explicitly in Metal, normally we just work with the
MTLTexture as-is, not with views.

Task-number: QTBUG-122288
Task-number: QTBUG-122614
Change-Id: I8aea4e892b308d48f0bf18bdef481e460fbc9d47
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2024-03-12 20:27:42 +01:00
Alexey Edelev 173164cd47 "Simplify" versionless targets
Versionless targets in Qt6 are interface libraries that link the
versioned libraries using the INTERFACE link type. This makes the
linking chain more complicated than it can be. Also we miss some
significant interface properties in the versionless targets comparing
to the versioned targets.

The new approach manually generates the versionless targets, instead
of using CMake exports.

For CMake versions < 3.18 we now create a copy of the versioned
targets. The copy includes all the relevant INTERFACE properties from
the versioned targets and imported locations for all configs.

For CMake versions >= 3.18 we now create the versionless target ALIASes
which should behave give the transparent access to the versioned
targets.

Using the QT_USE_OLD_VERSION_LESS_TARGETS flag you may force the
behavor of the CMake versions <= 3.18

The change is partial workaround for QTBUG-86533.

Task-number: QTBUG-114706
Change-Id: Iafadf6154eb4912df0697648c031fcc1cbde04e0
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2024-03-12 20:27:42 +01:00
Wladimir Leuschner a1d18276a8 QWindows11Style: HighDPI aware progressbars
Draw progressbars and progressbar handles on sub-pixel coordinates to be
HighDPI aware.

Pick-to: 6.7
Change-Id: Ib4f39c3b3a05d9f47c045dd6032d7544b7add175
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2024-03-12 20:27:42 +01:00
Wladimir Leuschner 91df9d1bbf QWindows11Style: HighDPI aware scrollbars
Draw scrollbars and scrollbar handles on sub-pixel coordinates to be
HighDPI aware.

Pick-to: 6.7
Change-Id: Iab7c8566f31a58f83d03ec6644be68bf130682ce
Reviewed-by: Alessandro Portale <alessandro.portale@qt.io>
2024-03-12 19:27:42 +00:00
Mårten Nordheim 8de1ed8979 tst_QNetworkReply: update and speed up httpConnectionCount
Because we will do a small wait after the final connection (to see
if there are any unexpected extra connections) we can save some time
by reducing _how long_ we wait for it.
In general we only need an extra long wait for the first connection,
subsequent connections are faster.
So we change the loop structure from looping until we hit 20(!)
connections, when anything larger than 6 will fail the test anyway!
And use qWaitFor instead of repeatedly calling enterLoop and checking
the state of an ElapsedTimer, the total wait time is not super
interesting, and made it a guarantee that the test would take 10
seconds.

While we are here, update the attribute we use to test HTTP/2
connections. We were previously enabling http/2, but this is the new
default so it's not needed. We do, however, need to enable h2c if we
want to see it trying to upgrade to http/2 over cleartext.

Not a big issue, so we don't pick it very far back.

Pick-to: 6.7
Change-Id: Ia314ae2827ab8a8baaa4af2c5136c5e531bcb1f8
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2024-03-12 14:23:57 +01:00
Mårten Nordheim 6aee3342e9 tst_QMutex[qnx]: increase system timer resolution
I don't know what it is but it's not 1, because it is quite
often flaky in these tests. A single failure leads to deadlock
that takes 5 minutes to fail. Then a rerun might do another
5 minutes and fail the integration, or it will pass but take
longer to do so.

Pick-to: 6.7 6.6 6.5
Change-Id: I188276df7800b00a20dbe39edee91c582f0a82a7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-03-12 14:23:57 +01:00
Mårten Nordheim be6644c1f2 Http: fix issues after early abort()
There were a few issues to deal with. One of them was that we would
print a warning about an internal error if we tried to *set* an error
on the reply after it had been cancelled. That's kind of unavoidable
since these things happen in different threads, so just ignore the
error if we have been cancelled.

The other issue was that, for a request with data, we will buffer the
data to send, and _only then_ do we start the request. This happens
asynchronously, so the user can abort the request before it has finished
buffering. Once it finished buffering it would set the state of the
request to "Working", ignoring that it was already marked "Finished".

Fixes: QTBUG-118209
Fixes: QTBUG-36127
Pick-to: 6.7 6.6
Change-Id: Idbf1fd8a80530d802bee04c4b0a6783cba4992d3
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2024-03-12 14:23:56 +01:00
Mårten Nordheim 22c99cf498 QHttp2ProtocolHandler: prevent truncation in arithmetic operations
On 64-bit systems, both the requests.size() and the
activeStreams.size() were truncated to uint32_t values from int64_t
ones. While extremely unlikely that either will contain more than 4Gi
elements, avoid the truncation by verifying that the `max` amount of
streams is larger than the activeStreams, and then using size_t for
the range.

Pick-to: 6.7
Change-Id: I50644cb634bab0f020acf9aea1d03744b11dbe51
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Juha Vuolle <juha.vuolle@qt.io>
2024-03-12 14:23:54 +01:00
Mårten Nordheim c468dfedd6 tst_QFactoryLoader: includemocs
For some reason android in CI failed to include the
moc file through the mocs_compilation file.

It's an issue that needs some investigation, but
in the interest of time just include the moc file
directly.

Pick-to: 6.7 6.6 6.5
Change-Id: I079588598a6f4137ef1fccc482795d703b59bc6e
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-03-12 14:23:42 +01:00
Thiago Macieira 418dcf88f8 QProcess/Unix: fix improper restoration of signal mask and cancel state
By just moving the handling of the child process' desired target
directory below the initialization of either the signal mask and PThread
cancel state, without that "return".

Commit 52ed6af527 ("QProcess/Unix: merge
some code from startProcess() and startDetached()") introduced
QChildProcess and merged the functionality of PThreadCancelGuard into
it. But it added that "return;" to the code path failing to opendirfd()
the target directory, meaning that the QChildProcess constructor could
exit without calling disableThreadCancellations(), but the destructor
would still run restoreThreadCancellations() every time the opening
failed. And we have tests for that: setNonExistentWorkingDirectory and
detachedSetNonExistentWorkingDirectory.

For the cancel state, the uninitialized variable we ended up passing to
pthread_setcancelstate() was probably harmless, because the cancellation
state is almost always active and the variable would have been non-zero.
And we don't test pthread cancellation, so we would never notice the
problem.

But commit bd32c7d705 ("QProcess/Unix:
block all Unix signals between vfork() and exec()") introduced a block
of the Unix signals with the same uninitialized variable problem. Unlike
the PThread cancellation state, the original signal mask would usually
be empty, so the "restoration" would actually mask signals we wanted.
And one such important signal is SIGCHLD, used by QProcess/forkfd when
*not* using vfork semantics. This meant that tests that had a child
process modifier (meaning, they wouldn't use vfork semantics) would end
up timing out because we'd never get the SIGCHLD that told us the child
had exited.

Fixes: QTBUG-123083
Pick-to: 6.7 6.7.0
Change-Id: I1362eb554b97dc012d02eab2dbca90b06728460e
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-03-12 04:38:57 -07:00
Joerg Bornemann b481393941 CMake: Add public helper _qt_internal_add_phony_target
This function can be used to create a custom target like
update_translations or all_qmllint that should be excluded from build
and be triggered by the user.

The function works around certain peculiarities of the Visual Studio
project generators that are described at length in QTBUG-115166 and
associated patches.

Follow-up patches in qttools and qtdeclarative will use this function
and remove duplicated code.

Task-number: QTBUG-115166
Task-number: QTBUG-118980
Change-Id: I87b89a658f35a5a09e3f7b04bdd5cae2166f8d62
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2024-03-12 12:38:57 +01:00
Mårten Nordheim 2d521002ca Schannel: fix handling of empty ciphers list
Contrary to OpenSSL the new ciphers support in Schannel
would disallow all ciphers when the list was empty.
The pre-existing behavior was to use the default list.

Amends f7792d2b6d

Pick-to: 6.7
Change-Id: I0e79013ac86261c4afa4affb28cb1838177c12de
Reviewed-by: Tobias Koenig <tobias.koenig@kdab.com>
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2024-03-12 12:38:57 +01:00
Lucie Gérard 0886035bcd Correct license for qbatchedtestrunner.in.cpp file
File is is part of the internal test infrastructure.
According to QUIP-18 [1], all test files should be
LicenseRef-Qt-Commercial OR GPL-3.0-only

[1]: https://contribute.qt-project.org/quips/18

Pick-to: 6.7
Task-number: QTBUG-121787
Change-Id: Ia5bc4e0abeea210ee501596330b2b63216e9e9c7
Reviewed-by: Kai Köhne <kai.koehne@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2024-03-12 12:38:56 +01:00
Allan Sandfeld Jensen fdb219b68e Fix CodeChecker warnings
Ensure move where it makes sense, and remove it where it doesnt

Change-Id: I988d7ff44f1d7898a967130fa53ed6ec5690e778
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2024-03-12 12:38:56 +01:00
Ivan Solovev 1c9e155b05 QCborStreamReader: rename toStringish() -> readAllStringish()
Amends 8af346c1f6 and
1d9137e13f.

Found in 6.7 API review

Task-number: QTBUG-123115
Pick-to: 6.7 6.7.0
Change-Id: I98d79274f26f3439302a59181401b6e244fe5202
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-03-12 05:36:54 +01:00
Ivan Solovev cc91132864 QCborStreamReader: rename appendToType() -> readAndAppendToType()
Amends ff034ebbfa.

Found in 6.7 API review

Task-number: QTBUG-123115
Pick-to: 6.7 6.7.0
Change-Id: Id5e95aacffcb633701d4d635d2bf8af70984903e
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-03-12 05:36:49 +01:00
Alexandru Croitor a2e0f3dfbd CMake: Use qt_internal_add_example for bindableproperties
bindableproperties is the actual project, not a subdirectory with
separate examples. It should use qt_internal_add_example.

Pick-to: 6.6 6.7
Task-number: QTBUG-90820
Task-number: QTBUG-123096
Change-Id: I409d20e035956e6c236f84721b3c6882893cd547
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2024-03-11 13:48:24 +01:00
Alexandru Croitor dd052a0a01 CMake: Warn when examples are not added via qt_internal_add_example
To ensure examples can be built as ExternalProjects, the example
subdirectories need to be added via qt_internal_add_example rather
than just add_subdirectory.
qt_internal_add_example is also needed for correct installation of
example sources.

To catch examples that are still not added via
qt_internal_add_example, set a QT_WARN_ABOUT_EXAMPLE_ADD_SUBDIRECTORY
variable at the top of the examples/CMakeLists.txt directory scope
and show a warning in qt_add_executable whenever that variable is
TRUE.

Calls of qt_internal_add_example will set the variable to FALSE,
making sure the warning is not shown for properly added examples.

This is limited to developer builds and can be opted out of via the
QT_NO_WARN_ABOUT_EXAMPLE_ADD_SUBDIRECTORY_WARNING variable.

qt_add_executable is used as the 'hook' for showing the error, because
that is the most likely function to be used in examples.
We don't use qt_standard_project_setup in all projects yet, so we
don't want to use that one.

Task-number: QTBUG-90820
Task-number: QTBUG-123096
Change-Id: I7a0b0b2cc60c70903db03b56c06494c127a62420
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2024-03-11 13:48:23 +01:00
Alexandru Croitor 06fef6219e CMake: Adjust QT_ADDITIONAL_QML_PLUGIN_GLOB_PREFIXES for EP examples
Make sure to consider all qt_prefixes for adjusting
QT_ADDITIONAL_QML_PLUGIN_GLOB_PREFIXES with locations where qml plugin
config files might be present.

Task-number: QTBUG-90820
Task-number: QTBUG-96232
Change-Id: I5a7eec434635db1953871d735e2420c331ccee48
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2024-03-11 13:48:08 +01:00
Alexandru Croitor 40fa36db22 CMake: Allow specifying additional glob paths for QmlPlugins.cmake
Currently we hard-code to look for qml plugin Config.cmake files
in the current list dir, whether the Qt6Qml directory is.

This is not sufficient for finding qml plugins in a prefix build of a
repo that has not been installed yet.
For example qtquick3d plugins will be in
qtquick3d_build_dir/lib/cmake/Qt6Qml/QmlPlugins, which
won't be picked up by the Qt6Qml Config file in the installed Qt
location.

Allow specifying extra qml plugin glob prefixes via a new
QT_ADDITIONAL_QML_PLUGIN_GLOB_PREFIXES variable.
This is similar to QT_ADDITIONAL_PACKAGES_PREFIX_PATH.

Any path specified via QT_ADDITIONAL_QML_PLUGIN_GLOB_PREFIXES
will have the
 QmlPlugins/${INSTALL_CMAKE_NAMESPACE}*Config.cmake
glob appended to it, and then used for globbing files in that
location, after processing the main location wherever Qt6Qml is.

This will be used by ExternalProject example machinery.

Task-number: QTBUG-90820
Task-number: QTBUG-96232
Change-Id: I469863c965b8b13cf007c611976a64fbff6e9111
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2024-03-11 13:48:03 +01:00
Alexandru Croitor c668dd4044 CMake: Disable ExternalProject examples for -debug-and-release builds
Unfortunately when using CMake <= 3.27 together with
-debug-and-release, it's not possible to reliably build examples as
external projects due to clobbered files in the same build dir.

Disable building examples as EPs in such a case.

Task-number: QTBUG-90820
Task-number: QTBUG-96232
Change-Id: Icea9fdab47986c2608e1952a0bbae72365ac7a62
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-03-11 13:48:01 +01:00
Alexandru Croitor 31c5d50e84 CMake: Adjust CMAKE_MODULE_PATH for ExternalProject examples
When building EP examples for a repo that defines a bundled library,
we need to make sure the relevant FindWrapBundledFooConfigExtra.cmake
file is found when looking up dependencies.

For a prefix build, that file is placed in the build dir of the repo.
Use the list of qt_prefixes that includes the build dir of the repo,
append lib/cmake/Qt6 to it and pass that as additional values to
the CMAKE_MODULE_PATH variable of the external project.

Task-number: QTBUG-90820
Task-number: QTBUG-96232
Change-Id: I85d5f360380856fcfb8be7235b8365dcf15aa0c0
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-03-11 13:47:59 +01:00
Alexandru Croitor cc537d927b CMake: Fix syncqt IMPORTED_LOCATION path for multi-config builds
When building examples as ExternalProjects as part of a multi-config
qtbase build, syncqt can not be located with the following error:

CMake Error at Qt6CoreToolsAdditionalTargetInfo.cmake:10 (message):
   Unable to add configure time executable Qt6::syncqt
   qtbase/libexec/syncqt doesn't exist
Call Stack (most recent call first):
  qtbase/lib/cmake/Qt6CoreTools/Qt6CoreToolsConfig.cmake:44 (include)
  qtbase/cmake/QtPublicDependencyHelpers.cmake:65 (find_package)
  qtbase/lib/cmake/Qt6Core/Qt6CoreDependencies.cmake:34
      (_qt_internal_find_tool_dependencies)
  qtbase/lib/cmake/Qt6Core/Qt6CoreConfig.cmake:42 (include)
  qtbase/lib/cmake/Qt6/Qt6Config.cmake:165 (find_package)
  CMakeLists.txt:13 (find_package)

The Qt6CoreToolsAdditionalTargetInfo.cmake file is used both for
install(EXPORT) Config files as well as export(EXPORT) Config files,
and in the latter case, the path that syncqt is looked up in is not
correct because syncqt is not yet installed.

In addition to checking whether syncqt exists in the install path,
also check if it exists in the build dir.

Ideally the additional path would be stored in a separate file that
is not installed, but the current code infrastructure does not provide
such a feature. Because we store a relative path instead of an
absolute path, the build path does not leak, so the situation is
bearable.

Task-number: QTBUG-90820
Task-number: QTBUG-96232
Change-Id: I16ad5c280751e050bc9b039ebd38ec9a66a6554c
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-03-11 13:47:57 +01:00
Alexandru Croitor 20bd9fad1c CMake: Pass CMAKE_MODULE_PATH to external project examples
Some examples depend on FindWrapFoo.cmake scripts that are part of
a repo. An example is qtgrpc with FindWrapProtoc.cmake.

These need to be available when building external project examples in
a prefix build where the repo is not installed yet, and thus the
source dir FindWrap scripts need to be used instead.

Make sure to pass the value of CMAKE_MODULE_PATH to the external
projects to ensure these scripts are found. CMAKE_MODULE_PATH is
populated by qt_set_up_build_internals_paths as part of the
qt repo build.

Task-number: QTBUG-90820
Task-number: QTBUG-96232
Change-Id: I3e977919bc137ed60e8eb9300625e5d8b87b373e
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-03-11 13:47:55 +01:00
Alexandru Croitor 43d0c5ed6e CMake: Allow passing extra variables to external project examples
In some repos we need to be able to pass extra cache variables to find
3rd party packages when building examples as external projects.

Introduce QT_EXAMPLE_CMAKE_VARS_TO_PASS to allow passing vars like
OpenSSL_ROOT or Protobuf_ROOT if they are set in the repo project.

It should be noted that QT_EXAMPLE_CMAKE_VARS_TO_PASS expects a
special syntax for its values, of the from VAR_NAME:CMAKE_TYPE, due
to the pre-existing implementation on how we pass variables
to ExternalProject.

Task-number: QTBUG-90820
Task-number: QTBUG-96232
Change-Id: Ie3e74d4fde106f947d12e51d27e41a310157aab6
Reviewed-by:  Alexey Edelev <alexey.edelev@qt.io>
2024-03-11 13:47:53 +01:00
Christian Ehrlicher e65dc19332 SQL/QSqlField: deprecate internal functions setSqlType()/typeID()
These functions set/get the db-specific internal sql type but it's not
used in any of the sql plugins since ages. Any external plugin using this for some reason must be ported away until Qt7.

Change-Id: Ifb33e9d3be0b80fb4d0979d31436e89ea6a8208b
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2024-03-10 18:16:00 +00:00
Christian Ehrlicher e2e818483f SQL/MySQL: retrieve default column value for QSqlDatabase::record()
Retrieve the default value (if set) of a column during
QSqlDatabase::record() but not for QSqlQuery::record() as it's done for
the other drivers which support retrieving the default column value.

Fixes: QTBUG-122723
Change-Id: I92e052bfa6d88e019c0151fbcbc1483a65770c55
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-03-10 19:15:47 +01:00
Christian Ehrlicher 453e66c61b SQL/ODBC: sync usage of qSqlWarning()
Replace all qWarning() with qSqlWarning() to be able to get additional
error/warning output from the handles.

Change-Id: Ieaa947fe06216b3d20b20c509080fc409803683b
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-03-10 19:15:46 +01:00
Giuseppe D'Angelo 003cef9d40 PNG: preserve ICC profiles that QColorSpace does not handle
QColorSpace::isValid() returns true if QColorSpace can handle the
profile. When called on a QColorSpace obtained via
QColorSpace::fromIccProfile, this doesn't necessarily mean that the ICC
profile itself was invalid; it could be that the ICC data was valid, but
QColorSpace didn't know how to use it. This is especially true on Qt <=
6.7, where only XYZ/RGB matrix profiles were supported.

We don't fully parse ICC v4, and we're lacking an API to differentiate
between "ICC data was valid but QColorSpace doesn't handle it" vs "ICC
data was invalid".

Still, an invalid QColorSpace will still the original ICC data, so it
can be saved again without loss of information.

So: 1) when loading a PNG with embedded ICC data, keep the loaded profile
even if it's "invalid"; 2) when writing a PNG, check if we have ICC data
to save, and unconditionally write it if it's the case.

This avoids data loss in the two directions.

This work has been kindly sponsored by the QGIS project
(https://qgis.org/).

Pick-to: 6.7 6.6 6.5
Change-Id: I1f27f603acbca1590c820e80f52f3b994f5ea5c7
Reviewed-by: Allan Sandfeld Jensen <allan.jensen@qt.io>
2024-03-10 11:59:32 +01:00
Cristian Adam 0804109d68 Android: Do Thread.sleep before loading Qt libraries in Debug Mode
Amends 269187bfa2 which added the sleep
but just loading the main library.

This commit moves the delay before any library is being loaded. Also log
the fact the thread is sleeping and advertise how to use the env
QT_ANDROID_DEBUGGER_MAIN_THREAD_SLEEP_MS variable.

Fixes: QTCREATORBUG-30425
Pick-to: 6.7 6.7.0
Change-Id: Ic1370e0b9fcce8c6074f768e5d94e5aa4a0a7824
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
2024-03-09 20:35:32 +00:00
Christian Ehrlicher e68c3f025e Don't show mnemonics in dockwidget titles
Dockwidget title accelerators doesn't work in dock widgets, so don't
show them.
This amends cc67b25579.

Fixes: QTBUG-86407
Pick-to: 6.7 6.6
Change-Id: I83fb2da1304d1e2b5eedfc127e5db3d322756d06
Reviewed-by: Sune Vuorela <sune@vuorela.dk>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-03-09 13:52:22 +01:00
Christian Ehrlicher 1ac58f4ba3 QStyleSheetStyle: don't draw check indicator twice
When the styled check indicator is smaller than the one from the base
style, then the clip region was to small and the check indicator from
the base style was also drawn. Therefore add both check rects to the
clipRegion.

Pick-to: 6.7 6.6 6.5
Task-number: QTBUG-102820
Fixes: QTBUG-122821
Fixes: QTBUG-122825
Change-Id: I1b5b8d70d66475bbfa4a40652dc3fdd4cc670c32
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-03-09 13:52:20 +01:00
Tor Arne Vestbø fde358dd90 Delete QComboBoxPrivateContainer while the combo box is still alive
Destroying the QComboxBox will, once it reaches the QWidget destructor,
close all popups, including the QComboBoxPrivateContainer, which emits
signals on behalf of the QComboBox, that is now gone.

Regression after d8e1100548.

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.

See 0e72a846d3.

We also need a QPointer for the QComboBoxPrivateContainer, as the
container may be deleted from outside QComboBox, as seen in the
tst_QGraphicsProxyWidget::bypassGraphicsProxyWidget() test, where
the QGraphicsProxyWidget proxies the QComboBoxPrivateContainer.

Pick-to: 6.7 6.6 6.5
Change-Id: I7590cc2821c73a6762f281504aa62f0c2b472252
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2024-03-09 13:52:19 +01:00
Giuseppe D'Angelo 0fa0d01c36 QT_NO_QEXCHANGE: add docs
Pick-to: 6.7 6.6
Change-Id: Ibb54de391a580814c9392b262966e2e2947364d9
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2024-03-09 10:34:08 +01:00
Eirik Aavitsland a5a6b657a7 Avoid QRubberBand leaving artefacts in QListView
On hidpi screens, the painted edges of the rubberband can extend
beyond the selection rect because of scaling. Extend the area to be
updated by 2x frame width, when the rubberband changes.

Fixes: QTBUG-113432
Pick-to: 6.7 6.6 6.5
Change-Id: Ie7aec1fefdc3fbf71c63952b693f462697adf849
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Eirik Aavitsland <eirik.aavitsland@qt.io>
2024-03-08 20:50:51 +01:00
Edward Welbourne cb5aac06cf Correct documentation of QDateTime's comparisons
These previously claimed that date-times with different date, time or
zone are different; as pointed out by Marcus Tillmanns, this is not
true. Corrected the documentation to talk about representing the same
moment in time.

In the process, renamed the snippet shared with several other docs,
since the snippet name only focused on the other part of what it was
saying.

Pick-to: 6.7 6.6 6.5 6.2 5.15
Fixes: QTBUG-122973
Change-Id: Ifd74da84aad0b0dca688c131b6ae6a7b65633225
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-03-08 18:31:47 +01:00
Giuseppe D'Angelo 682d057aab QThread/Win: set the thread name on non-MSVC also
SetThreadDescription is a Win32 API provided by Kernel32.dll, the only
thing that MinGW is missing is the declaration of the function. We can
provide it ourselves.

Change-Id: Iad5fc6cb7b6eb190310f5888326b65f50ddbdca8
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2024-03-08 16:44:18 +00:00