Commit Graph

14058 Commits

Author SHA1 Message Date
Thiago Macieira
26dd7fe4ed CMake: remove "res_ninit" feature and collapse to just "libresolv"
Testing for "res_ninit" when WrapResolv.cmake has already checked for
far more complex functions was pointless. Instead, just accept the
library that was found by find_package() as good enough and rename the
feature as "libresolv".

Amends 4a46ba1209 and
68b625901f.

Change-Id: Ib5ce7a497e034ebabb2cfffd1762c0afa2fac6e0
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-27 12:57:16 -07:00
Ievgenii Meshcheriakov
4f65f91d6f QDBus: Fix typo in a function name
Rename connectionCapabilies -> connectionCapabilities

Change-Id: I07deff1b944b30404548181d5c930b76fb1a575c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-26 15:46:34 +02:00
Thiago Macieira
432d67b43f QDnsLookup: add TimeoutError for timeouts
We were getting InvalidReplyError because it was simply unknown, which
is not very useful. Previously, the Unix code used res_nquery(), which
does not return timeouts as a condition. It returns -1 if a timeout did
happen, but the content in errno could be a left-over from a previous
timeout (see the "Not a typewriter"[1] problem).

With the rewrite to using res_nmkquery() and res_nsend() from the
previous commits, we can rely on errno being set properly by
res_nsend().

$ $objdir/tests/manual/qdnslookup/qdnslookup @0.0.0.1
; <<>> QDnsLookup 6.6.0 <<>> qdnslookup @0.0.0.1
;; status: TimeoutError (Request timed out)
;; QUESTION:
;qt-project.org                 IN A

;; Query time: 10008 ms
;; SERVER: 0.0.0.1#53

Tested on FreeBSD, Linux, macOS, and Windows.

[1] https://en.wikipedia.org/wiki/Not_a_typewriter

Change-Id: I3e3bfef633af4130a03afffd175e31958247f9b1
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-26 06:46:33 -07:00
Volker Hilsheimer
bdbfa7757a QWindow test: Blacklist enterLeaveOnWindowShowHide
This test fails too frequently on Android and RHEL to leave in as
significant. The bug report is already closed after timeouts were
extended, so perhaps we just have to accept the status quo. No
point in keeping tickets open for tests that we can't get stable on
some platforms.

Pick-to: 6.5
Task-number: QTBUG-102239
Change-Id: I54b8ae821e93b3e1f24acd67a2e84ef405388667
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-05-25 12:07:35 +00:00
Volker Hilsheimer
6a2b029138 QLabel: always show the context menu created by the control
Amends e718818745, after which a context
menu was only shown if the format was rich text and there was a link at
the position of the click.

We always want to leave it up to the control to create a context menu,
so only return early if there is no control. The control will then
respect content at the position (i.e. link or not) and text interaction
flags, and create the menu based on that. I.e. a rich text label with
selectable text should still show "Select All" in the context menu, also
if not clicking on a link.

Add a test case to verify that the context menu event got accepted
as expected, which indicates that the label showed a menu.

Pick-to: 6.5
Change-Id: Ib2b36286e4f1253d10489b5add83e8cdd7197a06
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
2023-05-25 14:06:57 +02:00
Volker Hilsheimer
16cf095bd5 Silence warning from unused variable in QObject test
It's not needed, but makes the point for having a mutable lambda in the
first place.

Change-Id: I483862d6aee90bb62d4b5363c56a80bb05e14df7
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-25 14:06:55 +02:00
Volker Hilsheimer
833da1f31c QPauseAnimation test: add QNX to platforms that might fail
The noTimerUpdates test has been quite flaky since the optimization
of single shot timers in 87535e4e43.

Since we run QNX tests in QEMU, it's hard to guarantee anything that
involves timers, so tagging that platform as one of those that have a
bad timer resolution.

Change-Id: I6567ea0dee859a207d4b9f659a02e805a2f87d63
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-05-25 14:06:50 +02:00
Ievgenii Meshcheriakov
c968405455 QDBusAbstractAdaptor: Send signals using correct interface
When forwarding a signal, associate this signal with its
enclosing metaobject instead of its sender's metaobject.
Those two may be different if the signal is declared in
a base class.

Add a regression test into tst_qdbusconnection.

