Commit Graph

15702 Commits

Author SHA1 Message Date
Piotr Wierciński
9468ef2cfb CI: Enable some tests under corelib/thread for Wasm platform
This is part of our testing effort where we try enabling more tests for
Web Assembly platform on CI. Not all tests work out of box, so some of
them will require followup work.
This commmit also introduces a new mechanism of automatically renaming
files when they are added many times with the same filename to single
translation unit.

Change-Id: I620536494ea83aeb9b294c4a35ef72b51e85a38b
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2023-09-14 11:58:48 +02:00
David Faure
549ed4fb24 QMimeType: simplify implementation of filterString
As suggested by Ahmad Samir

Change-Id: I7f3ef29436a7725b6dceab72bd0f8b01756bf930
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-09-13 23:27:44 +02:00
David Faure
1f0bc1ade3 QMimeDatabase: fix glob-deleteall support for the binary providers
This fixes the recently added QEXPECT_FAIL about glob-deleteall
in a local directory (with a binary cache). Before adding a glob match
we ask the more-local (higher-precedence) directories if they have
a glob-deleteall for that mimetype, and skip it then. This "asking"
is a virtual method, implemented for both XML and binary providers.

Change-Id: I6e4baf0120749f3331fd2d9254bea750a322b72d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-09-13 23:27:44 +02:00
Edward Welbourne
c0cb616c1d Use the modern name for zone Asia/Kolkatta
The old name Asia/Calcutta is being phased out. We can't assign
QTzTZP, so select between new name and old using a reference variable.
In the process, fix a QCOMPARE() against bool to a QVERIFY().

Pick-to: 6.6 6.5
Change-Id: I7cd8a813f8a88c8ae4ba07213f04f4ad0860cec0
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-09-13 19:51:47 +02:00
David Faure
4e9944e6c8 QMimeDatabase: collect glob patterns from all locations
A QMimeTypePrivate used to belong to a single provider, which would
provide the complete data for it.
But since the redesign in commit 7a5644d648, each provider
represents is a single mime directory, and the merging happens at the
QMimeDatabase level. So we need a QMimeType[Private] to be just a name
(a "request" for information about this mimetype) and the information
for that mimetype is retrieved on demand by querying the providers
and either stopping at the first one (e.g. for icons) or merging
the data from all of them (e.g. for glob patterns).

The XML provider was using QMimeTypePrivate as data storage,
give it its own struct QMimeTypeXMLData for that purpose instead.

Task-number: QTBUG-116905
Change-Id: Ia0e0d94aa899720dc0b908f40c25317473005af4
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-09-13 13:45:04 +02:00
David Faure
994311a66b tst_qmimedatabase: move local override to the specific test method
When running tst_qmimedatabase with the full shared-mime-info test suite
(which unfortunately requires local setup so this is easy to overlook),
we need *.webm to still be associated with video/webm.

So to test glob-deleteall, do that in installNewLocalMimeType(), with
other similar tests.

This however unearthed the following bug: the handling of glob-deleteall
is only correct when the local dir has no binary cache. It's broken
when using a binary cache. Added a QEXPECT_FAIL for now because this is
going to be fixed as part of a major redesign, coming up.
I also found out that neither xdgmime nor gio do this correctly...

Change-Id: Ib075fcdb792f60a859f23db8c2d7e1c6524f9050
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-09-13 13:45:04 +02:00
David Faure
251ab925fe tst_qmimedatabase: separate xml files for Global and Local tests
For historic reasons, the test had a single list of override xml files
to copy first into the global dir, and then into the local dir.
But glob-deleteall only makes sense in the local dir (as per the MIME
spec). Having two definitions for the same mimetype in the same dir
is undefined behavior, so the test was working by chance only, and
my upcoming refactoring/fixes caught that.

Change-Id: I4717683b4b3f9ba69f1fd815669460789700e877
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-09-13 13:45:04 +02:00
Marc Mutz
104a0a9ecd Long live Q_(U)INT128_MIN/MAX!
Since compilers don't provide such macros, do it ourselves.

In order to test these macros, add ad-hoc specializations of
QTest::toString() for qint128 and quint128 locally to the test. Turns
out it's not too hard to write them, so we might move them to a public
header, yet.

Pick-to: 6.6
Change-Id: I1483f3af2ccec6038e1c780649f9ffe413bb59ef
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-09-13 09:18:40 +02:00
Marc Mutz
32f66f7008 Add some tests for q(u)int128
Check that QIntegerForSize<16> and std::numeric_limits<quint128> work
and that q(u)int128 are available in C mode, too.

Pick-to: 6.6
Change-Id: I44af8282399c78f6e74a8268af53bad64407ca34
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-09-13 09:18:40 +02:00
Marc Mutz
6da6a17de9 Fix qHash(qfloat16) to match Qt 6.4 behavior
There were two problems:

- On platforms where QFLOAT16_IS_NATIVE == true, a qHash(qfloat16{})
  call has become ambiguous between the three FP qHash() overloads
  (float, double, long double), where it was unambiguously calling the
  float one in Qt 6.4. This SiC was caused by the replacement of
  operator float() by operator __fp16() in
  99c7f0419e, which is in Qt 6.5.

- On platforms where QFLOAT16_IS_NATIVE == false, qHash(qfloat16{})
  would produce a different value from qHash(float{}), and therefore
  Qt 6.4, when the seed was != 0, because the former would go via the
  one-arg-to-two-arg qHash adapter while the latter one would
  not. Since participating functions are inline, this causes old and
  new code to produce different hash values for the same qfloat16,
  leading to a BiC possibly corrupting QHash etc.

Fix both by adding an explicit qHash(qfloat16). This function is
inline, so it doesn't add a new symbol to 6.5.x.

[ChangeLog][QtCore] Fixed qHash(qfloat16) which was broken from 6.5.0
to 6.5.3, inclusive. If you compiled against one of the affected Qt
versions, you need to recompile against either Qt 6.4 or earlier or
6.5.4 or later, because the problematic code is inline.

Pick-to: 6.6 6.5
Fixes: QTBUG-116064
Fixes: QTBUG-116076
Change-Id: Id02bc29a6c3ec463352f4bef314c040369081e9b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-09-12 21:12:50 +00:00
Tor Arne Vestbø
5ce4aecd49 embeddedwindows: Mask the painting manually by applying a clip
QWindow::setMask() is not guaranteed to turn the masked out areas
transparent, and it's up to the client to ensure this during
painting.

Pick-to: 6.6
Change-Id: I1155b3ad095152a993532f2290cacb670e20daa7
Reviewed-by: Liang Qi <liang.qi@qt.io>
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-09-12 16:30:02 +02:00
Tor Arne Vestbø
61c043333b embeddedwindows: Fill bounds, instead of event rect
The event might come from a partial expose, but we want to
fill the entire bounds of the window, as we're filling with
a gradient.

Pick-to: 6.6
Change-Id: I66cedb160fb0ed06935c06ba2fe5dec9ed468833
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
Reviewed-by: Liang Qi <liang.qi@qt.io>
2023-09-12 16:30:00 +02:00
Tor Arne Vestbø
4e2e3a6b4f xcb: Reflect geometry of foreign window on creation
Pick-to: 6.6
Change-Id: I305b256696a32454f64c12c5a8901b65506fc520
Reviewed-by: Liang Qi <liang.qi@qt.io>
2023-09-12 16:29:58 +02:00
Mikolaj Boc
647aca1e7c Enable qsettings tests on WASM
Task-number: QTBUG-115509
Change-Id: Ib33cfdf09c821e99f229ecfd0e7761b17fb4b672
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
2023-09-12 16:13:59 +02:00
Shawn Rutledge
63eaa3a989 Add manual test for QTextCursor::insert*
Visualize what's going on with tst_QTextCursor::insertMarkdown() at least.
But this could be expanded for other purposes.

It's also interesting to test drag-and-drop with this. And you can save
the result to any supported text format.

Change-Id: I363c32ff9b1bd7c53c562b08c58de95a69be0aa9
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2023-09-12 06:20:23 +01:00
Marcin Zdunek
185627557e Fix undeclared identifier 'geteuid' for VxWorks
Task-number: QTBUG-115777
Change-Id: Ic95d5f92af185ac64b14ae6fafd4ffe507911f5b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-09-12 02:07:04 +00:00
Tor Arne Vestbø
3cb3c1d9a8 xcb: Implement native window helper for embeddedwindows/foreign window test
Pick-to: 6.6
Change-Id: I73720f8f49a5d7e5df7c95bf4b17ef910180e01c
Reviewed-by: Liang Qi <liang.qi@qt.io>
2023-09-12 02:47:24 +02:00
Axel Spoerl
edc984db38 QDialogButtonBox: Manage hide and show of standard buttons
0b421fa58b9a73d657bf17834788fd1175c4767e ensured a correct focus chain,
when buttons in a QDialogButtonBox were hidden.

The implementation did not check, if a hidden button was added via
setStandardButtons(). In consequence, it was removed from the
standardButtonHash and never added again.
QDialogButtonBox::button() returned nullptr for a standard button,
once it had been hidden. That introduced a regression.

This follow-up patch makes sure, a standard button is not removed
from standardButtonHash, when hidden. By no longer removing it from
standardButtonHash, it makes showQDialogButtonBox::button() always
return the pointer to the standard button, even if it is hidden.

The function handleButtonDestroyed() used the argument
QDialogButtonBoxPrivate::RemoveRule::KeepConnections, in order to leave
signal/slot connections untouched. It expected the the destroyed button
to be removed from standardButtonHash. In order to retain that
functionality, the enum class RemoveRule is renamed to RemoveReason,
and one value was added. QDialogButtonBoxPrivate now handles all
necessary cases of removing a button:

ManualRemove (previously Disconnect):
- remove button from roles
- remove button from standardButtonHash
- disconnect all signals

LeaveEvent (previously KeepConnections):
- remove button from roles
- do not remove button form standardButtonHash
- do not disconnect signals

Destroyed (new):
- remove button from roles
- remove button from standardButtonHash
- do not disconnect signals (QObject will do that)

An autotest is added to tst_QDialogButtonBox.

Task-number: QTBUG-114377
Pick-to: 6.6 6.5
Change-Id: Ib28625d44fa89c3d06f181f64875c2e456cebbfa
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-09-11 13:26:56 +00:00
Ahmad Samir
b0a3cfaf53 QStringList: optimize replaceInStrings
By first checking if the list has any matches before potentially making
it detach.

Change-Id: I7a42c2910ef6efc45033e562573414a3a9ef972e
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-09-10 15:14:50 +03:00
Ahmad Samir
ada0e8be5d QStringList: test indexOf/lastIndexOf(QRegularExpression) overloads
Change-Id: I8c62b0d36628c2a1519667cc553f3ec33b964dfc
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-09-10 15:13:05 +03:00
Giuseppe D'Angelo
2f945aaa26 QProcess: remove a XFAIL for QNX
91dcc76fc1 might have fixed the underlying issue, so we no longer
need the XFAIL codepath at all.

