Commit Graph

15491 Commits

Author SHA1 Message Date
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
Marc Mutz
9c1d20337a Remove QUuid(quint128) constructor again
This constructor matches way too many argument types (integral,
unscoped enums, FP types), so it's likely to cause mayhem, even if
left in as an explicit constructor.

We now have a named constructor for the same functionality, so just
drop the "unnamed" constructor.

"Unnamed" constructors are important when emplacement is more
efficient than construction + move, or when implicit conversion is
required.  Neither is the case here: The named as well as the
"unnamed" constructors just copy ten bytes around, and the compiler
can optimize those extra copies away just fine.

Found in API review.

Pick-to: 6.6
Change-Id: I7faafd3ebf522fb2b0e450112fb95d643fece5ce
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-08-14 20:13:54 +00:00
Marc Mutz
3693dd74fe tst_QWizard: port from QSharedPointer to std::shared_ptr
QSharedPointer is 'meh', see QTBUG-109570 and 18113e22e9.

This is just a textual replacement of

- QSharedPointer<(.+)>::create() → std::make_shared<\1>()
- QSharedPointer → std::shared_ptr

And it compiles and still passes. No non-standard APIs to fix up.

Task-number: QTBUG-109570
Change-Id: I827d4a9be0511780c3900bd53ffcbdcb6aacbc3b
Reviewed-by: Richard Moe Gustavsen <richard.gustavsen@qt.io>
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
2023-08-14 23:11:54 +03:00
Marc Mutz
f2f8820073 tests: port assorted trivial uses of Q_FOREACH to ranged for loops
All of these fall into the trivial category: loops over (readily made)
const local containers. As such, they cannot possibly depend on the
safety copy that Q_FOREACH performs, so are safe to port as-is to
ranged for loops.

There may be more where these came from, but these were the ones that
stood out as immediately obvious when scanning the 100s of uses in
qtbase, so I preferred to directly fix them over white-listing their
files with QT_NO_FOREACH (which still may be necessary for some files,
as this patch may not port all uses in that file).

Pick-to: 6.6 6.5
Task-nubmber: QTBUG-115839
Change-Id: I7b7893bec8254f902660dac24167113aca855029
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Mårten Nordheim <marten.nordheim@qt.io>
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-08-14 23:11:54 +03:00
Marc Mutz
47375a213f QMimeDatabase benchmark: port away from Q_FOREACH
The original code duplicated contained elements of a QStringList by
repeated appending it to itself, preventing the container from being
marked const.

Instead, keep a list of unique mime-types, and iterate over the list
eight times.

As a drive-by, port from QList to a C array ("never use a
dynamically-sized container for statically-sized data"), use u""_s
UDLs (since we're touching almost all lines of the function, anyway,
also in the unrelated mimeTypeForName() call).

This allows porting the Q_FOREACH loop (which anyway cannot deal with
C arrays) to a ranged for one (which can).

Pick-to: 6.6 6.5
Task-number: QTBUG-115839
Change-Id: I844ae38104bb2980ea194b85f9017a3e95791ea2
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2023-08-14 23:11:54 +03:00
Marc Mutz
40afcb9d01 QtWidgets tests: port remaining users away from Q_FOREACH
These are all trivial: all are over (already or newly-made) const
local variables.

As a drive-by, replace a QList legacy left-shift-based- with
initializer_list-construction.

Pick-to: 6.6 6.5
Task-number: QTBUG-115803
Change-Id: I453e24272c4c4b7dce5b91a0bd04481d833c50bb
Reviewed-by: Ivan Solovev <ivan.solovev@qt.io>
2023-08-14 23:11:54 +03:00
Marc Mutz
6f5f10bea8 tst_QMainWindow: port away from Q_FOREACH
These are all trivial: all are over (already or newly-made) const
local variables.

As a drive-by, replace a QList with a C array
("never use a dynamically-sized container for statically-sized data").

Pick-to: 6.6 6.5
Task-number: QTBUG-115803
Change-Id: I1b1e8f093abf75093900631e6fe3cbc9e3019d34
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-08-14 23:11:54 +03:00
Marc Mutz
d4ba159148 QtWidgets benchmarks: port remaining users away from Q_FOREACH
These are all trivial: all are over (already or newly-made) const
local variables.

We don't have a mechanism to mark a subtree as Q_FOREACH-free, and
adding QT_NO_FOREACH to each executable is overkill, so we just have
to hope that no new uses are being introduced until we can mark the
whole QtBase module as Q_FOREACH-free.

Pick-to: 6.6 6.5
Task-number: QTBUG-115803
Change-Id: I13dc176756633674bab8c93a342ecdba6c5dd23e
Reviewed-by: Ahmad Samir <a.samirh78@gmail.com>
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: Joerg Bornemann <joerg.bornemann@qt.io>
2023-08-14 23:11:54 +03:00
Axel Spoerl
4c7cac682f QPlainTextEdit: update placeholder text when document is empty
When the placeholder text is changed after having been displayed, it
doesn't get updated on the screen any more, unless the entire viewport
is updated, e.g. because of a document change or a focus event.

This patch simplifies QPlainTextEditPrivate::updatePlaceHolderVisibility()
to update the visibility if the text document is empty.
It replaces the member QPlainTextEditorPrivate::placeholderVisible
by the function isPlaceHolderTextVisible(). It returns true, if the
document is empty and a placeholder text exists, and otherwise false.
It adapts and corrects tst_QPlainTextEdit::placeHolderVisibility():
- usage of new member function instead of data member.
- do not expect an empty placeholder to be visible.

Fixes: QTBUG-115831
Pick-to: 6.6 6.5 6.2
Change-Id: Ic4427ce7f7f1b8cde89957b9de0b978bd34ba923
Reviewed-by: Santhosh Kumar <santhosh.kumar.selvaraj@qt.io>
2023-08-14 17:11:27 +00:00
Laszlo Agocs
72a453c6a8 Add QRhiWidget
Task-number: QTBUG-113331
Change-Id: I8baa697b4997b05f52acdee0e08d3c368fde5bc2
Reviewed-by: Andy Nichols <andy.nichols@qt.io>
2023-08-14 17:05:36 +02:00
Axel Spoerl
be3b9b2ab1 QAndroidPlatformInputContext: send composition text and cursor jointly
QAndroidPlatformInputContext::focusObjectStopComposing() sends an input
event for each character newly added by the Android virtual keyboard.
It then sends a second input event to notify that the cursor has
advanced to the position after the new character.
The implicit assumption is, that the receiver of the input event does
not change the text.

If e.g. QLineEdit::setText() is called in the QLineEdit::textEdited
slot, the text does change. If the change implies a cursor change,
QLineEdit notifies the platform input context about it.
However, by sending the second input event, QAndroidPlatformContent
returns the cursor back to the position after the last character added
by the virtual keyboard.

This patch joins the composed text and the cursor position into one
single input method event. A new cursor position, set by the receiver
of the input method event, is no longer overridden.
The patch adds test functionality to tst_QLineEdit::setText().

Fixes: QTBUG-115756
Pick-to: 6.6 6.5 6.2
Change-Id: I85ffac5d6bab93ccb144be0f5b8083258a270550
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@qt.io>
2023-08-14 16:24:45 +02:00
Piotr Wierciński
592f8630c6 CI: Enable tests under corelib/serialization for Wasm platform
Add more tests on WebAssembly platform for better tests coverage.

Change-Id: Iaaaa824ae6058a9ae5dba4c4038a7f687bfc17e0
Reviewed-by: Mikołaj Boc <Mikolaj.Boc@qt.io>
2023-08-14 16:08:32 +02:00