Fixes: QTBUG-33142
Pick-to: 6.5
Change-Id: I532ab3bb6c0671a480568f46d63fceff0c82c097
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-05-25 11:30:40 +02:00
Christian Ehrlicher
048a68c1e9 SQL: Make QSqlDatabase::DriverDict creation thread-safe
Make the QSqlDatabase::DriverDict thread-safe and make sure it's
properly cleaned up on destruction.

Pick-to: 6.5 6.2 5.15
Fixes: QTBUG-112961
Change-Id: I1ff70e477579231754ef829fdede944d6042894d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-24 17:27:55 +02:00
Mårten Nordheim
c891d16490 Skip diffie-hellman parameter test when not supported
Pick-to: 6.5
Change-Id: I0c21aeea813ee48f8c62689dafce6f7fb9620001
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-05-24 13:08:34 +02:00
Thiago Macieira
282b078fca tst_QDnsLookup: add a test for setNameserver
I had to write a sample query test to ensure that those servers can be
reached. They can't from the my corporate network, for example:

QDEBUG : tst_QDnsLookup::setNameserver(normal) QHostAddress("8.8.8.8") discarded: "Network operation timed out"
QDEBUG : tst_QDnsLookup::setNameserver(normal) QHostAddress("2001:4860:4860::8888") discarded: "Network unreachable"
QDEBUG : tst_QDnsLookup::setNameserver(normal) QHostAddress("1.1.1.1") discarded: "Connection refused"
QDEBUG : tst_QDnsLookup::setNameserver(normal) QHostAddress("2606:4700:4700::1111") discarded: "Network unreachable"

This will also take care of ignoring the IPv6 servers on systems without
it (as above).