Fixes: QTBUG-114720
Change-Id: I67ccbed67a0536b679c50c26eb0b3e51c93dceeb
Pick-to: 6.6
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-09-08 19:00:49 +02:00
Christian Ehrlicher
9016def4dc tst_QAbstractItemModelTester: fix unittest
rowsAboutToBeMoved() and rowsMoved() signals aren't emitted for
QSortFilterProxyModel, which meant the two connections in the
ObservingObject's constructor didn't trigger the slots, which let the
test pass (the store/checkPersistentFailureCount stayed at 0).

- Instead connect to layoutAboutToBeChanged() and layoutChanged()
  respectively, these two are emitted for QSFPM
- Use PMF syntax
- Verify m_persistent{Proxy,Source}Indexes aren't empty

Change-Id: I8b83989de02c2bfb22bde9b230cb5b68814f74b6
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-09-08 19:17:36 +03:00
Marc Mutz
defabd265e tst_QFont: fix -Wsign-compare
Amends 17f8e2c441.

Pick-to: 6.6
Change-Id: I896027866c11b5e135c39848cefcf45942f1cf99
Reviewed-by: Eskil Abrahamsen Blomfeldt <eskil.abrahamsen-blomfeldt@qt.io>
2023-09-08 11:32:44 +02:00
Marc Mutz
9c63667d01 tst_QHashFunctions: fix std::pair test to use QFETCH_GLOBAL seeds
Because the local `seed` variable shadowed the member one, this test
was run for each QFETCH_GLOBAL with the same data and seed. That
doesn't make sense, so make the test use the member variable `seed`,
as all other tests already do.

Since zero is one of the seeds coming from QFETCH_GLOBAL, drop the
seedless calls to qHash(), too.

Amends 64bfc927b0.

Pick-to: 6.6 6.5 6.2
Change-Id: I1e22ec0b38341264bcf2d5c26146cbbcab6e0749
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-09-08 11:32:44 +02:00
Marc Mutz
8ca319a172 tst_QHashFunctions: test with actual 64-bit seeds
The old code only tested with seed = 0 and seed = 1045982819, the
latter being a "random number", which, however, fits into
32-bits. Since Qt 6.0 increased the seed from uint to size_t, amend
the test to actually test a seed value with some of the upper half of
bits set, too, also in 64-bit mode.

While we're at it, also test with each seed's bits flipped for extra
coverage.

Remove a static assertion that prevented testing seeds with the MSB
set.

Pick-to: 6.6 6.5 6.2
Change-Id: I5ed6ffb5cabaaead0eb9c01f994d15dcbc622509
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-09-08 09:32:44 +00:00
Dennis Oberst
3db9ef358d QArrayDataPointer: remove Q_CHECK_PTR in assign(it, it) again
This commit reverts 2d77051f9d.

When requesting an allocation of size 0, we will actually get
a nullptr.

 qarraydata.cpp:
    ~~~
    if (capacity == 0) {
        *dptr = nullptr;
        return nullptr;
    }

This will let the Q_CHECK_PTR trigger falsely. Such an occurrence was
initially detected during the cmake_automoc_parser build-step.

Found-by: Marc Mutz <marc.mutz@qt.io>
Task-number: QTBUG-106196
Pick-to: 6.6
Change-Id: Icb68c5dd518c9623119a61d5c4fdcff43dc4ac5d
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-09-07 15:05:05 +02:00
Øystein Heskestad
d83aabad0f Add static constexpr Boyer-Moore Latin-1 string matcher
QStaticLatin1StringMatcher is a static templated Latin-1 Boyer-Moore
string matcher which can be case sensitive or not. It should be used
when the needle is known at compile time so there is no run-time
overhead when generating the skip table.
The convenience functions qMakeStaticCaseSensitiveLatin1StringMatcher
and qMakeStaticCaseInsensitiveLatin1StringMatcher should be used to
construct the matcher objects.

Green Hills Optimizing Compilers are currently not supported.

[ChangeLog][QtCore] Added QStaticLatin1StringMatcher, which can be used
to create a static constexpr string matcher for Latin-1 content.

Task-number: QTBUG-100236
Change-Id: I8b8eed1e88e152f29cbf8d36d83e410fafc5ca2c
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-09-07 09:38:36 +02:00
Jonathan Ketchker
55f0738f16 Add StateLocation & GenericStateLocation to StandardLocation
The latest XDG spec (0.8) defines XDG_STATE_HOME that does not exist
in QStandardPaths::StandardLocation.

Some Linux distributions clean XDG_CACHE_HOME on restart which makes
XDG_STATE_HOME useful as a path for saving application state.

This commit adds StateLocation and GenericStateLocation to serve as a
StandardLocation for XDG_STATE_HOME for all platforms.

This commit also updates docs and tests to fit the new changes.

[ChangeLog][QStandardPaths] Added StateLocation &
GenericStateLocation to StandardLocation

Change-Id: I470602466c37f085062cc64d15ea243711728fa5
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-09-07 01:17:13 +03:00
Volker Hilsheimer
505ed52cd4 Dialogs: clean up native dialogs when object gets destroyed
QWidget::setVisible is virtual, and called via hide() by both the
QDialog and the QWidget destructor. A dialog that becomes invisible
when getting destroyed will at most execute the QDialog override.
Subclassing QDialog and overriding setVisible() to update the state
of the native platform dialog will not work, unless we explicitly
call hide() in the respective subclass's destructor.

Since e0bb9e81ab, QDialogPrivate::setVisible is
also virtual, and gets called by QDialog::setVisible. So the clean
solution is to move the implementation of the native dialog status
update into an override of QDialogPrivate::setVisible.

Add test that verifies that the transient parent of the dialog
becomes inactive when the (native) dialog shows (and skip if that
fails), and then becomes active again when the (native) dialog is
closed through the destructor of the Q*Dialog class. The test of
QFileDialog has to be skipped on Android for the same reason as the
widgetlessNativeDialog.

Fixes: QTBUG-116277
Pick-to: 6.6 6.5
Change-Id: Ie3f93980d8653b8d933bf70aac3ef90de606f0ef
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-09-06 23:12:33 +02:00
Thiago Macieira
b6462bbd5c tst_selftests: split the qFatal() test away from tst_Silent
This allows us to control whether to run this particular test in ASan
mode or with specific loggers or not. Adding the expected log output for
tst_silent for other loggers is left as an exercise to the reader.

Change-Id: Ifa1111900d6945ea8e05fffd177f1548c8c8e714
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-09-06 12:36:06 -07:00
Thiago Macieira
1c8402dd41 Revert "Dodge qFatal() so as to get coverage results despite it"
This reverts commit f20adcde30. The
implementation had the right idea, but this is not expected to work
reliably in C++. It's jumping out of several frames without cleaning
them out properly and our ASan-based memory leak-checker has started
complaining (the next commit will move this test elsewhere).

   ==19313==ERROR: LeakSanitizer: detected memory leaks

 Direct leak of 258 byte(s) in 1 object(s) allocated from:
       #0 0x7ffa505c8e48 in __interceptor_malloc (/usr/lib64/libasan.so.5+0x109e48)
       #1 0x7ffa4f2d7ff9  (/home/qt/work/install/lib/libQt6Core.so.6+0x896ff9)
       #2 0x7ffa4f2d834d in QArrayData::allocate(QArrayData**, long long, long long, long long, QArrayData::AllocationOption) (/home/qt/work/install/lib/libQt6Core.so.6+0x89734d)
       #3 0x7ffa4f23b700  (/home/qt/work/install/lib/libQt6Core.so.6+0x7fa700)
       #4 0x7ffa4f1f6cc8 in QString::reallocData(long long, QArrayData::AllocationOption) (/home/qt/work/install/lib/libQt6Core.so.6+0x7b5cc8)
       #5 0x7ffa4f1f68a7 in QString::resize(long long) (/home/qt/work/install/lib/libQt6Core.so.6+0x7b58a7)
       #6 0x7ffa4f2092ff  (/home/qt/work/install/lib/libQt6Core.so.6+0x7c82ff)
       #7 0x7ffa4f209e09 in QString::vasprintf(char const*, __va_list_tag*) (/home/qt/work/install/lib/libQt6Core.so.6+0x7c8e09)
       #8 0x7ffa4ed0d83d  (/home/qt/work/install/lib/libQt6Core.so.6+0x2cc83d)
       #9 0x7ffa4ed114a9 in QMessageLogger::fatal(char const*, ...) const (/home/qt/work/install/lib/libQt6Core.so.6+0x2d04a9)
       #10 0x5641d2604c40 in tst_Silent::messages() /home/qt/work/qt/qtbase/tests/auto/testlib/selftests/silent/tst_silent.cpp:77
       #11 0x5641d26050fb in tst_Silent::qt_static_metacall(QObject*, QMetaObject::Call, int, void**) tests/auto/testlib/selftests/silent/silent_autogen/include/tst_silent.moc:118

The restoration of the signal handler (which QtTest now has) is also
wrong: this needed to use sigaction() instead.

Change-Id: Ifa1111900d6945ea8e05fffd177f14fbc09a1d7d
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-09-06 12:36:06 -07:00
Ahmad Samir
ac9e968755 Remove redundant QPair includes
Nothing in those files uses QPair; and a local build finished fine without them.

Task-number: QTBUG-115841
Change-Id: I669cfecaa9129bce6b31e464826287f138b159db
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-09-06 17:24:40 +00:00
Ivan Solovev
516d828f24 QCborValue: add benchmark for operator[]
In order to test the impact of migration to QASV.

Task-number: QTBUG-101707
Pick-to: 6.6 6.5 6.2
Change-Id: I17f84ca98fc87d89bb4cd6ad98c8a12aecd315ee
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-09-06 16:17:52 +02:00
Edward Welbourne
54c2383e81 Add _tzset() call before mktime() on MS
Add a change-of-zone manual test, based on a bug-report by Felix
Kälberer. This failed: debugging revealed that MS's mktime() doesn't
pick up a change to system zone.

Fixes: QTBUG-83881
Change-Id: I9b86398ef870627a059e269f85a0f5d9d9de284b
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-09-05 22:41:35 +02:00
Volker Hilsheimer
e73f35d9c6 QPrintDialog on macOS: Don't crash when parent is not a window
The test case is an incomplete version of the test that will be added to
verify the fix for the referenced bug report. The test crashes already
when showing the dialog without this fix.

Task-number: QTBUG-116277
Pick-to: 6.6 6.5 6.2
Change-Id: I969a723157f6453b78bafae5cb24a6b37b1eea50
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-09-05 22:41:35 +02:00
Dennis Oberst
b134718c11 QString: use new assign() in operator=({QByteArray, QChar, char *})
operator=(~) and assign() share similar names but, until now, have not
shared the same functionality. This patch introduces the usage of
QString::assign() within the non-sharing assignment operators to
effectively boost efficiency by reusing the available capacity.

Since we're re-using the capacity we update the test case in places
where they don't hold true anymore.

Since these assignment operators are frequently used in many places,
both within Qt and non-Qt code, this patch comes with benchmarks.

The preview of the benchmark results are compared with this patch and
before this patch. The results show a boost in performance for the
QByteArray and 'const char*' overload. The QLatin1StringView overload
already preserved the capacity and has a better performance than the
assign() alternative, so don't us it there.

(x86_64-little_endian-lp64 shared (dynamic) release build (O3); by
gcc 13.2.1, endeavouros ; 13th Gen Intel(R) Core(TM) i9-13900K

benchmarks executed with -perf -iterations 1000000

  * The last value at the EOL represent the string size.

QString &operator=(const QByteArray &a) (current)
  64.3  cycles/iter; 300  instructions/iter; 17   nsec/iter (5)
  65.8  cycles/iter; 366  instructions/iter; 12   nsec/iter (10)
  62.9  cycles/iter; 301  instructions/iter; 11.5 nsec/iter (20)
  61.3  cycles/iter; 315  instructions/iter; 11.1 nsec/iter (50)
  71.4  cycles/iter; 386  instructions/iter; 13   nsec/iter (100)
  136.9 cycles/iter; 811  instructions/iter; 24.5 nsec/iter (500)
  245.8 cycles/iter; 1394 instructions/iter; 42.5 nsec/iter (1'000)

QString &operator=(const QByteArray &a) (before)
  78   cycles/iter; 399  instructions/iter; 15.3 nsec/iter (5)
  82.3 cycles/iter; 465  instructions/iter; 15   nsec/iter (10)
  76.7 cycles/iter; 400  instructions/iter; 14   nsec/iter (20)
  79.5 cycles/iter; 414  instructions/iter; 14.5 nsec/iter (50)
  91.4 cycles/iter; 485  instructions/iter; 16.7 nsec/iter (100)
  189  cycles/iter; 910  instructions/iter; 34.4 nsec/iter (500)
  320  cycles/iter; 1666 instructions/iter; 56   nsec/iter (1'000)

QString &operator=(const char *ch) (current)
  70  cycles/iter; 317  instructions/iter; 12   nsec/iter (5)
  71  cycles/iter; 383  instructions/iter; 12.3 nsec/iter (10)
  64  cycles/iter; 318  instructions/iter; 11.1 nsec/iter (20)
  69  cycles/iter; 340  instructions/iter; 12   nsec/iter (50)
  77  cycles/iter; 419  instructions/iter; 13.5 nsec/iter (100)
  141 cycles/iter; 899  instructions/iter; 24.4 nsec/iter (500)
  280 cycles/iter; 1518 instructions/iter; 48.4 nsec/iter (1'000)

QString &operator=(const char *ch) (before)
  86.7  cycles/iter; 416  instructions/iter; 15   nsec/iter (5)
  87.8  cycles/iter; 482  instructions/iter; 15.7 nsec/iter (10)
  82.4  cycles/iter; 417  instructions/iter; 14.3 nsec/iter (20)
  90.2  cycles/iter; 443  instructions/iter; 15.6 nsec/iter (50)
  101.4 cycles/iter; 518  instructions/iter; 17.7 nsec/iter (100)
  204.4 cycles/iter; 994  instructions/iter; 36.5 nsec/iter (500)
  337.9 cycles/iter; 1789 instructions/iter; 58.9 nsec/iter (1'000)

 * current implemented as: assign(other)
QString &operator=(QLatin1StringView other) (current)
  47.4 cycles/iter; 237 instructions/iter; 8.2  nsec/iter (5)
  46.2 cycles/iter; 237 instructions/iter; 7.9  nsec/iter (10)
  46.8 cycles/iter; 255 instructions/iter; 8    nsec/iter (20)
  59   cycles/iter; 273 instructions/iter; 10.2 nsec/iter (50)
  55   cycles/iter; 300 instructions/iter; 9.5  nsec/iter (100)
  94.3 cycles/iter; 525 instructions/iter; 16.3 nsec/iter (500)
  166  cycles/iter; 804 instructions/iter; 28.7 nsec/iter (1'000)

QString &operator=(QLatin1StringView other) (before)
  14  cycles/iter; 79  instructions/iter; 2.5  nsec/iter (5)
  14  cycles/iter; 79  instructions/iter; 2.6  nsec/iter (10)
  16  cycles/iter; 97  instructions/iter; 3    nsec/iter (20)
  19  cycles/iter; 115 instructions/iter; 3.5  nsec/iter (50)
  23  cycles/iter; 142 instructions/iter; 4.2  nsec/iter (100)
  91  cycles/iter; 367 instructions/iter; 16.6 nsec/iter (500)
  131 cycles/iter; 646 instructions/iter; 23.4 nsec/iter (1'000)

Task-number: QTBUG-106201
Change-Id: Ie852f6abd1cf16164802acddb048eae5df59758f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-09-05 20:58:47 +02:00
Marc Mutz
5a96d13bb5 QCheckBox: add new checkStateChanged(Qt::CheckState) signal
... to replace the old stateChanged(int) one, which a) had the wrong
name and b) the wrong argument type.

Mark the old one as \obsolete, so new users don't see it
anymore. Prepare for deprecation in the test, but don't actually
deprecate, yet (this author does not know how to deprecate signals).

Found in API-review.

Amends 37b47ebf94.

As a drive-by, replace explicit qWait() calls with QTRY_COMPARE().

[ChangeLog][QtWidgets][QCheckBox] Added new
checkStateChanged(Qt::CheckState) signal, obsoleting
stateChanged(int).

Fixes: QTBUG-104688
Change-Id: I01791fd003b752c47d99bea65151202be9175c21
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-09-05 13:43:44 +00:00
Dennis Oberst
c8be7c6a6c tst_QString: assign(it,it) add test-cases for empty range
Pick-to: 6.6
Change-Id: Iaf2ddb247aa279166110ad8793b1e37e66e8b11b
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-09-05 15:00:38 +02:00
Ilya Doroshenko
1eb15adee3 Add stereo support for DirectX12 and Vulkan backends
Change-Id: Id12723d6c392e25935ccb265c58af91aff968984
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2023-09-05 10:28:42 +00:00
Santhosh Kumar
4cf92d83c3 Reset palette resolve mask in windows vista style
The palette set by windows vista style during polish doesn't allow style-
sheet style to override it.

This patch reset resolve mask for the palette set by windows vista style
and thus it can be overridden.

Fixes: QTBUG-115511
Pick-to: 6.6 6.5
Change-Id: Ifcaf441f806cfa0273599b3dce83fdfaec3f5a66
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-09-05 10:59:00 +02:00
Ahmad Samir
0ce51dee0e tst_QDnsLookup: fix typo in CMakeListst.txt
There was an extra `q` before dnslookup.

Found while trying to build tst_qdnslookup, the target wasn't seen by
CMake/Ninja.

Pick-to: 6.6
Change-Id: Id594aab30dc9081fc269541561e0f2db5e615657
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-09-04 14:17:12 -07:00
Ahmad Samir
9b40272562 tst_QDnsLookup: skip a unittest on Windows
See code review 496440 on Gerrit for the details.

Change-Id: Ibd32a44cf7e2e07f36687cc2f0eeaf3008f64e73
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-09-04 22:40:35 +03:00
Ahmad Samir
909893344c tst_qeventdispatcher: port to QDeadlineTimer
Easier logic for these use-cases.

Change-Id: I97a18c45d9bd8cfcfee5d379d271366276d5a435
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-09-04 22:40:35 +03:00
Mårten Nordheim
6577242adf tst_QString: deduplicate datatags
By saying what's special about some of them

Pick-to: 6.6 6.5
Change-Id: I17bf2e12a27bf55f621020ddf3819ee9e606847d
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-09-04 12:00:48 +02:00
Thiago Macieira
961620824c QArrayData: make calculateBlockSize() account for the extra null element
Instead of adding it after the block size was calculated. This makes no
difference for non-growing (exact) blocks. For growing blocks, this
means we take that extra element into account before rounding to the
next power of two, instead of after. That results in a change of the
thresholds of when a block grows and also what capacity it will
contain.

For example, for a QString growing to 22-25 elements:

      Request     |       Previously        |           Now           |
elements |  bytes | malloc()ed | capacity() | malloc()ed | capacity() |
    22   |    44  |        66  |        24  |        64  |        23  |
    23   |    46  |        66  |        24  |        64  |        23  |
    24   |    48  |        66  |        24  |       128  |        55  |
    25   |    50  |       130  |        56  |       128  |        55  |

To avoid wasting elementSize - 2 bytes in this footer, we only include
this footer if elementSize <= 2. Thus, for a QList<int> growing to 11-13
elements:

      Request     |       Previously        |           Now           |
elements |  bytes | malloc()ed | capacity() | malloc()ed | capacity() |
    11   |    44  |        66  |        12  |        64  |        12  |
    12   |    48  |        66  |        12  |       128  |        28  |
    13   |    52  |       130  |        28  |       128  |        28  |

In both cases, we now only allocate powers of two while growing, which
may be beneficial to some allocators.

Pick-to: 6.6
Change-Id: Ifa1111900d6945ea8e05fffd177dcb96e251d0a1
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-09-03 17:43:24 -07:00
Ivan Solovev
d752da1857 QAnyStringView: fix construction from QL1SV for bootstrapped builds
The SizeShift was not taken into account when constructing QASV from
QL1SV. This is not an issue in normal Qt builds, because SizeShift == 0
there.
But in bootstrapped case (and in future Qt 7) SizeShift changes to 2,
and the bug becomes visible.

The added test-cases do not really reveal the issue, because we do
not run tests in bootstrapped builds, but at least they will help
to prevent the issues in Qt 7.

Pick-to: 6.6 6.5 6.2
Change-Id: I337b37b5230323a5357f48fd1c9bf799ca507d52
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-09-03 18:22:06 +02:00
Ivan Solovev
1ad424aed5 QLocal{Socket,Server}: extend the test coverage for property bindings
The pre-existing test for QLocalServer was testing only a minor subset
of cases, so replace it with the call to
QTestPrivate::testReadWritePropertyBasics.

The test for QLocalSocket's bindable properties was missing, so add
it.

The new tests didn't reveal any problems.

Task-number: QTBUG-116346
Pick-to: 6.6 6.5
Change-Id: I695bb050d39eeae9ffb84c097c36601a4ca89af6
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-09-03 18:20:59 +02:00
Ivan Solovev
96a62cd1f5 tst_QDnsLookup: extend test coverage for property bindings
The pre-existing tests were not using the QTestPrivate helpers, so
extend them with the call to QTestPrivate::testReadWritePropertyBasics.

The updated test didn't reveal any problems with binding loops, so no
other action is required for now.

Task-number: QTBUG-116346
Pick-to: 6.6 6.5
Change-Id: I51a17974a7f5bec3c969fcb55b6f28e3e9218eb5
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-09-03 18:20:56 +02:00
Ivan Solovev
ac59fcdab8 QStandardItemModel: extend the test coverage for property bindings
The pre-existing tests were not using the QTestPrivate helpers, so
extend them with the call to QTestPrivate::testReadWritePropertyBasics.

The updated test didn't reveal any problems with binding loops, so no
other action is required for now.

Task-number: QTBUG-116346
Pick-to: 6.6 6.5
Change-Id: I360614a40fe2bacb796051607ed67e7e666b4f22
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-09-03 18:20:54 +02:00
Ivan Solovev
7d70edd31c QTimer: extend property tests and fix binding loop
The bindable property tests were not using the QTestPrivate helpers, so
add a new test which uses them.

The new tests revealed a binding loop for the interval property.
Fix it in a usual way by explicitly removing the binding and using
{set}ValueBypassingBindings() in the setter.

Task-number: QTBUG-116346
Pick-to: 6.6 6.5
Change-Id: If94f57938da449a68e3527aead5ebd55ba410adb
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-09-03 18:20:51 +02:00
Ivan Solovev
cdb50edc98 tst_QMovie: extend the test coverage for property bindings
The old tests were not using the test methods from QTestPrivate, so
add another test case.

Task-number: QTBUG-116346
Pick-to: 6.6 6.5
Change-Id: I291ede26461e79a615630f1decad2ad7549b4dd8
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-09-03 18:20:48 +02:00
Ivan Solovev
6a873778b9 QAbstractProxyModel: fix binding loops
... by using valueBypassingBindings() when accessing the properties
from the setters.

This commit is mostly trivial.
Had to change the template parameters in the unit-test, because the
updated QTestPrivate::testReadWritePropertyBasics() creates an instance
of the TestedClass, and QAbstractProxyModel cannot be instantiated,
since it has pure virtual methods.

Task-number: QTBUG-116346
Pick-to: 6.6 6.5
Change-Id: I0cae29263ea9bb92c9de06891b0ba8633fb9fd72
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-09-03 18:20:33 +02:00
Ivan Solovev
22c2c15b27 QSequentialAnimationGroup: extend bindable property unit tests
The bindable property tests should use the helper functions from
QTestPrivate.

Task-number: QTBUG-116346
Pick-to: 6.6 6.5
Change-Id: Ie1a61ab80e6f737eac02246214c2c93129a1cf94
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-09-03 18:20:21 +02:00
Ivan Solovev
b64e36240b QPauseAnimation: extend tests and fix binding loop
Extend the unit-tests for bindable properties and fix the discovered
binding loop by using {set}ValueBypassingBindings() in the setter of
the duration property.

The code refactoring does not modify the setter logic, because
previously the binding was anyway implicitly removed when calling the
assignment operator. The updated code just does it explicitly.

Task-number: QTBUG-116346
Pick-to: 6.6 6.5
Change-Id: I0f339d182efb60500ee7f12e407f200d739da312
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
2023-09-03 18:20:18 +02:00
Thiago Macieira
2b06d41b46 tst_QFileInfo: don't trigger libstdc++ std::filesystem bug
libstdc++'s std::filesystem::path implementation incorrectly assumes
that any 8-bit char input is UTF-8, when it patently isn't on Windows.

Reported at https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111244

Pick-to: 6.5 6.6
Fixes: QTBUG-116609
Change-Id: I2b24e1d3cad44897906efffd17803f2862935c9b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-09-01 13:05:45 -07:00
Thiago Macieira
9e8c93fac1 tst_QFileInfo: replace a portion of a macro with a lambda
It's very hard to debug a macro.

Pick-to: 6.5 6.6
Change-Id: I2b24e1d3cad44897906efffd17803b8eac9bd844
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-09-01 13:05:40 -07:00
Thiago Macieira
5b9e2f31bd tst_QFileInfo::stdfilesystem: add extra Unicode string tests
Pick-to: 6.6
Change-Id: I2b24e1d3cad44897906efffd17803f70bd4d60f6
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-09-01 13:05:34 -07:00
Volker Hilsheimer
c59b34b8cf QAccessible: consistently respect rootIndex of item views
Accessibility implementations rely on correct information about the
model dimensions when operating on item views. An item view that has a
root index set needs to report it's size based on the root index, rather
than for the view's model directly.

Pass the rootIndex to all calls to QAbstractItemModel::column/rowCount.
Refactor the code to avoid excessive dereferencing of a QPointer, apply
const and fix/improve coding style in touched lines.

Emit a ModelReset notification when the root index changes, or (in the
case of QListView) when the model column changes.

Split long Q_ASSERTs into multiple lines to be able to better trace the
exact reason for an assertion, and replace the assert with an early
return of nil when it's plausible that a cached cell is no longer part
of the view (i.e. because the root index changed).

Add a test case that verifies that changing the root index changes the
dimension of the view as reported through the accessibility interface.

Pick-to: 6.6 6.5
Fixes: QTBUG-114423
Change-Id: I7897b79b2e1d10c789cc866b7f5c5dabdabe6770
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2023-09-01 18:03:29 +02:00
David Faure
1b39e61a77 QMimeDatabase: fix detection of pattern conflict in different prefixes
Installing a second mimetype with *.txt as glob had a different
effect depending on whether it was installed into the same prefix
or a different prefix as the one where text/plain is installed.

Pick-to: 6.6
Change-Id: I7f54b8efe22f620eb57257745c48fe5402c87626
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-09-01 15:04:33 +02:00
Shawn Rutledge
801b8304fb Add QTextDocument* constructor argument to QTextMarkdownImporter
QTextMarkdownImporter::import() took a QTD* as if it would be ok to
reuse one instance of QTextMarkdownImporter for repeated importing into
different documents; but in practice, we never do that: in fact it's
usually a short-lived, stack-allocated object, as in
 QTextMarkdownImporter(&doc, QTMI::DialectGitHub).import(input);
So it's less clumsy internally to require the document be provided to
the constructor: that way a QTextCursor can be constructed immediately
too, as part of the importer object rather than separately on the heap.

This is private API, unused outside qtbase.

Change-Id: I8041ceb33cb7e7608df55dc5a963292c585afb90
Reviewed-by: Oliver Eftevaag <oliver.eftevaag@qt.io>
Reviewed-by: Giuseppe D'Angelo <giuseppe.dangelo@kdab.com>
2023-09-01 08:17:29 +02:00
Volker Hilsheimer
d027b0c816 Constrain QCoreApplication::requestPermission to compatible functors
The 6.5 versions of the overload not taking a context/receiver object
were constrained by requiring a functor to be free function or lambda.
207aae5560 removed that constraint, which
might be source incomaptible if wrapper functions in user code forward
the constraint using Expression SFINAE. Those wrappers would no longer
be removed from the overload set based on the same criteria as the
function they wrap.

We can't constrain the new functions based on the same predicate as
before, as after the simplification we have only one overload with, and
one without context object. But we can still remove overloads for
incompatible functors.

Add the respective scenario to the QPermission test as a compile-time
test.

Found during 6.6 header review.

Pick-to: 6.6
Change-Id: Id21391b4a6b78a29de2f8fa04374f4262e5fafa7
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-09-01 03:30:50 +02:00
Axel Spoerl
a7d7634f1b Implement QSignalBlocker::dismiss()
...to set m_o to nullptr and prevent an existing QSignalBlocker from
touching the QObject, which it was created for.
Add documentation and implement an autotest.

Change-Id: Ic18e80af5a57df1928f9d36aa0ab7ad79b6525fd
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-08-31 22:11:51 +00:00
Axel Spoerl
38380de63c tst_qstatictext: Fix CMake condition
Private libraries were linked conditional to QT_FEATURE_private_tests in
the CMake file. qstatictext_p.h was included conditional to developer
build. A developer build fails, with test enabled and private tests
disabled.

=> Change the CMake condition to QT_FEATURE_developer_build, to resolve
mismatch between CMake and cpp file.

Pick-to: 6.6 6.5 6.2
Change-Id: I79213e7d3c38851b8b80cb8ab248d7bff750c227
Reviewed-by: Alexey Edelev <alexey.edelev@qt.io>
2023-08-31 22:11:51 +00:00
Axel Spoerl
41c8d215f2 tst_QSplitter: fix compiler warning
QLabel *l is declared uninitialized, assigned in a for loop. The last
object is deleted for testing purposes.
This leads to a false compiler warning about deleting a potentially
unintialized pointer.

=> initialize with nullptr to silence the warning.

Pick-to: 6.5 6.6
Change-Id: I1422b04fc1fdbfc7248de577884aabfb539f3f4b
Reviewed-by: Doris Verria <doris.verria@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-09-01 00:11:51 +02:00
Axel Spoerl
70b57c943a tst_qsslkey: Fix CMake condition
Private libraries and WrapOpenSSL were linked conditional to
QT_FEATURE_private_tests in the CMake file.
qsslkey_p.h and open ssl symbols were included conditional to developer
build. A developer build fails, with test enabled and private tests
disabled.

=> Change the CMake condition to QT_FEATURE_developer_build, to resolve
mismatch between CMake and cpp file.

Pick-to: 6.6 6.5
Change-Id: I3ac93b02701e467a0b548c35d441d35a45c4568b
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-09-01 00:11:51 +02:00
Axel Spoerl
4f4a8e75ab QItemSelectionModelPrivate: use QObjectPrivate::connect
QItemSelectionModelPrivate::initModel() uses string based connections,
to connect/disconnet its QAbstractItemModel.
The QObject::destroyed signal is connected to modelDestroyed(), which
does not disconnect other signals.

QQuickTableView's selection model binds to its QAbstractItemModel.
The binding also reacts to QObject::destroyed
Eventually, QItemSelectionModel::setModel(nullptr) is called.
At this point, only a QOBject is left from the QAbstractItemModel.
That leads to warnings about disconnecting string based signals, which
belong to QAbstractItemModel.

This patch changes the connect syntax to the QObjectPrivate::connect
API. Instead of keeping a list of string based connections around, the
connections themselves are kept in a list member. Disconnecting happens
based on that list.
Connections are also disconnected in
QAbstractItemModelPrivate::modelDestroyed.

An auto test is added in tst_QItemSelectionModel.

Fixes: QTBUG-116056
Pick-to: 6.6 6.5 6.2
Change-Id: I57e5c0f0a574f154eb312a282003774dd0613dd6
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2023-09-01 00:11:51 +02:00
Thiago Macieira
763592b238 tst_selftests: add a way to run a subset of all subprograms
This functionality was lost when we switched to Catch2.

Change-Id: I2b24e1d3cad44897906efffd177fb4cff641546f
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-08-31 06:26:25 +00:00
Thiago Macieira
f1ba2b9f44 tst_selftests: deduplicate the Unix/Linux conditions
Amends 118f2210c6. That commit added

 #ifdef Q_OS_UNIX
     if (test == "assert"
         || test == "crashes"
         || test == "failfetchtype"
         || test == "faildatatype")
     return; // Outputs "Received signal 6 (SIGABRT)"
 #endif

Which duplicated 4 out of the 5 tests in the block:

 #ifdef Q_OS_LINUX
    // QEMU outputs to stderr about uncaught signals
    if (QTestPrivate::isRunningArmOnX86() &&
        (test == "assert"
         || test == "crashes"
         || test == "faildatatype"
         || test == "failfetchtype"
         || test == "silent"
        ))
        return;
 #endif

But as Linux is Unix, we never got to that second block for those 4
tests.

Pick-to: 6.6
Change-Id: I2b24e1d3cad44897906efffd177fb4b5507d190a
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-08-30 23:26:25 -07:00
Morten Sørvig
c802a9e987 wasm: rename JsString -> EcmaString
QString::fromJsString -> QString::fromEcmaString()
QString::toJsString() -> QString::toEcmaString()

For API naming compatibility with QByteArray::fromEcmaUin8Array()

Pick-to: 6.6
Change-Id: If6e2121e31e630d6728ed24e41d14b763f395aaa
Reviewed-by: Piotr Wierciński <piotr.wiercinski@qt.io>
Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
Reviewed-by: Lorn Potter <lorn.potter@gmail.com>
2023-08-30 23:02:03 +02:00
Tor Arne Vestbø
4ba7a76985 Allow QObjects to opt in to receiving ParentAboutToChange/ParentChange
QWidget already handles this, but it might be useful for non-Widget
object hierarchies as well, such as in Qt Quick.

The flag is opt in, and as QWidget already handles these events by
itself (without checking any flags), we assert that we don't end up
in this code path, instead of enabling it for QWidget. The latter
would mean refactoring the QWidget code, with possible regressions.

Docs and header comments have been updated to reflect that this
event is not widget specific. (This is an issue with other events
as well, that are documented to say "widget", since they came
from a time when there was only QWidget, but nowadays apply to
e.g. QWindow as well. That's something for another fix though).

Change-Id: Ib71962131d6011c17dcce8c01bd8adcdaa58d798
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-08-30 15:45:41 +02:00
Timur Pocheptsov
a323f05c5e tst_QSslSocket: don't use deprecated RSA api
OpenSSL 3.1.2 can be configured with no-deprecated option, in this
case test fails to build.

Pick-to: 6.6 6.5 6.2
Change-Id: Icaf457f55fb001b632922856dbe4bbb5bdba220e
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-08-29 20:15:05 +02:00
Thiago Macieira
ac8fe3e645 QtNetworkSettings: narrow down hasIPv6 to specific OSes
It's currently conditional on two features used in QNetworkInterface.
The fact that QNetworkInterface misses those two features is probably
correlated to the failures observed on QNX, but is not the cause, so
this code was actually wrong and was possibly disabling the execution of
similar content on other OSes.

Therefore, this commit removes them and changes the conditional to
exclude the OS that is failing (QNX).

I find this situation unacceptable.  IPv6 support is mandatory for any
application after 2011-01-31, the date when IANA delegated its last IP
block, and definitely after 2019-11-25, when RIPE NCC ran completely
out. But since there's no SDK available for it, I'll grudgingly accept a
grandfathered exception because there's nothing I can do about it (I
tried to fix it; look at the change history of this patch set). I will
block any new OSes in that situation, though.

Task-number: QTBUG-116503
Change-Id: Ifa1111900d6945ea8e05fffd177ed6979c3e5916
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-08-29 07:20:51 -07:00
Thiago Macieira
fd924ab0b6 tst_QUdpSocket: move up the search for IPv6-capable interfaces
Let's do it in initTestCase(), where we're already searching for IPv6
addresses, instead of storing the information in a local static.

Pick-to: 6.6
Change-Id: Ifa1111900d6945ea8e05fffd177efb6a055aaa58
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-08-29 07:20:50 -07:00
Thiago Macieira
2e51fbf89a tst_QNetworkInterface: enable IPv6 detection for Windows
This was disabled in d0d1d74033, I guess
accidentally, by a too-wide conditional. The change the same commit
applied to QtNetworkSettings didn't make the same mistake.

I am also opportunistically updating the conditional to QT_CONFIG (I
missed this in 9d4579c1cd) and adding the
Linux-specific check, as the AF_NETLINK implementation does not rely on
getifaddrs() or if_nametoindex().

Drive-by fix indentation.

Pick-to: 6.6
Change-Id: Ifa1111900d6945ea8e05fffd177ef8fcb11b4e1e
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-08-29 07:20:49 -07:00
Krzysztof Sommerfeld
44d274a29f Add 'thread_local' definition as it is not available in C mode for VxWorks
Task-number: QTBUG-115777
Change-Id: I42c54ac2a34817f3b0a9b687ee282b97123b78c9
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-08-29 13:27:06 +00:00
Thiago Macieira
19673b6cf9 tst_qdnslookup: fix the location of the opcode in the header
We were reading the wrong byte with the wrong shift count.

 4.1.1. Header section format

 The header contains the following fields:

                                    1  1  1  1  1  1
      0  1  2  3  4  5  6  7  8  9  0  1  2  3  4  5
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |                      ID                       |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |QR|   Opcode  |AA|TC|RD|RA|   Z    |   RCODE   |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |                    QDCOUNT                    |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |                    ANCOUNT                    |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |                    NSCOUNT                    |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+
    |                    ARCOUNT                    |
    +--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+--+

This diagram is big-endian, so bit 0 is the MSB.

Change-Id: I964c2b1e6b834feb9710fffd177bb72110bb77e7
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-28 20:09:41 -07:00
Laszlo Agocs
80520c2f52 Enable QWidget::grab() with QRhiWidget in the widget tree
This involves reimplementing QWidgetPrivate::grabFramebuffer().
Widgets call this function whenever a texture-based widget is
encountered.

This implies however that we rename QRhiWidget's own, lightweight
grab function, grab(), because it kind of shadows QWidget's grab().
Switch back to grabFramebuffer() which is what QQuickWidget and
QOpenGLWidget both use.

Supporting QWidget::grab() is particularly important when grabbing
an ancestor of the QRhiWidget, because that has no alternative.
Right now, due to not reimplementing the QWidgetPrivate function,
the place of the QRhiWidget is left empty.

In addition, grabFramebuffer() is now const. This is consistent
with QQuickWidget, but not with QOpenGLWidget and QOpenGLWindow.

Change-Id: I646bd920dab7ba50415dd7ee6b63a209f5673e8f
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2023-08-28 21:14:28 +02:00
Mikolaj Boc
5c5c9dd830 Main thread-proxy localStorage oprations in native WASM QSettings
localStorage is unavailable on workers. Operations will now get proxied
to the main thread instead.
This - among other benefits - makes tst_QSettings::testThreadSafety
pass.

Task-number: QTBUG-115509
Change-Id: Iebbe5e9f9069948f8728e0a82628cc082b30de12
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2023-08-28 17:53:29 +02:00
Piotr Wierciński
c95555e9f7 CI: Enable tests under auto/wasm on Wasm platform
Change-Id: Ib017f59b06cc5a7df73ad9f9a0c036670d6458b0
Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-08-28 14:10:02 +02:00
Thiago Macieira
a0550df6d9 tst_QFile: extend virtualFile() to test in unbuffered mode too
Change-Id: Ifbf974a4d10745b099b1fffd1777acb752350375
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-25 15:54:15 -07:00
Thiago Macieira
7ca82250e0 tst_QFile: update virtualFile() to check if readLine() reads all
We know that all lines from /proc/<PID>/maps end in a newline, so we
trim exactly that one byte, then we put it all back together with
.join('\n') to check if we've read the entire file.

Linux virtual files are usually served in 4 kB increments; tst_qfile's
maps file is about 16000 bytes for me, just short of the QIODevice buffer:

[pid 414315] read(5, "55c6afe04000-55c6afe11000 r--p 0"..., 16384) = 4049
[pid 414315] read(5, "7f215fd25000-7f215fd26000 r--p 0"..., 12335) = 4038
[pid 414315] read(5, "7f2160800000-7f21608c7000 r--p 0"..., 8297) = 4072
[pid 414315] read(5, "7f216119f000-7f21611a0000 rw-p 0"..., 4225) = 3994

It is not a coincidence that the reads are at line boundaries, though
it's not a guarantee from the kernel.

We appear to have accidentally fixed the QEMU emulation bug by reading
another process' /proc/<PID>/maps (hypothesis: QMU emulates the target
system in /proc/self, hiding itself in maps, but makes no translation
for other process map files.

Change-Id: Ifbf974a4d10745b099b1fffd1777ac919b12dc90
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-25 22:54:08 +00:00
Alexey Edelev
d02c3151b2 Disable android_deployment_settings test for non-standalone scenario
The test changes couple variables to emulate the user project
environment. These variables also affect the policy handling.
The test will build and work properly only if tests are built
standalone. So add this limitation.

Amends 2e340cea88

Pick-to: 6.6
Change-Id: I0cc49bf55bf7763e4c3ecdfa5333fb0453f06794
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-08-25 18:37:23 +02:00
Timur Pocheptsov
a3cbbe449a Blacklist tst_QMainWindow::QTBUG52175_tabifiedDockWidgetActivated
We are BLACKLISTing on macos/arm - the test is flaky.

Pick-to: 6.6 6.5
Task-number: QTBUG-115945
Change-Id: I3be28c895d46ce5ba86e00d597016334bdb16021
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-08-25 18:37:23 +02:00
Ahmad Samir
788d19439b tst_QAccessibility: compile with QT_NO_FOREACH
QObject::children() returns a const QList&, and nothing in the loop body
changes the objects children, so straightforward port to ranged-for.

Task-number: QTBUG-115839
Change-Id: I78827fd986d6ff2607cc2616ff23580c9d830f1b
Reviewed-by: Jan Arve Sæther <jan-arve.saether@qt.io>
2023-08-25 18:56:28 +03:00
Tor Arne Vestbø
ea25b3962b Stabilize tst_QGraphicsEffect::draw()
It's very flakey in CI: http://testresults.qt.io/grafana/goto/XZQAAPRSg

What we want to test is whether Qt issues paint events in response
to enabling an already enabled effect. Doing so via qWait will process
both window system events and posted Qt events, and the former might
include spontaneous paint events from the system that we can't control.

Task-number: QTBUG-115945
Pick-to: 6.5 6.6
Change-Id: I65e5c6a4458e77b3bd2ad700c5caf6d441f4ca53
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-08-25 09:04:37 +02:00
Ahmad Samir
2e37cff19e tst_QSpinBox: handle an old TODO
QTBUG-69492 has been fixed since Qt 5.12.

Pick-to: 6.6 6.5
Change-Id: I8bc59bd37a9ee2f47f13fa8ff54aa91e2c9148fa
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-08-24 23:35:01 +03:00
Ievgenii Meshcheriakov
43a2f19a07 Update public suffix list
Task-number: QTBUG-116236
Pick-to: 6.6 6.5
Change-Id: I91d4619b69a16ef1ac2f954b738f181b1dd9d9a1
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-08-24 13:39:45 +02:00
Marcin Zdunek
c00951c6c2 Fix tst_qprinterinfo.cpp not compiling on Vxworks
Neither fork() nor execvp exist on Vxworks so they should not be used

Task-number: QTBUG-115777
Change-Id: I6de4e9ec67741466de1b1f4bd89d9c962e539bb8
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-08-24 08:04:01 +00:00
Mårten Nordheim
4ffb227c78 invokeMethod: Try invoking functor and member function accepting pointer, returning void
Due to the pre-existing overload of invokeMethod that accepts a void-pointer there is
concern that the new overloads would not be preferred.
Here we add a test for this to verify all supported platforms work.

Change-Id: Ie5ac7bf16643599006ac57e0145feb6aace3fa87
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-08-24 07:45:04 +02:00
Mårten Nordheim
a7d2855b3c invokeMethod: enable passing parameters to overload taking functors
This was missing for a while, and there is nothing fundamentally
missing for it to work.

With the more recent work around slot objects and invokeMethod in
general, it is a good time to add support for this.

In this patch, when connecting to a functor, it automatically deduces
the overload to call based on the arguments passed to invokeMethod.

Sharing code with QObject::connect could be done, but they have a
key difference that makes it harder:
With signal emissions we throw away trailing arguments that are not
used: i.e. `signal(int, int)` can be connected to `slot(int)` or
`slot()`. With invokeMethod that's not a thing. So we will need a way
to toggle that behavior during resolution.

[ChangeLog][QtCore][QMetaObject] Added support for passing parameters
to the overload of QMetaObject::invokeMethod that takes a functor. These
new overloads must have the return-value passed through qReturnArg().

Change-Id: If4fcbb75515b19e72fab80115c109efa37e6626e
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-08-24 07:45:04 +02:00
Joerg Bornemann
b684984939 CMake: Fix find_package(Qt6*Tools) in non-qtbase tests
Tests in non-qtbase modules could not find_package their own Qt6*Tools
packages, because add_subdirectory(tests) was called before the config
files for Qt6*Tools were created.

The creation of tools config files is done in QtPostProcess.cmake, which
was included in qt_build_repo_end(). Move that include into its own
macro, qt_build_repo_post_process() and remove it from
qt_build_repo_end(). Call qt_build_repo_post_process() before the
'tests' directory is added in qt_build_repo().

Every call site of qt_build_repo_end() must now be adjusted and call
qt_build_repo_post_process().

Task-number: QTBUG-88264
Change-Id: I80d60a1b5c0e9b715c298ef4934b562f815432d1
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-08-23 16:21:58 +02:00
Alexey Edelev
2e340cea88 Add test for the qt6_android_generate_deployment_settings CMake command
qt6_android_generate_deployment_settings is implicitly used by
qt6_add_executable in user projects. This test makes sure that the
function behaves as expected for user projects specificly, since in Qt
tests it behaves differently because of Qt-specific conditions inside.

Task-number: QTBUG-116037
Pick-to: 6.6
Change-Id: Iea10eca7a780ebaff0c05b91ebe47b821b9ec956
Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
2023-08-23 16:21:57 +02:00
Ahmad Samir
40f863738b QtNetwork auto tests: compile with QT_NO_FOREACH
Remove all "#undef QT_NO_FOREACH" white-listing from source files.
Previous commits have removed all remaining Q_FOREACH/foreach uses in
this sub-tree.

Also remove one source file from NO_PCH_SOURCES in CMakeLists.txt.

Task-number: QTBUG-115839
Change-Id: I02cf994eda720c028e613407342fbd6658fa62b1
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-08-22 21:50:38 +03:00
Ahmad Samir
d489d207c4 tst_QNetworkReply: port Q_FOREACH to ranged-for
The QHash "cache" isn't modified in the loop body (method is const), in
general cacheSize() shouldn't be susceptible to data races.

Task-number: QTBUG-115839
Change-Id: I122a03ddd5e648d16736c16fa9289eafc886979d
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-08-22 21:50:28 +03:00
Ahmad Samir
659b6d5595 tst_QSslCertificate: port Q_FOREACH to ranged-for [5]
The toString() method's parameter is a const&, the loop body doesn't
change the container; and the container the parameter refers to isn't
changed during iteration.

Drive-by, remove braces from single-line if blocks.

Task-number: QTBUG-115839
Change-Id: I363e1ed37c0f75fa6a9f8eac3393a6c10d756c1b
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-08-22 21:49:01 +03:00
Ahmad Samir
dccaedc626 QtNetwork auto tests: port Q_FOREACH to ranged-for [4]
Straightforward ports where the container could be made const.

Use C arrays instead of QList if the data is known at compile time.

Drive-by, where appropriate make the for-loop variable a const& (e.g.
QString) instead of copying it for no reason.

Task-number: QTBUG-115839
Change-Id: I273a386e414e5923e750072f0407226efcd4531e
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-08-22 21:48:20 +03:00
Ahmad Samir
36f925aac1 QtNetwork auto tests: port Q_FOREACH to ranged-for [3]
In both cases, the container is a member of the unittest, initialized in
initTestCase(), then not changed after that. So use std::as_const.

Task-number: QTBUG-115839
Change-Id: I3b66127e10ac94137260d99f354de9f66a74bec7
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-08-22 21:47:45 +03:00
Ahmad Samir
bca2805b34 QtNetwork auto tests: port Q_FOREACH to ranged-for [2]
The containers are created locally in the top level test functions, they
can't be made const due to the way they are filled, however the loop
body don't change them; even if the code in a loop would cause
re-entrance du due to signal emittance or events processing, those
containers aren't affected and aren't changed during iteration because
the top-level test functions themselves aren't re-entered, hence
use std::as_const.

Drive-by change: take QHostAddress by const& when it's used as a
for-loop variable (it has a QExplicitlySharedDataPointer d-pointer).

Task-number: QTBUG-115839
Change-Id: I443169e10d973aba2f62854aba200fc2dc2c80aa
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-08-22 21:47:34 +03:00
Ahmad Samir
1a98293200 QtNetwork auto tests: port Q_FOREACH to ranged-for [1]
The loops were iterating over a temporary, so use a local const auto
variable to hold it, and use ranged-for.

Drive-by, make the for-loop variable const& instead of copying it,
for any object that has a d-pointer (QNetworkAddressEntry, QHostAddress,
QNetworkInterface).

Task-number: QTBUG-115839
Change-Id: If96c0b2a6142fe2fa2ed45ed7e2435cc1f80e005
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-08-22 21:47:16 +03:00
Ahmad Samir
87aac3caca QFile: add decodeName() unittests
And extend the encodeName() unittest.

Change-Id: Id5cd8a1f7ffbdb0d810bdc80b28aab9eb5cfbcdb
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-08-22 21:45:12 +03:00
Thiago Macieira
4368179c37 QTimer: fix regression on singleShot-invoking non-mormalized SLOT()s
The was introduced with the rewrite of QMetaObject::invokeMethod() in
commit 0f76e55bc4, because we have an
optimization for zero timers to avoid creating a temporary
QSingleShotTimer object. The old implementation did attempt to normalize
the target slot name, but did so because it looked metamethods up using
QMetaObject::indexOfMethod:

    int idx = meta->indexOfMethod(sig.constData());
    if (idx < 0) {
        QByteArray norm =
QMetaObject::normalizedSignature(sig.constData());
        idx = meta->indexOfMethod(norm.constData());
    }

The new implementation does not use this method so it didn't need to
attempt to normalize.

I am fixing this only in QTimer and not in QMetaObject::invokeMethodImpl
(even though it is trivial to do so) because I don't believe spaces in a
pure string to invokeMethod were ever expected to work:

    QMetaObject::invokeMethod(obj, "slotName ", Qt::QueuedConnection);

The Q_ARG and Q_RETURN_ARG (for code not recompiled) still does
normalization inside QMetaType::fromName().

Fixes: QTBUG-116060
Pick-to: 6.5 6.6
Change-Id: I964c2b1e6b834feb9710fffd177cac60c83ef413
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-08-22 10:17:33 -07:00
Timur Pocheptsov
708b3285f3 tst_gestures: clean-up the BLACKLIST
The recent change in QCocoaScreen (108d2e4486)
fixed the problem with no widget found at 'hot spot' (while we know
it's there, since we create it and wait for it to get expose event).

Pick-to: 6.6 6.5
Fixes: QTBUG-108402
Task-number: QTBUG-115945
Change-Id: Ibbf6867bb3381b8137d64cdbd15cc467d8fcf348
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-08-22 15:19:50 +00:00
Mikolaj Boc
234f03a0b3 Remove the unix dispatcher from WASM builds
Unix dispatcher is not used and - as such - redundant on WASM.

Change-Id: Ia8789ef783b06ce9cfba2ce9d67159db2355b594
Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
2023-08-22 17:19:50 +02:00
Timur Pocheptsov
6d6d22b65d tst_QSslSocket: skip tests requiring TLS v 1.0 downgrade
If OpenSSL version is 3.1.1 or above - this version moved the protocol
under security level 0, but the default one is 1.

Pick-to: 6.6 6.5 6.2 5.15
Fixes: QTBUG-116166
Change-Id: Iaabb2cf33e2a9f280d6167233ee16080dee808b0
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-08-22 16:26:02 +02:00
Axel Spoerl
366b4d3ae7 tst_QDockWidget: Fix compiler warning in non-development build
Static variables for a message handler were used only in developer
build, while they were declared unconditionally.
That has lead to compiler warnings about unused variables in a
non developer build.

=> declare them only in developer build
=> move assignment and static method in front of the method,
that uses them.

Pick-to: 6.6 6.5
Change-Id: Ie06f91f7857130f08fd484a6e7319ddfd16c546b
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-08-22 15:37:46 +02:00
Mårten Nordheim
4660a230d5 QString/QByteArray: fix append() wrt. raw data
When appending to an empty string or byte array, we optimize and
copy the internal pointer. But if the other string/byte array was
created with fromRawData this might be temporary data on the stack/heap
and might be de-allocated or overwritten before the string/byte array
is used or is forced to make a deep-copy. This would lead to incorrect
data being used.

This is easy to overlook if you plan to append multiple strings
together, potentially supplied through an argument. Upon appending a
second string it would make a full copy, but there might not be a
guarantee for that. So, it's hard for users to avoid this pitfall!

Fixes: QTBUG-115752
Pick-to: 6.6 6.5 6.2
Change-Id: Ia9aa5f463121c2ce2e0e8eee8a6c8612b7297f2b
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-08-21 23:27:56 +02:00
Mikolaj Boc
a6d40467de Make IDB settings work sync with JSPI
IndexedDB version of QSettings will now use solely the sync versions
of data access functions. Those will suspend with JSPI.
This makes IDB settings conform to the QSettings contract - and also
allows us to enable tests in tst_qsettings for the IDB version of
QSettings.
Also, do not treat the IndexedDB format as one defining read/write
functions in QSettings - those are the same as for ini format, as
IndexedDB settings backend uses a backing ini file.

Change-Id: Iee3471cc79c0cea87378923cf9baac58e56d1272
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2023-08-21 19:39:21 +02:00
Timur Pocheptsov
c1b287c531 tst_QDtls: use DTLS v 1.0 test data conditionally
Starting from OpenSSL v 3.1.1 DTLS 1.0 is only available, if the
security level is 0, which is not the case most of the time. So
we consider this version number to be a 'threshold' after which
we don't test v 1.0 anymore.

Pick-to: 6.5 6.6 6.2 5.15
Task-number: QTBUG-116166
Change-Id: I9763703f36ae742e1d3c7cb17872cf8d0d82ab85
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
2023-08-21 16:13:48 +02:00
Ulf Hermann
9306db6d46 QObject: Do not register an observer when writing objectName property
Observers should only be registered when _reading_ the property.
Otherwise we get binding loops.

Pick-to: 6.6 6.5
Change-Id: I974f6ea444fa7a5d333ed79eea6f34e3d757d169
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-08-21 14:15:51 +02:00
Ahmad Samir
ea24142ab5 tst_QPrintDevice: compile with QT_NO_FOREACH
The loop was iterating over a temporary, so it couldn't have changed it.
Store the container in a local const variable and port to ranged-for.

Drive-by change: don't call ps->availablePrintDeviceIds() multiple
times.

Task-number: QTBUG-115839
Change-Id: If2cabec68040dc7096acf0b7ddeff72d7c8c7750
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-08-19 19:17:18 +03:00
Ahmad Samir
78f0250053 tst_QPrinter: compile with QT_NO_FOREACH
resolution(): a local const container, Q_FOREACH wasn't needed here to
begin with, port to ranged-for

The rest, the loops were iterating over temporaries, so just put them in
local const auto variables and use ranged-for.

Task-number: QTBUG-115839
Change-Id: Iebe6d164661d74df9fefb764c370cdc9a8e817ff
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-08-19 19:17:17 +03:00
Ahmad Samir
7889dcda95 tst_qmimedatabase: compile with QT_NO_FOREACH; port to ranged-for
msgMimeTypeForFileNameFailed(): the method takes the container by const&
and I've made the container const at the call site, so now it's
iterating over a const container.

allMimeTypes(): iterating over a const container.

checkHasMimeType(): was iterating over a temporary, store it in a const
auto variable.

Task-number: QTBUG-115839
Change-Id: If10eb425d55484bc1857dfdeafa9d65b2beb765f
Reviewed-by: David Faure <david.faure@kdab.com>
2023-08-19 19:17:17 +03:00
Ahmad Samir
6864576577 tst_qmakelib: compile with QT_NO_FOREACH
proEval(), proParser(): the loop was iterating over a temporary so it
couldn't have changed it. Hold the container in a const auto variable
and use ranged-for.

formatValue(): iterating over a const QList& parameter, and the container
isn't changed at the call sites during iterating, so Q_FOREACH wasn't
needed to beging with. Use ranged-for instead.

Task-number: QTBUG-115839
Change-Id: Idabe0bbd84b5bcc86cef275f80497651353a4d9e
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-08-19 19:17:17 +03:00
Ahmad Samir
7101dcab7a tst_qmake: compile with QT_NO_FOREACH
systemEnvironment(): the loop was iterating over a temporary; hold the
temporary in a local const auto variable and use ranged-for.

runCommand(): the container is a const&, the loop doesn't change the
container and the containers the method is called on aren't changed
during iteration.

Task-number: QTBUG-115839
Change-Id: I6687e5ff64ff8c2fa26e34abf4044b98718e65d4
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-08-19 19:17:17 +03:00
Ahmad Samir
192e1ed649 tst_moc: compile with QT_NO_FOREACH
specifyMetaTagsFromCmdline(): the loop was iterating over a temporary so
it couldn't have modified it; hold it with a const auto variable and use
ranged-for.

relatedMetaObjectsNameConflict_data(): make the container const and port
to ranged-for.

Task-number: QTBUG-115839
Change-Id: I6a5afdf0e5a3dd47818da0025fbbeacd05335b39
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-19 19:17:17 +03:00
Ahmad Samir
890a61fba0 tst_selftests: compile with QT_NO_FOREACH
The loop was iterating over a temporary container, so it couldn't have
changed it. Use a const auto variable to hold the container and port to
ranged-for

Task-number: QTBUG-115839
Change-Id: I66e7cbdb811666ca352cdf064b1228caa346d876
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-08-19 16:30:13 +03:00
Ahmad Samir
f516cf93b4 selftests/badxml/tst_badxml: compile with QT_NO_FOREACH
badString(): const'ify the static QList, this is both faster as the
compiler doesn't need to check if it has been already initialized, and
it means we can use it directly in ranged-for as the method returns
const QList&.

Drive-by change: don't go the long way around to get a const char*:
qPrintable(QString("fail %1").arg(ba))
instead use:
QTest::addRow("fail %s", ba.constData())
(thanks to dfaure for pointing it out in review).

Task-number: QTBUG-115839
Change-Id: I6e8efa6df47ee94f1d71a63e22ab121647e6bf20
Reviewed-by: David Faure <david.faure@kdab.com>
2023-08-19 16:30:05 +03:00
Ahmad Samir
9aeb38650d tst_QFreeList: build with QT_NO_FOREACH
The container is local to the function, but can't be made const due to
the way it's filled. The loop clearly doesn't modify the container so
use std::as_const and ranged-for.

Task-number: QTBUG-115839
Change-Id: Ia9f01dfaccfca3225fe0487aafd0a386605cf466
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-08-19 16:29:54 +03:00
Ahmad Samir
964e6c6754 tst_QTemporaryDir/File: compile with QT_NO_FOREACH
These are member containers of nested (in the test function) structs.
It's clear the container isn't modified in the loop body, so use
ranged-for and std::as_const.

Remove "#undef QT_NO_FOREACH".

Task-number: QTBUG-115839
Change-Id: I0588bf4b6520b42d6d8678d702192fb894956b05
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-08-19 16:29:47 +03:00
Ahmad Samir
1612ddac40 tst_QStorageInfo: compile with QT_NO_FOREACH
This is a local container that isn't modified in the loop, so use a
ranged-for loop with std::as_const.

Task-number: QTBUG-115839
Change-Id: Ie9129e065f8ae9bd8c93cf95093a77529aef0803
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-08-19 16:29:40 +03:00
Ahmad Samir
71397212ef tests/auto/*: port Q_FOREACH to ranged-for, make container const
Use std::initializer_list/std::array for data known at compile time.

In files where Q_FOREACH isn't used any more, remove
"#undef QT_NO_FOREACH".

Drive-by change: de-duplicate some trivial code.

Task-number: QTBUG-115839
Change-Id: Ifb1a93579bd4ab8fd10f78665a28559cc61da7e2
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-08-19 16:29:30 +03:00
Ahmad Samir
8e0281a8be tests/auto/: port Q_FOREACH to ranged-for, local const containers
These are local containers that are either:
- Already const and didn't need Q_FOREACH to begin with
- Can be simply made const, just by adding const keyword

In one case the unittest checked that the container's size is 1, so use
list.first() instead of a for-loop.

In files where Q_FOREACH isn't used any more, remove
"#undef QT_NO_FOREACH". Also remove those files from NO_PCH_SOURCES.

Drive-by changes:
- Remove parenthesis from one-line for-loops
- Make the for-loop variable a const& where a copy isn't needed

Task-number: QTBUG-115839
Change-Id: Ide34122b9cda798b80c4ca9d2d5af76024bc7a92
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-08-19 16:29:25 +03:00
Ahmad Samir
e7b07b64c7 tests/auto/*: port Q_FOREACH to ranged-for
The loop was iterating over a temporary container, so it couldn't have
changed it. Store the container in a const auto variable and use
ranged-for.

In files where Q_FOREACH isn't used any more, remove
"#undef QT_NO_FOREACH".

Task-number: QTBUG-115839
Change-Id: I402df5fa48f4287f3cc989ddae1524da43999049
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-08-19 16:29:09 +03:00
Ahmad Samir
c7a8e1e992 tst_QDirIterator: build with QT_NO_FOREACH
cleanupTestCase: the loops don't change the member containers, so use
std::as_const and ranged for.

iterateRelativeDirectory(): the for loop doesn't change the container,
so make it const to begin with, and use a ranged-for loop.

Drive-by change: make the for-loop variables const&, no need to create
unnecessary copies.

Task-number: QTBUG-115839
Change-Id: Ic2776459f695c9f334f83916b1c9bbe5646a3b9d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-08-19 16:29:03 +03:00
Ahmad Samir
019554a399 tst_QDir: compile with QT_NO_FOREACH
Each loop was iterating over temporary containers, so use a const auto
variable to hold it and use ranged-for

Drive-by change: make the for-loop variable a const& (QString,
QFileInfo).

Task-number: QTBUG-115839
Change-Id: Idffaedb8e2e8782a0f4f907995f62f3c0de44bba
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-08-19 16:28:53 +03:00
Ahmad Samir
9812df02db tst_QDir: port Q_FOREACH with QList::removeIf
filterLinks() is always called on a temporary QStringList, so make it
take by && (which proves it's always called on a temporary), and modify
the parameter directly.

Task-number: QTBUG-115839
Change-Id: I40611f40cc0096a58d5c9d8e68c5df06d43152e5
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-08-19 16:28:45 +03:00
Ahmad Samir
645dcc27d3 tst_QAbstractFileEngine: compile with QT_NO_FOREACH
cleanupTestCase(): the loop doesn't modify the member container, so use
std::as_const and a ranged-for.

mounting(): the loop was iterating over a temporary QList, store it in a
local auto variable and use ranged-for.

Drive-by change: add braces to a multi-lined for block.

Task-number: QTBUG-115839
Change-Id: I0542cad4df3730d6a09b39e64a54a84fc0d57062
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-08-19 16:28:33 +03:00
Ahmad Samir
0766d55d22 tst_QtConcurrentMedian: compile with QT_NO_FOREACH
One trivial case: container newly marked as const.

Task-number: QTBUG-115839
Change-Id: Ief788beab2f84b656e429ce3e96bbd691f6d4c71
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-08-19 16:28:20 +03:00
Marc Mutz
02add2a807 tst_QImageReader: fix a trivial Q_FOREACH and remove #undef QT_NO_FOREACH
Other recent commits have fixed the other Q_FOREACH uses in this file.

Task-number: QTBUG-115839
Change-Id: I03063f3e8f1e99c5a2aa2d9188260f3e79ca43bd
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-19 08:19:47 +03:00
Marc Mutz
11d6932560 Mark all of Qt as free of Q_FOREACH, except where it isn't
The density of Q_FOREACH uses in this and some other modules is still
extremely high, too high for anyone to tackle in a short amount of
time. Even if they're not concentrated in just a few TUs, we need to
make progress on a global QT_NO_FOREACH default, so grab the nettle
and stick to our strategy:

Mark the whole of Qt with QT_NO_FOREACH, to prevent new uses from
creeping in, and whitelist the affected TUs by #undef'ing
QT_NO_FOREACH locally, at the top of each file. For TUs that are part
of a larger executable, this requires these files to be compiled
separately, so add them to NO_PCH_SOURCES (which implies
NO_UNITY_BUILD_SOURCES, too).

In tst_qglobal.cpp and tst_qcollections.cpp change the comment on the
#undef QT_NO_FOREACH to indicate that these actually test the macro.

Task-number: QTBUG-115839
Change-Id: Iecc444eb7d43d7e4d037f6e155abe0e14a00a5d6
Reviewed-by: Edward Welbourne <edward.welbourne@qt.io>
2023-08-19 05:19:42 +00:00
Ahmad Samir
5941f192ab tst_QtBench: fix leak
Instead make "benchmarks" a member variable and call qDeleteAll() on it
in cleanupTestCase(). This doesn't make much difference since the
allocated resources would be freed when the whole test is destroyed
anyway, but still.

Change-Id: Iba66d32697fd3f2283185ee65a0a514176b4b258
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-08-18 23:40:29 +03:00
Edward Welbourne
15cfdab514 Give QLocale's name() and bcp47Name() separator parameters
Previously name() has always used underscore and bcp47Name() dash; let
the user chose which one best fits their needs.

[ChangeLog][QtCore][QLocale] QLocale's name() and bcp47Name() now let
the caller chose what separator to use between the tags making up the
name, where there is more than one.

Change-Id: Ia689e6a3fb581b42905e7fb1ae7a7b688244d267
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-08-18 18:39:14 +02:00
Ivan Solovev
470b2b8ad9 QUuid: convert bswap(Id128Bytes) to a hidden friend of Id128Bytes
... and rename it to qbswap(), thus enabling the endian conversions
for Id128bytes via q{To,From}{Little,Big}Endian() functions.

Found during Qt 6.6 API Review.

Pick-to: 6.6
Change-Id: Ie320cee52ec2b9de0aaa112adec8febb7f5b68a2
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
2023-08-18 18:00:09 +02:00
Santhosh Kumar
90980a54e8 Rename accent color in QPalette
Accent color role has been renamed according to name rule of other
color roles in QPalette.

Fixes: QTBUG-116107
Pick-to: 6.6
Change-Id: I70ac98a1e97afbdc7ea5f8d79f808c307e170712
Reviewed-by: Mitch Curtis <mitch.curtis@qt.io>
2023-08-18 00:38:38 +02:00
Allan Sandfeld Jensen
ae9594ea98 Increase setup precision and reduce test precision
Reduce test precision to account for rounding errors, and at the same
time increase the setup precession by premultiplying in rgba64 instead
of argb32, which makes the test randomness trigger more regularly.

Pick-to: 6.6
Task-number: QTBUG-115945
Change-Id: I3e95449ada26ff5bb0acc00412f345733603f4c0
Reviewed-by: Timur Pocheptsov <timur.pocheptsov@qt.io>
2023-08-17 22:35:34 +02:00
Timur Pocheptsov
600d16df22 tst_gestures: use proper spelling 'macos' (not 'macOS') arm
Task-number: QTBUG-115945
Change-Id: I842726dc2af07cf61535a52af08e0fe8b13ee304
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-08-17 20:16:21 +02:00
Orkun Tokdemir
bc0c44d4cd _qt_internal_create_moc_command: Fix genex parse
The function was replacing the `>` character in generator expressions coming from `add_compile_definitions`. This was creating generator expression syntax errors. Discard generator expressions from character replacing.
Add tests for the three cases.

Fixes: QTBUG-111717
Change-Id: I694d2908738085fdf15112834f20183a9f393422
Reviewed-by: Alexandru Croitor <alexandru.croitor@qt.io>
2023-08-17 13:09:46 +02:00
Volker Hilsheimer
3965d52ad5 QTabBar: don't make current tab visible while tab bar is invisible
When changing the current index while the tab bar is not visible,
calculating the necessary scroll offset might result in wrong results if
the tab bar still has an old size. When the tab bar then gets shown and
resized, the scroll wouldn't be corrected, potentially leaving tabs
unnecessarily scrolled out.

We don't need to make the current index visible if the tab bar itself is
not visible, it's enough to flag the layout as dirty so that the next
show event (which either way makes the then current index visible)
triggers a laying out of the tab bar tabs.

Amends e851d4c06154bf02b23030ff1f7024a8b9edf874.

Fixes: QTBUG-115109
Task-number: QTBUG-113140
Pick-to: 6.6 6.5
Change-Id: I3d8633f9f8b907a36190123839a6104a17bfe138
Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org>
Reviewed-by: David Faure <david.faure@kdab.com>
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-08-16 22:36:35 +02:00
Mikolaj Boc
c0c9e43be1 Add a special testcase for IndexedDB settings only
The test removes the file in memfs that IndexedDB settings use as the
backing store. This forces a new instance of IDB settings to read from
the actual IndexedDB, instead of the file.

Change-Id: I7c04a90ae80e47b7742bd133b2d9327ce0063fe2
Reviewed-by: Morten Johan Sørvig <morten.sorvig@qt.io>
2023-08-16 17:17:13 +02:00
Edward Welbourne
91e70f239e Give QLocale::uiLanguages() a separator parameter
It has always returned dash-joined forms of the locale names, and
callers who need an underscore-joined form have been obliged to
replace('-', '_') before using them. Given that everything it adds to
the list comes from QLocaleId methods that accept a separator, it's
trivial to let it offer the same choice to its callers and save them
this hassle.

Amended code in QTranslater and QMimeType to save them that hassle.

[ChangeLog][CoreLib][QLocale] QLocale::uiLanguages() now lets the
caller choose what separator to use between the tags that make up each
locale-identifier in the list returned.

Change-Id: I91fcd0b988d9a64e0e9ad9e851f6cb8c1be8ae50
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-08-16 16:25:48 +02:00
Marc Mutz
c86cf385d6 tst_QHashFunctions: extend the consistency() test with int/FP types
It's ... broken. Found and filed lots of bugs. Add #ifdef'ery and
QEXPECTED_FAIL() to document the state of affairs, hopefully reminding
us to fix these things come Qt 7.

Task-number: QTBUG-116064
Task-number: QTBUG-116076
Task-number: QTBUG-116077
Task-number: QTBUG-116079
Task-number: QTBUG-116080
Pick-to: 6.6 6.5
Change-Id: I29e89fdf995ddf60ef1e03c7af009e80980c9817
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-08-16 12:56:50 +00:00
Marc Mutz
fa522eb8be tst_QHashFunctions: use actual seed in consistent() test function
We were only ever testing with a 0 seed, even though the function was
called for all QFETCH_GLOBAL seeds.

Add the seed.

Amends 5e93361888.

Pick-to: 6.6 6.5 6.2 5.15
Change-Id: I3c78714ad6fb3f94233789dd2c8884d9b157fa76
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-08-16 04:23:51 +02:00
Ahmad Samir
d50fd6acfa tst_qdbusconnection: iterate over member container directly
The loops don't change the m_connections container. The call chain is:
- registerObjectPeer() unittest constructs a MyServer, which connects
  QDBusServer::newConnection to MyServer::handleConnection(), the
  latter stores each new connection's name in m_connections
- An QTestEventLoop is entered, which triggers handleConnection(),
  handleConnection() calls exitLoop() at the bottom (this is repeated
  multiple times)
- server.unregisterObject() is called, iterating over m_connections
- server.registerObject() is called iterating over m_connections
- between the unregisterObject() call and the registerObject() calls
  m_connections is not modified AFAICS

Thus no need for taking a copy of m_connections (not that it matters
much, it's a QStringList with size() == 3).

Change-Id: Idaea2ca4d3b27fc88d39f8434e3817a2a4098c72
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-08-15 21:27:50 +03:00
Marc Mutz
c0a3806609 tst_macdeplyqt: unbreak runVerifyDeployment()
Amends f2f8820073.

I have no idea how this went through the CI, but assigning to a const
variable cannot possibly compile.

Reported-by: Axel Spoerl <axel.spoerl@qt.io>
Pick-to: 6.6 6.5
Task-nubmber: QTBUG-115839
Change-Id: I0f22dcd5ab691f92880ea3c6446aedca53df0721
Reviewed-by: Axel Spoerl <axel.spoerl@qt.io>
2023-08-15 17:40:22 +00:00
Laszlo Agocs
55c79dcc25 rhi: add a way to test Display P3 with the manual test
Extended linear Display P3 + FP16 is likely the thing to use
on platforms such as VisionOS and iOS (and optionally on macOS)
and perhaps iOS). Enable testing this on macOS with the hdr
manual test.

Change-Id: I67f0bdbadae8c7ebccae7de008f12fd8d9135529
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
Reviewed-by: Christian Strømme <christian.stromme@qt.io>
2023-08-15 15:10:35 +02:00
Axel Spoerl
e03bc88a80 QDockWidgetGroupWindow::adjustFlags() - don't show() empty group window
The method calls show() on a dock widget group window, when the window
flags have changed. When all of its contained, tabbed dock widgets are
programmatically hidden or docked on the main window, an empty group
window is shown.

This patch implements bool hasVisibleDockWidgets(). It returns true, if
at least one of the group window's dockwidget children is not hidden.
It replaces show() by setVisible(), passing the return value of
hasVisibleChildren().

It adapts tst_QDockWidget::floatingTabs() to test the fix.
(Drive-by: remove dead code)

Fixes: QTBUG-115058
Pick-to: 6.6 6.5 6.2
Change-Id: Ifb8e2450e91a7c78decc06f592e160631ca2faf5
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
2023-08-15 10:47:28 +02:00
Axel Spoerl
ccd8a496cf QXmlStreamReader::readNextStartElement() - return false on document end
The method reads the next element in a loop, as long as valid elements
exist. Within the loop, it returns
- false if the end of an element has been reached
- true if a new element has started

When the document end has been reached, the loop continues, until
readNext() returns Invalid. Then, PrematureEndOfDocumentError is launched.

This is wrong, because reading beyond the document end is caused by a
missing return condition in the loop.

=> Treat document end like element end and return false without
reading beyond it.

=> Test correct behavior in tst_QXmlStream::readNextStartElement()

Fixes: QTBUG-25944
Pick-to: 6.6 6.5 6.2
Change-Id: I0160b65880756a2be541e9f55dc79557fcb1f09f
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
2023-08-15 07:16:31 +02:00
Thiago Macieira
56bd5d60c9 Fix registration of QtDBus types' metatypes
By actually registering them.

Commit 850d850c5a changed from
qMetaTypeId<QDBusArgument>() to QMetaType::fromType<QDBusArgument>() and
in Qt 6, fromType() does not register the type with the database. That
means the lines became runtime no-ops at that time or during the
QMetaType updates since 6.0. All they did was instantiate the C++ inline
variable.

The testing also detected we didn't register QList<QDBusVariant> as an
alias for the "av" signature. I'm not entirely sure you're allowed to
use this because QtDBus does not like re-registration of the built-in
types, and "av" is already assigned to QVariantList. This is no trouble
for the parser, anyway.

Minor change to qdbuscpp2xml to allow reading from stdin, so we don't
have to create temporary files.

Pick-to: 6.5 6.6
Fixes: QTBUG-115964
Change-Id: I80612a7d275c41f1baf0fffd177a14925e7d23ac
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
2023-08-14 20:19:36 -07:00
Thiago Macieira
7a1ffacca0 tests/tools: only run qdbus{cpp2xml,xml2cpp} tests if D-Bus is available
Strictly speaking, we don't need the *bus*, only libdbus-1, but some
machines in our CI appear to be misconfigured somehow. I don't
understand how they can both have and not have this library in the same
run.

Pick-to: 6.5 6.6
Change-Id: I80612a7d275c41f1baf0fffd177a66a04951948c
Reviewed-by: Ievgenii Meshcheriakov <ievgenii.meshcheriakov@qt.io>
2023-08-14 20:19:36 -07:00
Thiago Macieira
14d1108d35 Deprecate Q_ASSUME()
We've known for a long time that this is producing worse code with GCC
because of how we implemented in Q_ASSUME_IMPL(). So bite the bullet and
actually deprecate the macro, replacing all extant Q_ASSUME() with
Q_ASSERT().

The replacement is in C++23. Backporting the support onto Q_ASSUME_IMPL
was previously rejected by reviewers.

[ChangeLog][Deprecation Notice] The Q_ASSUME() macro is deprecated. This
macro has different side-effects depending on the compiler used (GCC
compared to Clang and MSVC), and there are certain conditions under
which GCC is known to produce worse code than if the macro was absent.
To give a hint to the compiler for optimizations, use the C++23
[[assume]] attribute.

Change-Id: I80612a7d275c41f1baf0fffd177a3a4ad819fb2d
Reviewed-by: Volker Hilsheimer <volker.hilsheimer@qt.io>
2023-08-14 17:36:37 -07:00