Change-Id: I3e3bfef633af4130a03afffd175de18af24add70
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-23 21:23:43 -07:00
Thiago Macieira
bce7009f55 QDnsLookup: add support for setting the port number of the server
I couldn't make my Windows 10 or 11 query a non-standard port. It kept
complaining about "The parameter is incorrect.", so as a result the unit
test doesn't actually test the new feature there. I can't find a single
example of this on the Internet; my speculation is that the backend API
that DnsQueryEx uses does not support setting port numbers
(DnsQuery_{A,W} didn't offer that option).

[ChangeLog][QtNetwork][QDnsLookup] Added setNameserverPort().

Change-Id: I3e3bfef633af4130a03afffd175d60a581cc0a9c
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-23 21:23:42 -07:00
Volker Hilsheimer
9526e8dc33 macOS: Extend accessibility testing of treeview
Check that we can navigate to rows and columns, and that we get the
right text back for cells.

We see API failures in CI on some macOS nodes, accompanies by the debug
message:

AXUIElementCopyAttributeValue( "AXTitle" ) returned error =
  AXError(value=-25201, name=kAXErrorIllegalArgument,
  description="An illegal argument was passed to the function.")

On hosts where the test fails, we always see this warning, so extend the
test helper with an errorOccurred boolean that we can test and if set
skip the test.

Pick-to: 6.5
Change-Id: Iacad4c41f8597243abeff36ca91cf290446c13a1
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-05-23 19:42:16 +02:00
Giuseppe D'Angelo
313bb32364 QRegularExpression: match newlines when converting wildcards
A * or a ? in a wildcard pattern is allowed to match any character,
including newlines. When converting a wildcard pattern to a PCRE,
* and ? were converted to ., which by default does _not_ match over
newlines (/s is necessary).

There isn't a metacharacter that matches everything, so either we modify
the returned pattern to enable dot-matches-all (for instance, by
wrapping the returned expression in (?s:...)), or use a character class
that includes everything. Picking this last approach for simplicity.

Change-Id: I86703f654e3414783427c4c8e0bb018885b42e54
Fixes: QTBUG-113676
Pick-to: 6.5
Reviewed-by: Samuel Gaist <samuel.gaist@idiap.ch>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-23 00:03:37 +02:00
Thiago Macieira
c5221f6be0 QProcess/Linux: add a flag to re-enable the vfork()-like semantics
Commit 29b2fe40dc disabled it by reverting
commit d6bf71123d. We now add the promised
flag to opt-in. The flag is added to all Unix systems, but it really
only applies to Linux right now.

No ChangeLog because the whole UnixProcessParameters structure is new
and has its own changelog.

Task-number: QTBUG-104493
Task-number: QTBUG-111243
Task-number: QTBUG-111964
Change-Id: Icfe44ecf285a480fafe4fffd174d4effd3382495
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Paul Wicking <paul.wicking@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2023-05-22 10:43:53 -07:00
Thiago Macieira
f9c87cfd44 QProcess/Unix: add setUnixProcessParameters()
This commit adds those three flags that are either frequent enough or
difficult to do: close all file descriptors above stderr and reset the
signal handlers. Setting SIGPIPE to be ignored isn't critical, but is
required when the ResetSignalHandlers flag is used, as this is run
after the user child process modifier.

[ChangeLog][QtCore][QProcess] Added setUnixProcessParameters() function
that can be used to modify certain settings of the child process,
without the need to provide a callback using setChildProcessModifier().

Change-Id: Icfe44ecf285a480fafe4fffd174d0d1d63840403
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-22 10:43:50 -07:00
Volker Hilsheimer
6a4afebc5c macOS: Fix assertion in accessibility implementation for treeviews
In QAccessible's widget implementations, trees are treated as tables,
with a rowCount implementation that is based on the view's current
item content. That item content is the view's content, not the model's,
and it changes when tree branches are expanded.

The Cocoa bridge for accessibility allocates arrays of row data
structures based on the rowCount implementation. Those data structures
need to be invalidated and recreated when the view's content changes.
To do that, emit an accessibility event for a model reset when laying
out items changes the size of the view's item array. We don't know what
changed during that layout process to makes this any more granular.

Amends 11ae55e918, but the problem
with the data structure being stale and incorrect would have been there
before that chain of changes optimizing. It didn't trigger an assert,
but probably resulted in incorrect data being reported.

To make trees testable, we need to actually expose them as AXOutline
to the macOS accessibility framework. Until now, they have been treated
like plain QWidget, e.g. AXGroup. This made them in practice in-
accessible. With this change, VoiceOver works much better (although not
perfeclty yet).

Also remove an assert that could be triggered by an accessibility
client asking for a cell for an invalid index (which can be reproduced
by navigating around in a tree, following debug warnings from
QAccessibleTree::indexFromLogical: invalid index).

Pick-to: 6.5
Change-Id: I7650342aa0dcd7925a94ae6a36de5a0b344c467d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-05-22 16:45:28 +02:00
Volker Hilsheimer
b60c31de52 macOS: show the test function in the title of the test window
This makes it a bit easier to know what's going on when debugging.

Pick-to: 6.5
Change-Id: I5955b9b590c7aea584748f36e4fe15d41fd05ac1
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-05-22 16:45:27 +02:00
Axel Spoerl
980a499ad0 Implement color role AccentColor in QStyleSheetStyle and QCssParser
The color role AccentColor has been added to QPalette.

This patch implements the new color role in QCssParser and subsequently
in QStyleSheetStyle.
The QBrush variable names used to populate brushes, have been changed
into speaking names for better code readability.

tst_QCssParser has been adapted accordingly.
The test function accentColor() has been added in tst_QStyleSheetStyle.

Documentation has been updated.

Change-Id: Ib09ddc1b61868f2bb8f70f654e83ea1c35276d30
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-22 14:45:26 +00:00
Axel Spoerl
17c589df94 Shoehorn AccentColor into QPalette and keep existing 64bit resolve mask
It is necessary to add an AccentColor role to QPalette.
QPalette currently has 21 color roles and 3 color groups, which
require 63 bits to resolve. The resolve mask is implemented with a
qint64, which doesn't provide spare bits for another color role.

The color role NoRole is used as a default value, marking that a role
has not (yet) been defined. The enum value does not represent a valid
brush, even though it can theoretically be stored in QPalette's shared
data.

This patch adds the enum value AccentColor to QPalette::ColorRole,
increasing the available color roles to 22.
To keep the resolve mask at 63 bits, AccentColor is mapped to NoRole
in static constexpr bitPosition.

As the enum range would exceed 64 bits without this tweak, 3 additional
bits are substracted in the respective static assertion.

With NoRole having no bit in the resolve mask, the following adaptions
have been implemented:
- QPalette::resolve() is adapted to explicitly ignore NoRole.
- QPalette::isBrushSet() always returns false for NoRole.
- tst_QPalette::setAllPossibleBrushes() to verify the latter
- operator== ignores NoRole (documentation updated)

AccentColor is added in tst_QPalette::roleValues and enum documentation
is adapted.

In QPalette's default constructor, the AccentColor brush is defaulting
to the Highlight brush, it this is available. Otherwise it is made 30%
darker or lighter than the Base brush, depending on dark/light mode
heuristics.

QPalette's data stram functions have been extended from QDataStream
Version Qt_6_6. If earlier versions are de-serialised, the AccentColor
defaults to Highlight. An autotest function dataStream() has been added
to tst_QPalette.

The QDataStream Version Qt_6_6 has been bumped to 21.
tst_QDataStream has been adapted to the new version and the new
color Role.

Change-Id: I98bbf9de95fb83bda921e9614a0db3a3c0ebdf75
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-05-21 18:36:37 +02:00
Laszlo Agocs
1dd8b5ceec rhi: Make it a QPA-style private but semi-public API
qrhi.h, qshader.h, qshaderdescription.h (and qshaderbaker.h from
shadertools; done separately) become "RHI APIs", following the concept
of QPA APIs.

Mirror completely what is done for QPA headers, but using the "rhi"
prefix for the headers. This involves updating syncqt to handle the
new category of headers. (a note on the regex: matching everything
starting with "qrhi" is not acceptable due to incorrectly matching
existing and future headers, hence specifying the four header names
explicitly)

There is going to be one difference to QPA: the documentation for
everything RHI is going to be public and part of the regular docs, not
hidden with \internal.

In addition to the header renaming and adding the comments and
documentation notes and warnings, there is one significant change
here: there is no longer a need to do API-specific includes, such as
qrhid3d11[_p].h, qrhivulkan[_p].h, etc. These are simply merged into a
single header that is then included from qrhi.h. This means that users
within Qt, and any future applications can just do #include
<rhi/qrhi.h> (or rhi/qshader.h if the QRhi stuff is not relevant), no
other headers are needed.

There are no changes to functionality in this patch. Only the
documentation is expanded, quite a lot, to eliminate all qdoc warnings
and make the generated API docs complete. An example, with a quite
extensive doc page is added as well.

Task-number: QTBUG-113331
Change-Id: I91c749826348f14320cb335b1c83e9d1ea2b1d8b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-05-21 15:42:58 +02:00
Thiago Macieira
8566c2db85 QUuid: add support for 128-bit integers
[ChangeLog][QtCore][QUuid] Added support for converting between QUuid and
quint128, on platforms that offer 128-bit integer types (all 64-bit ones
supported by Qt, except MSVC).

Change-Id: Id8e48e8f498c4a029619fffd1728c9553e871df5
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-20 04:59:43 +00:00
Ahmad Samir
a2abca317a Moc: silence a GCC warning
It's already silenced for Clang, extend it to cover GCC too.

Change-Id: I212ca78d7a203d69d490c46e7ef4b78a60cabd80
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-18 22:39:16 +03:00
Marc Mutz
8712e35aec QVarLengthArray/QList: make assign() return a reference to *this
While std::vector::assign() returns void, std::basic_string::assign()
returns std::basic_string&. In Qt, we want to be consistent between
{QVLA,QList,QString,QByteArray}::assign(), and returning *this is the
more general solution, so do that.

Task-number: QTBUG-106196
Task-number: QTBUG-106200
Change-Id: I2689b4af032ab6fb3f8fbcb4d825d5201ea5abeb
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-05-17 06:44:45 +02:00
Marc Mutz
782ccc6de5 QList: re-use the prepend buffer, if any, on assign()
Task-number: QTBUG-106196
Change-Id: I62d8610529cab528ae1b114d29707133b4fc28dc
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-05-17 06:44:39 +02:00
Thiago Macieira
37f1fb78ee QSemaphore: add QDeadlineTimer API
This removes the last use of QtPrivate::convertToMilliseconds().

Change-Id: I6f518d59e63249ddbf43fffd1759fee2e00d36f4
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2023-05-16 19:13:03 -07:00
Dennis Oberst
bbbe5f45c4 QList: add STL-style assign()
Implemented assign() methods for QList to align with the criteria of
std::vector, addressing the previously missing functionality.

Reference:
https://en.cppreference.com/w/cpp/container/vector/assign

[ChangeLog][QtCore][QList] Added assign().

Fixes: QTBUG-106196
Change-Id: I5df8689c020dafde68d2cd7d09c769744fa8f137
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-16 20:09:39 +02:00
Marc Mutz
d8bdb66e82 tst_ContainerApiSymmetry: fix spacing of template <typename
This file, like the majority of qtbase, uses a space between template
and the opening of the template argument list. Add it.

Change-Id: I927cb2b1b9620ae108e913343d995373493e8981
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-16 20:09:39 +02:00
Volker Hilsheimer
c113a7a796 QTabBar: Add testcase for tabs not scrolling
Verify that changing a tab's text doesn't scroll.

Fixes: QTBUG-45381
Task-number: QTBUG-113140
Pick-to: 6.5
Change-Id: I02ace9d3fcaa20d8ff5d87ccca5d96a4114b0fb0
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
2023-05-15 21:03:00 +02:00
Thiago Macieira
48b6c8503a QProcess/Unix: enable setChildProcessModifier for startDetached
Do this by making the actual child-execution code common between
startProcess() and startDetached(). It does mean we've moved the chdir()
operation from the child to the grandchild process, though.

[ChangeLog][QtCore][QProcess] The modifier function set with
setChildProcessModifier() will now also be executed when the process is
started with startDetached().

Change-Id: Icfe44ecf285a480fafe4fffd174d9aa57dd7dfff
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-15 19:10:03 +02:00
Thiago Macieira
fb40737b0d QProcess/Unix: improve the error message if the child modifier throws
Functionality added for 6.5, but after translatable string freeze.

Change-Id: Icfe44ecf285a480fafe4fffd174d984c5349e0cb
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-15 19:10:03 +02:00
Thiago Macieira
ba05af82d3 QProcess/Unix: protect against stack unwinding in the child process stub
There are two types of stack unwinding that can happen on Unix systems:
C++ exceptions and PThread cancellations (on some systems, like Linux,
PThread cancellations can be caught in catch(...) statements). We call a
variety of PThread cancellation functions from inside the child stub,
like close(). To avoid problems, we disable PThread cancellations
completely before fork() or vfork().

The C++ exception case is simpler, because we can be sure of catching
them with the catch (...) statement and simply transform them into an
error message. This is also testable, which the PThread cancellation
isn't.

The error message isn't ideal because we're string-frozen. I'll improve
it for 6.6.

Pick-to: 6.5
Change-Id: Icfe44ecf285a480fafe4fffd174d97a475c93ff1
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-05-15 10:10:03 -07:00
Ahmad Samir
d2242c353f MOC: pass the erroneous Symbol as an arg to Parser::error() overload
We already know the Symbol while parsing, passing a reference to it to
error() makes it simpler to construct the error message.

This fixes an issue where reporting an error about "NONSENSE" in e.g.:
Q_PROPERTY(Foo* foo NONSENSE foo)

would be off-by-one and the error message would say:
path/to/file.h:11:1: error: Parse error at "foo"

instead of 'at "NONSENSE"', which is where the parser actually found an
unexpected attribute.

Fixes: QTBUG-36367
Pick-to: 6.5
Change-Id: Ief70e544af41f7575fbeea9b936fa8197c3ef43d
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-05-15 19:20:21 +03:00
Tor Arne Vestbø
e95f03f989 Darwin: Remove QMacAutoReleasePool heap allocation detection
This is handled by the Objective-C runtime nowadays, where it will
abort if the situation is detected, with the option to break on
objc_autoreleasePoolInvalid to debug the situation.

Pick-to: 6.5
Change-Id: Idf2c4aacc77e41a3deebf270303f4f13cfb0819b
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-05-15 13:51:00 +00:00
Edward Welbourne
4768fcf836 Fix case-sensitivity of exponent separator check in Cyrillic fall-back
When matching the locale's correct exponent separator, QLocale was
doing a case-insensitive match; but the Cyrillic fall-back was
matching case-sensitively, so failed to catch the case of lower-case e
and its Cyrillic equivalent, when used in a Cyrillic font in place of
the upper-case form of the other, where that's the locale's official
separator. So make this comparison case-insensitive.

Added some test-cases for the lower-case exponential separator.

Pick-to: 6.5
Fixes: QTBUG-113443
Change-Id: I18e22d7b3451fbb61e87d5b93661eadff3c7356e
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
2023-05-15 14:02:47 +02:00
Edward Welbourne
526ce669ed Clean up phrasing of --help-all and other help options
The options included by --help-all, although they are "specific to
Qt", are "specific" to all Qt applications, so - in the present
context, of QCommandLineParser - not specific at all. It's the options
described by -h that are specific, to the present command; the Qt
options are generic (in the present context).

So rework the help string for --help-all itself and the documentation
of the function. It had, in any case, an overly-complex first line,
that descended into too much detail. Updated test to match.

Pick-to: 6.5
Task-number: QTBUG-111228
Change-Id: I06da0af41be60e6e1b7616984001ddb9ca33aad6
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: David Faure <david.faure@kdab.com>
2023-05-15 14:02:43 +02:00
Edward Welbourne
06e2719f73 Add test-cases for QDate::{start,end}OfDay() at QDateTime's bounds
Task-number: QTBUG-68855
Change-Id: Ic91cb5f9947ce5ee533fc77ae24a50376e139ab3
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-15 14:02:41 +02:00
Edward Welbourne
eff0ffbd1b Sanitize the handling of limitations of the MS time-zone backend
tst_QDate::startOfDay_endOfDay() and its _data() were in danger of
growing a lot of ugly #if-ery to work round the known limitations of
MS's time-zone API and the backend built on them. Replace the #if-ery
with a flags enum indicating which parts we need to ignore on MS and
limit the #if-ery to how those flags get exercised.

Change-Id: I8657b4fba75f1aef1f3f9374e05f60354dc25e34
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-15 14:02:40 +02:00
Thiago Macieira
df2131426e tst_QProcess: move setChildProcessModifier test to a Q_OS_UNIX section
There's no need to say it's getting skipped on Windows. moc *can* parse
the #ifdefs these days.

Pick-to: 6.5
Change-Id: Icfe44ecf285a480fafe4fffd174d95c709ff6a74
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Oswald Buddenhagen <oswald.buddenhagen@gmx.de>
2023-05-15 00:12:43 +02:00
Marc Mutz
3b0536bbe8 tst_ContainerApiSymmetry: make assign_impl() robust w.r.t. overallocation
The parameter passed to reserve() is just a hint. The container
implementation is free to choose a larger capacity, and some do
(e.g. QList in prepend optimization mode).

Fix the test by querying the container for its post-make<>()
capacity() and taking a larger-than-expected initial capacity() into
account when later re-checking the capacity().

Change-Id: Id8f26f14e8df9d685ca2387ec4a52d74fea7cb9d
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-05-13 16:58:36 +02:00
Marc Mutz
fb58df3260 tst_ContainerApiSymmetry: make a comment more precise
It took me a sec to figure out the relation between the comment and
the code line following it. Make it easier for the next guy and add a
bit more infos.

Amends 7cbdc8abbd.

Change-Id: I4ff2d9a52aef643a92339df32cc86f686a689a9a
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-05-13 16:58:27 +02:00
Marc Mutz
4eea3f857c tst_ContainerApiSymmetry: follow file's style for assign() tests
We use a single line per test slot everywhere else, ignoring even
line-length limitations, to keep the function names aligned for easier
parsing.

Amends 7cbdc8abbd.

Change-Id: Iaf2941aae88392d407d688fc4a7537fcdc0a5851
Reviewed-by: Dennis Oberst <dennis.oberst@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-05-13 16:58:19 +02:00
Marc Mutz
edc953948c tst_ContainerApiSymmetry: fix mutable lambda anti-pattern
STL algorithms, in general, don't specify how often the function
objects passed to them are copied during the run of the
algorithm.

While generate_n is above any reasonable suspicion of copying the
function object after the first invocation, passing a mutable lambda
containing the counter is still an anti-pattern we don't want people
to copy.

Fix in the usual way, by keeping the counter external to the lambda.

As a drive-by, replace post- with pre-increment.

Amends dc091e7443.

Pick-to: 6.5 6.2
Change-Id: I9c44e769fd41e5f7157179a2be4c3534424cf913
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-05-13 16:58:10 +02:00
Thiago Macieira
3cc39197f8 tst_QAnyStringView: fix warning of unused variable by using it
Pick-to: 6.5 6.2
Change-Id: Ieab617d69f3b4b54ab30fffd175c78ddb5fb919d
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-05-12 20:54:13 +00:00
Thiago Macieira
cdd0e8fa67 QSlotObjectBase: move the which parameter to the 4th position
This places the first through third parameters on the exact positions
that they will be used to perform the operations in the switch, saving
the compiler from generating a few instructions to move data around. All
ABIs Qt supports that pass any function parameters in registers at all
pass at least 4.

We keep the return type as void (instead of returning bool, for the
Compare case) so the compiler can apply tail-call optimizations for
those two typical cases.

PMF case: https://gcc.godbolt.org/z/9oP5boKfj
Function case: https://gcc.godbolt.org/z/e9vEzd5dj
Functor case: https://gcc.godbolt.org/z/s8Ejjra7P

Change-Id: I3e3bfef633af4130a03afffd175d3e3009c56323
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-05-11 21:53:22 -07:00
Thiago Macieira
af9fa21a70 tst_QDnsLookup: don't fail if the server refused to answer
This happens often for me for ANY queries via Dnsmasq (home router) or
via whatever the corporate DNS servers are in the office.

Pick-to: 6.5
Change-Id: I3e3bfef633af4130a03afffd175e2656ae5e2c3e
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-11 17:05:26 -07:00
Thiago Macieira
9f7b341aae tst_QDnsLookup: create a dedicated test for IDN
Instead of using initTestCase and QFETCH_GLOBAL, which make the rest of
the tests repeat themselves with IDN data, which isn't necessary.

Pick-to: 6.5
Change-Id: I3e3bfef633af4130a03afffd175e2537ba89dc04
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-11 17:05:25 -07:00
Amir Masoud Abdol
68b625901f Network: link directly to libresolv instead of dlopen()ing it
There's little need for us to dynamically load it. The reasons why that
was necessary aren't in the public history (Qt 4.5 already had it[1]). I
remember writing the code in 2007-2008, I just don't remember why.

On modern Linux and FreeBSD, there's no libresolv.so any more and those
symbols have been rolled up into libc.so. It's still necessary on Darwin
systems, so this commit introduces WrapResolv.

It also resolves the unity build issues relating to libresolv symbols.

[1] https://code.qt.io/cgit/qt/qt.git/tree/src/network/kernel/qhostinfo_unix.cpp?h=v4.5.1

Task-number: QTBUG-109394
Change-Id: Ic5799e4d000b6c9395109e008780643bac52122b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-11 17:05:25 -07:00
Ievgenii Meshcheriakov
859ef05633 QDBusConnectionPrivate: Fix handling of queued messages
Handle any queued messages before attempting to dispatch
any newly received messages. This ensures that messages are
processed in the order they were sent.

Add a regression test for this bug using code adapted
from the bug report by Pascal Weisser. Because of the
nature of the bug, this new test does not always fail
even when compiled with affected versions of Qt though.

Fixes: QTBUG-105457
Pick-to: 6.2 6.5
Change-Id: I2725f3450ad537d63d6660e21645ac2c578e1768
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-05-11 19:58:12 +02:00
Volker Hilsheimer
9c9c5d9828 Fix QMetaObject::invokeMethod for free functions and std::bind
Amends 3bf5b5f894, after which free
functions and std::bind could no longer be used as callables in
QMetaMethod::invokeMethod.

For free functions to work we need to decay to function pointers when
choosing what type QtPrivate::Callable aliases.

And std::bind has operator() overloads and the return type cannot be
deduced. So simplify the definition of the ZeroArgFunctor - we know
the function prototype if we know the return type.

Add testcase for calling std::bind and free function, and remove the
now unneeded helpers for functor argument and return type deduction.

Change-Id: I54aac5cb6d660267e6b2f5ab05d583e8826cdf9a
Reviewed-by: Zoltan Gera <zoltan.gera@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-05-11 19:36:55 +02:00